From: Alice Carlotti Date: Tue, 4 Nov 2025 12:28:56 +0000 (+0000) Subject: aarch64: Fix incorrect sysreg notes operand notes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9e512968b489276d5c950084e26fa2a49a9b983;p=thirdparty%2Fbinutils-gdb.git aarch64: Fix incorrect sysreg notes operand notes When support for Armv8-R was added in 2020, aarch64_print_operand was modified to check architecture features when searching for a system register name. However, this mismatch is then conflated with read-only/write-only mismatches, leading to incorrect note emission when reading a read-only or writing a write-only system register that is not available in whichever of Armv8-A or Armv8-R we are using. The original code also segfaults when parsing `msr mpuir_el1, w1'. This segfault arises while suggesting alternative assembler input with corrected qualifiers, due to a missing NULL check when attempting to emit notes. The segfault is unreachable after this change, but a subsequent patch will incorporate NULL checking anyway. Once notes are enabled by default, an existing `mrs x0, mpuir_el1' test will verify that the incorrect notes are no longer generated. --- diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c index b074765920e..d7e697e7247 100644 --- a/opcodes/aarch64-opc.c +++ b/opcodes/aarch64-opc.c @@ -5024,9 +5024,11 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc, indicates what we didn't want for this instruction. e.g. If F_REG_READ is there, that means we were looking for a write register. See aarch64_ext_sysreg. */ - if (aarch64_sys_regs[i].flags & F_REG_WRITE) + if (aarch64_sys_regs[i].flags & F_REG_WRITE + && !(opnd->sysreg.flags & F_REG_WRITE)) *notes = _("reading from a write-only register"); - else if (aarch64_sys_regs[i].flags & F_REG_READ) + else if (aarch64_sys_regs[i].flags & F_REG_READ + && !(opnd->sysreg.flags & F_REG_READ)) *notes = _("writing to a read-only register"); } }