[PATCH v2] aarch64: Remove guarding restrictions on system registers by default.

Srinath Parvathaneni srinath.parvathaneni@arm.com
Mon Jun 23 15:44:31 GMT 2025


Changes from v1->v2:
* Modified the patch description to indicate this patch only
  disables (but not remove) the existing code for sysreg
  guarding restrictions.
* Also mentioned this code can be enables by passing
  "-menable-sysreg-checking" flag.
* Added the reasons for proposing this patch in the description.
* Removed the default values or the sys_reg parameter name from
  the tests.
* To avoid exporting a variable from a shared library, we have used
  used function pointers to find the guarding status of system
  registers, so that libopcode-internal function calls returns bool
  for the status, while the gas-internal uses the integer variable.
-------------------------
The current implementation of system register in assembler are
guarded by following rules:
1. No restrictions.
2. Architecture version (eg: armv8.5-a)
3. Architecture features (eg:+sve)
4. Combination of both architecture version and architecture
   feature (eg: armv9.5-a+profile).
5. Combination of multiple architecture features (eg: +memtag+pops).

In this patch we are disabling all the above mentioned guarding
restrictions and making the system registers available by default
in the assembler.

Also we are adding a command line flag "-menable-sysreg-checking",
which enables the current restrictions on system registers.

The reasons for making these changes are:

1. Many system registers are gated by architecture features that don't
have a toolchain flag, so we can't accurately determine whether a system
register should be available based upon existing flags. We don't want to
add new toolchain flags just to enable more precise system register gating.

2. Existing feature guards are inconsistent and often too restrictive,
which means that there is generally no set of features we can use to enable
the correct system registers without incorrectly enabling some unsupported
data processing instructions.

3. Many system registers that were introduced as part of Armv8.x-a
are allowed to be implemented in Armv8.(x-1)-a, but existing gating in
Binutils tended to require Armv8.x-a instead.

Above mentioned reasons are some of the issues in the existing assembler,
which we plan to fix in the later versions of binutils.

But there is one exception with the default behaviour, even though we
have removed all the restrictions on system registers, the 128 bit
system instructions like mrrs and msrr which uses the 128 bit system
registers as operands, are not available unless we pass
".arch_extension d128" directive or "+d128" flag to the assembler.

eg:
	.arch_extension d128 // For the msrr and mrrs instructions.
        msrr    rcwmask_el1, x2, x3
        mrrs    x2, x3, rcwmask_el1

All the current system registers *.d files are added with
"-menable-sysreg-checking" flag to assembler, so that all those
system registers get testing with current guarding restrictions.

Also we have tested the assembler behaviour with this patch for
following scenarios:
1. sysregs with no guarding reatrictions.
2. sysregs with no guarding restrictions + "-menable-sysreg-checking".
3. sysregs with guarding restrictions + "-menable-sysreg-checking".

Regression tested for aarch64-none-elf target and found no regressions.

Ok for binutils-master?

Regards,
Srinath.

Co-authored-by: Andre Simoes Dias Vieira <andre.simoesdiasvieira@arm.com>
---
 gas/config/tc-aarch64.c                       |  25 ++-
 gas/config/tc-aarch64.h                       |   4 +
 gas/testsuite/gas/aarch64/armv8-ras-1.d       |   2 +-
 .../gas/aarch64/armv8_4-a-registers-illegal.d |   2 +-
 .../gas/aarch64/armv8_4-a-registers.d         |   2 +-
 gas/testsuite/gas/aarch64/gpc3.d              |   2 +-
 gas/testsuite/gas/aarch64/illegal-ite1-1.d    |   4 +-
 .../gas/aarch64/illegal-predres2-1.d          |   4 +-
 gas/testsuite/gas/aarch64/illegal.d           |   2 +-
 gas/testsuite/gas/aarch64/ite1.d              |   2 +-
 gas/testsuite/gas/aarch64/mec-arch-bad.d      |   2 +-
 gas/testsuite/gas/aarch64/mec.d               |   2 +-
 gas/testsuite/gas/aarch64/msr.d               |   2 +-
 gas/testsuite/gas/aarch64/pan-directive.d     |   2 +-
 gas/testsuite/gas/aarch64/pan.d               |   2 +-
 gas/testsuite/gas/aarch64/sme-8.d             |   2 +-
 gas/testsuite/gas/aarch64/ssbs-illegal2.d     |   2 +-
 gas/testsuite/gas/aarch64/ssbs1.d             |   2 +-
 gas/testsuite/gas/aarch64/ssbs2.d             |   2 +-
 .../gas/aarch64/sysreg/armv8_8-a-sysregs.d    |   2 +-
 .../aarch64/sysreg/armv8_9-a-sysregs-bad.d    |   2 +-
 .../gas/aarch64/sysreg/armv8_9-a-sysregs.d    |   2 +-
 .../armv9_5-a-sysregs-archv9_4-unsupported.d  |   2 +-
 .../gas/aarch64/sysreg/armv9_5-a-sysregs.d    |   2 +-
 .../aarch64/sysreg/fp8-feature-enables-fpmr.d |   2 +-
 .../sysreg/fpmr-unsupported-by-default.d      |   2 +-
 .../gas/aarch64/sysreg/gcs-sysregs-bad.d      |   2 +-
 .../gas/aarch64/sysreg/gcs-sysregs.d          |   2 +-
 .../gas/aarch64/sysreg/illegal-sysreg-3.d     |   2 +-
 .../gas/aarch64/sysreg/illegal-sysreg-4.d     |   2 +-
 .../gas/aarch64/sysreg/illegal-sysreg-4b.d    |   2 +-
 .../gas/aarch64/sysreg/illegal-sysreg-5.d     |   2 +-
 .../gas/aarch64/sysreg/illegal-sysreg-7.d     |   1 +
 .../gas/aarch64/sysreg/illegal-sysreg-8.d     |   2 +-
 .../gas/aarch64/sysreg/illegal-sysreg-8b.d    |   2 +-
 gas/testsuite/gas/aarch64/sysreg/mpam-bad.d   |   2 +-
 .../gas/aarch64/sysreg/pops-sysregs-bad.d     |   2 +-
 .../gas/aarch64/sysreg/pops-sysregs.d         |   2 +-
 .../gas/aarch64/sysreg/sme-sysreg-illegal.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sme-sysreg.d |   2 +-
 .../gas/aarch64/sysreg/sve-sysreg-invalid.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sve-sysreg.d |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-1.d   |   2 +-
 .../gas/aarch64/sysreg/sysreg-10-bad.d        |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-10.d  |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-2.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-3.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-4.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-6.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-7.d   |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-8.d   |   2 +-
 .../gas/aarch64/sysreg/sysreg-9-bad.d         |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg-9.d   |   2 +-
 .../gas/aarch64/sysreg/sysreg-diagnostic.d    |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg.d     |   2 +-
 gas/testsuite/gas/aarch64/sysreg/sysreg128.d  |   2 +-
 .../sysreg/sysregs_with_no_restrictions-bad.d |   3 +
 .../sysreg/sysregs_with_no_restrictions-bad.l | 173 ++++++++++++++++++
 .../sysreg/sysregs_with_no_restrictions.d     |  95 ++++++++++
 .../sysreg/sysregs_with_no_restrictions.s     |  56 ++++++
 .../sysreg/sysregs_with_restrictions.d        |  95 ++++++++++
 .../sysreg/sysregs_with_restrictions.s        |  93 ++++++++++
 .../gas/aarch64/sysreg/v8-r-bad-sysregs.d     |   1 +
 .../aarch64/sysreg/v8-r-sysregs-need-arch.d   |   1 +
 .../gas/aarch64/sysreg/v8-r-sysregs.d         |   2 +-
 gas/testsuite/gas/aarch64/uao-directive.d     |   2 +-
 gas/testsuite/gas/aarch64/uao.d               |   2 +-
 .../gas/aarch64/virthostext-directive.d       |   2 +-
 gas/testsuite/gas/aarch64/virthostext.d       |   2 +-
 include/opcode/aarch64.h                      |   2 +
 opcodes/aarch64-opc.c                         |  13 +-
 opcodes/aarch64-opc.h                         |   2 +
 72 files changed, 622 insertions(+), 62 deletions(-)
 create mode 100644 gas/testsuite/gas/aarch64/sysreg/sysregs_with_no_restrictions-bad.d
 create mode 100644 gas/testsuite/gas/aarch64/sysreg/sysregs_with_no_restrictions-bad.l
 create mode 100644 gas/testsuite/gas/aarch64/sysreg/sysregs_with_no_restrictions.d
 create mode 100644 gas/testsuite/gas/aarch64/sysreg/sysregs_with_no_restrictions.s
 create mode 100644 gas/testsuite/gas/aarch64/sysreg/sysregs_with_restrictions.d
 create mode 100644 gas/testsuite/gas/aarch64/sysreg/sysregs_with_restrictions.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-aarch64-Remove-guarding-restrictions-on-system-re.patch
Type: text/x-patch
Size: 51989 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20250623/5d60f86b/attachment-0001.bin>


More information about the Binutils mailing list