Skip to contentSkip to conversation

target/arm: Implement ID_AA64PFR2_EL1

PATCH In review Peter Maydell 3 participants 6 messages Sep 23, 2025 – Sep 24, 2025

lore
Share & tools
lore
#0 lore raw

v2 cover target/arm: Implement ID_AA64PFR2_EL1

The ID register ID_AA64PFR2_EL1 is in the space previously reserved in the system register ID space, but recent versions of the architecture have started to define fields in it to advertise the presence of new architectural features. We don't implement any of those new features yet, but will need to do so at some point. (Notably, the GICv5 EAC spec defines a field in this register to advertise the GICv5 CPU interface.)

This patchset gives ID_AA64PFR2_EL1 a backing field in the CPU ID regs struct, defines the field names, and reads it from KVM if it's present there. The only visible behaviour change is the name we present to the user via the gdbstub.

Commit 1 is a code movement one to clear some more stuff out of cpu.h that doesn't need to be there; it's mostly because of that that I'm sending this patchset rather than holding on to it until I have some GICv5 patches ready to send.

(Compare commit f7ddd7b6a1f90c from last year which added the ID_AA64MMFR3_EL1 register.)

v2 here is just a rebase which updates the patchset to handle the new array-based storage we're using for ID register values.

thanks
-- PMM

Peter Maydell (2):
target/arm: Move ID register field defs to cpu-features.h target/arm: Implement ID_AA64PFR2_EL1

 linux-user/arm/target_proc.h |   2 +
 target/arm/cpu-features.h    | 415 +++++++++++++++++++++++++++++++++++
 target/arm/cpu.h             | 410 ----------------------------------
 target/arm/cpu-sysregs.h.inc |   1 +
 target/arm/helper.c          |   6 +-
 target/arm/hvf/hvf.c         |   2 +
 target/arm/kvm.c             |   1 +
 7 files changed, 425 insertions(+), 412 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 target/arm: Move ID register field defs to cpu-features.h

Currently we define constants for the ID register fields in cpu.h. This means they're defined for a lot more code in QEMU than actually needs them. Move them to cpu-features.h, which is where we define the feature functions that test fields in these registers.

There's only one place where we need to use some of these macro definitions that we weren't already including cpu-features.h:
linux-user/arm/target_proc.h. Otherwise this patch is a pure movement of code from one file to the other.

---
 linux-user/arm/target_proc.h |   2 +
 target/arm/cpu-features.h    | 410 +++++++++++++++++++++++++++++++++++
 target/arm/cpu.h             | 410 -----------------------------------
 3 files changed, 412 insertions(+), 410 deletions(-)
linux-user/arm/target_proc.h +2 -0
index a4cd6948c60..a28d7231cdc 100644
@@ -6,6 +6,8 @@
 #ifndef ARM_TARGET_PROC_H
 #define ARM_TARGET_PROC_H
 
+#include "target/arm/cpu-features.h" /* for MIDR_EL1 field definitions */
+
 static int open_cpuinfo(CPUArchState *cpu_env, int fd)
 {
     ARMCPU *cpu = env_archcpu(cpu_env);
target/arm/cpu-features.h +410 -0

416 lines not on this page · raw message

target/arm/cpu.h +0 -410

416 lines not on this page · raw message

Signature · 1 line
2.43.0
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] target/arm: Move ID register field defs to cpu-features.h

Quoted 10 lines · Peter Maydell

Currently we define constants for the ID register fields in cpu.h. This means they're defined for a lot more code in QEMU than actually needs them. Move them to cpu-features.h, which is where we define the feature functions that test fields in these registers.

There's only one place where we need to use some of these macro definitions that we weren't already including cpu-features.h:
linux-user/arm/target_proc.h. Otherwise this patch is a pure movement of code from one file to the other.

Quoted 6 lines
---
  linux-user/arm/target_proc.h |   2 +
  target/arm/cpu-features.h    | 410 +++++++++++++++++++++++++++++++++++
  target/arm/cpu.h             | 410 -----------------------------------
  3 files changed, 412 insertions(+), 410 deletions(-)
#3 lore raw

PATCH v2 2/2 target/arm: Implement ID_AA64PFR2_EL1

In reply to Peter Maydell

Currently we define the ID_AA64PFR2_EL1 encoding as reserved (with the required RAZ behaviour for unassigned system registers in the ID register encoding space). Newer architecture versions start to define fields in this ID register, so define the appropriate constants and implement it as an ID register backed by a field in cpu->isar. Since none of our CPUs set that isar field to non-zero, there is no behavioural change here (other than the name exposed to the user via the gdbstub), but this paves the way for implementing the new features that use fields in this register.

The fields here are the ones documented in rev L.b of the Arm ARM.

---
 target/arm/cpu-features.h    | 5 +++++
 target/arm/cpu-sysregs.h.inc | 1 +
 target/arm/helper.c          | 6 ++++--
 target/arm/hvf/hvf.c         | 2 ++
 target/arm/kvm.c             | 1 +
 5 files changed, 13 insertions(+), 2 deletions(-)
target/arm/cpu-features.h +5 -0
index ad571e2ffee..602f6a88e53 100644
@@ -277,6 +277,11 @@ FIELD(ID_AA64PFR1, MTEX, 52, 4)
 FIELD(ID_AA64PFR1, DF2, 56, 4)
 FIELD(ID_AA64PFR1, PFAR, 60, 4)
 
+FIELD(ID_AA64PFR2, MTEPERM, 0, 4)
+FIELD(ID_AA64PFR2, MTESTOREONLY, 4, 4)
+FIELD(ID_AA64PFR2, MTEFAR, 8, 4)
+FIELD(ID_AA64PFR2, FPMR, 32, 4)
+
 FIELD(ID_AA64MMFR0, PARANGE, 0, 4)
 FIELD(ID_AA64MMFR0, ASIDBITS, 4, 4)
 FIELD(ID_AA64MMFR0, BIGEND, 8, 4)
target/arm/cpu-sysregs.h.inc +1 -0
index f48a9daa7c1..2bb2861c623 100644
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 DEF(ID_AA64PFR0_EL1, 3, 0, 0, 4, 0)
 DEF(ID_AA64PFR1_EL1, 3, 0, 0, 4, 1)
+DEF(ID_AA64PFR2_EL1, 3, 0, 0, 4, 2)
 DEF(ID_AA64SMFR0_EL1, 3, 0, 0, 4, 5)
 DEF(ID_AA64DFR0_EL1, 3, 0, 0, 5, 0)
 DEF(ID_AA64DFR1_EL1, 3, 0, 0, 5, 1)
target/arm/helper.c +4 -2
index c44294711f8..258cda4e90e 100644
@@ -6278,11 +6278,11 @@ void register_cp_regs_for_features(ARMCPU *cpu)
               .access = PL1_R, .type = ARM_CP_CONST,
               .accessfn = access_aa64_tid3,
               .resetvalue = GET_IDREG(isar, ID_AA64PFR1)},
-            { .name = "ID_AA64PFR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64,
+            { .name = "ID_AA64PFR2_EL1", .state = ARM_CP_STATE_AA64,
               .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 2,
               .access = PL1_R, .type = ARM_CP_CONST,
               .accessfn = access_aa64_tid3,
-              .resetvalue = 0 },
+              .resetvalue = GET_IDREG(isar, ID_AA64PFR2)},
             { .name = "ID_AA64PFR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64,
               .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 4, .opc2 = 3,
               .access = PL1_R, .type = ARM_CP_CONST,
@@ -6510,6 +6510,8 @@ void register_cp_regs_for_features(ARMCPU *cpu)
                                R_ID_AA64PFR1_SSBS_MASK |
                                R_ID_AA64PFR1_MTE_MASK |
                                R_ID_AA64PFR1_SME_MASK },
+            { .name = "ID_AA64PFR2_EL1",
+              .exported_bits = 0 },
             { .name = "ID_AA64PFR*_EL1_RESERVED",
               .is_glob = true },
             { .name = "ID_AA64ZFR0_EL1",
target/arm/hvf/hvf.c +2 -0
index b77db99079e..90e438e4e16 100644
@@ -495,6 +495,7 @@ static struct hvf_sreg_match hvf_sreg_match[] = {
     { HV_SYS_REG_ID_AA64PFR0_EL1, HVF_SYSREG(0, 4, 3, 0, 0) },
 #endif
     { HV_SYS_REG_ID_AA64PFR1_EL1, HVF_SYSREG(0, 4, 3, 0, 1) },
+    /* Add ID_AA64PFR2_EL1 here when HVF supports it */
     { HV_SYS_REG_ID_AA64DFR0_EL1, HVF_SYSREG(0, 5, 3, 0, 0) },
     { HV_SYS_REG_ID_AA64DFR1_EL1, HVF_SYSREG(0, 5, 3, 0, 1) },
     { HV_SYS_REG_ID_AA64ISAR0_EL1, HVF_SYSREG(0, 6, 3, 0, 0) },
@@ -869,6 +870,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
     } regs[] = {
         { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.idregs[ID_AA64PFR0_EL1_IDX] },
         { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.idregs[ID_AA64PFR1_EL1_IDX] },
+        /* Add ID_AA64PFR2_EL1 here when HVF supports it */
         { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.idregs[ID_AA64DFR0_EL1_IDX] },
         { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.idregs[ID_AA64DFR1_EL1_IDX] },
         { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.idregs[ID_AA64ISAR0_EL1_IDX] },
target/arm/kvm.c +1 -0
index c1ec6654ca6..65a262529a7 100644
@@ -324,6 +324,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
         err = 0;
     } else {
         err |= get_host_cpu_reg(fd, ahcf, ID_AA64PFR1_EL1_IDX);
+        err |= get_host_cpu_reg(fd, ahcf, ID_AA64PFR2_EL1_IDX);
         err |= get_host_cpu_reg(fd, ahcf, ID_AA64SMFR0_EL1_IDX);
         err |= get_host_cpu_reg(fd, ahcf, ID_AA64DFR0_EL1_IDX);
         err |= get_host_cpu_reg(fd, ahcf, ID_AA64DFR1_EL1_IDX);
Signature · 1 line
2.43.0
Reviewed-by on v2 2/2
#4 lore raw
Quoted 12 lines · Peter Maydell

Currently we define the ID_AA64PFR2_EL1 encoding as reserved (with the required RAZ behaviour for unassigned system registers in the ID register encoding space). Newer architecture versions start to define fields in this ID register, so define the appropriate constants and implement it as an ID register backed by a field in cpu->isar. Since none of our CPUs set that isar field to non-zero, there is no behavioural change here (other than the name exposed to the user via the gdbstub), but this paves the way for implementing the new features that use fields in this register.

The fields here are the ones documented in rev L.b of the Arm ARM.

Quoted 8 lines
---
  target/arm/cpu-features.h    | 5 +++++
  target/arm/cpu-sysregs.h.inc | 1 +
  target/arm/helper.c          | 6 ++++--
  target/arm/hvf/hvf.c         | 2 ++
  target/arm/kvm.c             | 1 +
  5 files changed, 13 insertions(+), 2 deletions(-)

To the best of my knowledge,

Reviewed-by on the v2 series
#5 lore raw
In reply to Peter Maydell
Quoted 24 lines · Peter Maydell

The ID register ID_AA64PFR2_EL1 is in the space previously reserved in the system register ID space, but recent versions of the architecture have started to define fields in it to advertise the presence of new architectural features. We don't implement any of those new features yet, but will need to do so at some point. (Notably, the GICv5 EAC spec defines a field in this register to advertise the GICv5 CPU interface.)

This patchset gives ID_AA64PFR2_EL1 a backing field in the CPU ID regs struct, defines the field names, and reads it from KVM if it's present there. The only visible behaviour change is the name we present to the user via the gdbstub.

Commit 1 is a code movement one to clear some more stuff out of cpu.h that doesn't need to be there; it's mostly because of that that I'm sending this patchset rather than holding on to it until I have some GICv5 patches ready to send.

(Compare commit f7ddd7b6a1f90c from last year which added the ID_AA64MMFR3_EL1 register.)

v2 here is just a rebase which updates the patchset to handle the new array-based storage we're using for ID register values.

Quoted 7 lines

thanks
-- PMM

Peter Maydell (2):
target/arm: Move ID register field defs to cpu-features.h target/arm: Implement ID_AA64PFR2_EL1

r~