]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
aarch64: Disallow invalid SVE addressing modes
authorAlice Carlotti <alice.carlotti@arm.com>
Tue, 8 Apr 2025 16:30:39 +0000 (17:30 +0100)
committerAlice Carlotti <alice.carlotti@arm.com>
Fri, 9 May 2025 17:04:37 +0000 (18:04 +0100)
commit4250bea744bdd373ba82b237ef7b1e77570f3fb3
tree533090d587d1b3e48773d9da7c72efe1ce3b8a5c
parentb304edbeb6d5bcc7c39929de961b6b3a9265799b
aarch64: Disallow invalid SVE addressing modes

The fix for PR22988 in 2018 added a new operand AARCH64_OPND_SVE_ADDR_R
to support implicit XZR offsets, but this fix had several flaws that
meant it accepted several invalid addressing modes:

1. The base register type wasn't properly checked when the optional
register offset was omitted.  This meant that
  ldff1b {z1.s}, p1/z,[z1.d]
was parsed as if it were
  ldff1b z1.d, p1/z, [x1.d, xzr].

2. The explicit offset parsing didn't include a shift type, so the new
operand would incorrectly parse
  ldff1h{z0.s}, p0/z, [x0, x0]
as if it were
  ldff1h{z0.s}, p0/z, [x0, x0, lsl #1].

3. Regardless of the above correctness issues, support for implicit
offsets should have been added by amending the operands in the existing
opcode table entries, instead of adding new duplicate table entires.

Issue 1 can be fixed by using an "if" instead of an "else if" in
parse_operands, while issue 2 can be fixed by failing when the first
condition is false.  This patch applies just these two fixes, leaving
issue 3 to be addressed in a subsequent more invasive patch.

The instructions removed from the test sme-5.d are architecturally
invalid. The new tests cover all of the affected ldff1 variants; the
issue also affected SME ZA ld1*/st1* instructions using the same operand
type.
gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/sme-5.d
gas/testsuite/gas/aarch64/sme-5.s
gas/testsuite/gas/aarch64/sve-ldff1-invalid.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/sve-ldff1-invalid.l [new file with mode: 0644]
gas/testsuite/gas/aarch64/sve-ldff1-invalid.s [new file with mode: 0644]