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.
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");
}
}