arm: demuxed ID registers (CCSIDR_EL1)
cover arm: demuxed ID registers (CCSIDR_EL1)
Note: this is on top of <[email protected]> ("[PATCH v3 0/2] arm: move DCZID_EL0 to idregs array")
While trying to move to an autogenerated cpu-sysregs.h.inc (so that we may keep a common view on registers), we should first address the ID registers that are still kept outside of ARMISARegisters. Other than DCZID_EL0 (addressed by the series this one goes on top of), that's the CCSIDR_EL1 values kept in cpu->cssidr[] (indexed via CSSELR_EL1.)
My idea was to provide {GET,SET}_IDREG_DEMUX helper that work similar to {GET,SET}_IDREG and operate on a two-dimensional array. As a side effect, this also allows to get the values KVM provides for CCSIDR_EL1 (which are virtualized as well.)
RFC because there are still some open questions:
- The demux array cannot easily be autogenerated. We can get rid of the ccsidr[] array, but we now have an autogenerated entry in the non-demux array that does nothing. Both are not that nice.
- I'm not sure if we need any compat handling for KVM (on TCG, everything should stay the same.) In theory, the KVM interface allows setting values from userspace (I didn't try.)
- There's a slight disagreement between the current code (providing 16 entries for CCSIDR_EL1) and the KVM code (providing (7 cache levels) * (data/unified, instruction) = 14 entries.) With FEAT_MTE2, we might be needing 7 more entries.
Feedback appreciated.
Cornelia Huck (3):
arm: handle demuxed ID registers
arm: handle CCSIDR_EL1 as a demuxed register
arm/kvm: get demuxed ID registers from kvm
hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu-sysregs.h | 6 ++++ target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.h | 26 ++++++++++++---- target/arm/cpu64.c | 12 ++++---- target/arm/helper.c | 2 +- target/arm/kvm.c | 33 ++++++++++++++++++++ target/arm/tcg/cpu32.c | 32 +++++++++---------- target/arm/tcg/cpu64.c | 60 ++++++++++++++++++------------------ 9 files changed, 114 insertions(+), 60 deletions(-)
Signature · 1 line
2.52.0
RFC PATCH 1/3 arm: handle demuxed ID registers
For some registers, we do not have a single ID register, but actually an array of values (e.g. CCSIDR_EL1, where the actual value is determined by whatever CSSELR_EL1 points to.) If we want to avoid using a different way to handle registers like that for every instance, we should provide some kind of infrastructure. Therefore, add accessors {GET,SET}_IDREG_DEMUX that are similar to the accessors we already use for regular ID registers.
--- target/arm/cpu-sysregs.h | 5 +++++ target/arm/cpu.h | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+)
target/arm/cpu-sysregs.h +5 -0
@@ -35,6 +35,11 @@ typedef enum ARMSysRegs {#undef DEF +/* ID registers that vary based upon another register */ +typedef enum ARMIDRegisterDemuxIdx { +NUM_ID_DEMUX_IDX , +}ARMIDRegisterDemuxIdx ; +extern const uint32_t id_register_sysreg[NUM_ID_IDX ];int get_sysreg_idx (ARMSysRegs sysreg);
target/arm/cpu.h +20 -0
@@ -905,6 +905,25 @@ typedef struct { i_->idregs[REG ## _EL1_IDX]; \ }) +#define SET_IDREG_DEMUX (ISAR ,REG ,INDEX ,VALUE ) \ + ({ \ + ARMISARegisters *i_ = (ISAR); \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][INDEX] = VALUE; \ + }) + +#define GET_IDREG_DEMUX (ISAR ,REG ,INDEX ) \ + ({ \ + ARMISARegisters *i_ = (ISAR); \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][INDEX]; \ + }) + +#define COPY_IDREG_DEMUX (ISAR ,REG ,FROM_INDEX ,TO_INDEX ) \ + ({ \ + ARMISARegisters *i_ = (ISAR); \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][TO_INDEX] = \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][FROM_INDEX]; \ + }) +/** * ARMCPU: * @env: #CPUARMState
@@ -1083,6 +1102,7 @@ struct ArchCPU {uint32_t dbgdevid1;uint64_t reset_pmcr_el0;uint64_t idregs[NUM_ID_IDX ]; +uint64_t idregs_demux[NUM_ID_DEMUX_IDX ][16 ]; } isar;uint64_t midr;uint32_t revidr;
Signature · 1 line
2.52.0
Re: [PATCH RFC 1/3] arm: handle demuxed ID registers
Quoted 61 lines · On Mon, 19 Jan 2026 18:27:30 +0100 Cornelia Huck <[email protected]> wrote:
For some registers, we do not have a single ID register, but actually an array of values (e.g.
CCSIDR_EL1, where the actual value is determined by whateverCSSELR_EL1points to.) If we want to avoid using a different way to handle registers like that for every instance, we should provide some kind of infrastructure. Therefore, add accessors {GET,SET}_IDREG_DEMUX that are similar to the accessors we already use for regular ID registers.Signed-off-by Cornelia Huck <[email protected]>--- target/arm/cpu-sysregs.h | 5 +++++ target/arm/cpu.h | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+)target/arm/cpu-sysregs.h +5
-0@@ -35,6 +35,11 @@ typedef enum ARMSysRegs {#undef DEF +/* ID registers that vary based upon another register */ +typedef enum ARMIDRegisterDemuxIdx { +NUM_ID_DEMUX_IDX , +}ARMIDRegisterDemuxIdx ; +extern const uint32_t id_register_sysreg[NUM_ID_IDX ];int get_sysreg_idx (ARMSysRegs sysreg);target/arm/cpu.h +19
-0@@ -905,6 +905,25 @@ typedef struct { i_->idregs[REG ## _EL1_IDX]; \ }) +#define SET_IDREG_DEMUX (ISAR ,REG ,INDEX ,VALUE ) \ + ({ \ + ARMISARegisters *i_ = (ISAR); \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][INDEX] = VALUE; \ + }) + +#define GET_IDREG_DEMUX (ISAR ,REG ,INDEX ) \ + ({ \ + ARMISARegisters *i_ = (ISAR); \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][INDEX]; \ + }) + +#define COPY_IDREG_DEMUX (ISAR ,REG ,FROM_INDEX ,TO_INDEX ) \ + ({ \ + ARMISARegisters *i_ = (ISAR); \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][TO_INDEX] = \ + i_->idregs_demux[REG ## _EL1_DEMUX_IDX][FROM_INDEX]; \ + }) +/** * ARMCPU: * @env: #CPUARMState
target/arm/cpu.h struct ArchCPU { · line 1105
Quoted 4 lines
target/arm/cpu.h +1
-0@@ -1083,6 +1102,7 @@ struct ArchCPU {uint32_t dbgdevid1;uint64_t reset_pmcr_el0;uint64_t idregs[NUM_ID_IDX ]; +uint64_t idregs_demux[NUM_ID_DEMUX_IDX ][16 ];
Hi,
Trivial, but I'd like a comment on why 16. I assume because that's the biggest you've seen so far (8 levels, 2 types for CCSIDR) Just good to have a bread crumb here for future readers.
Otherwise seems reasonable to me.
Quoted 3 lines
target/arm/cpu.h +0
-0} isar;uint64_t midr;uint32_t revidr;
Re: [PATCH RFC 1/3] arm: handle demuxed ID registers
Quoted 9 lines · Jonathan Cameron
target/arm/cpu.h struct ArchCPU { · line 1105
Quoted 5 lines · On Mon, 19 Jan 2026 18:27:30 +0100 Cornelia Huck <[email protected]> wrote:
target/arm/cpu.h +1
-0@@ -1083,6 +1102,7 @@ struct ArchCPU {uint32_t dbgdevid1;uint64_t reset_pmcr_el0;uint64_t idregs[NUM_ID_IDX ]; +uint64_t idregs_demux[NUM_ID_DEMUX_IDX ][16 ];Hi,
Quoted 3 lines
Trivial, but I'd like a comment on why 16. I assume because that's the biggest you've seen so far (8 levels, 2 types for CCSIDR) Just good to have a bread crumb here for future readers.
Yes, this came in via the current ccsidr[] sizing (which also might not be quite the right thing to use, given that we could have 2*7 + 7 entries with FEAT_MTE2); I'm not at all sure whether that's a reasonable value, but I'll certainly add a comment if we agree that it is. Or maybe make it a #define.
Quoted 2 lines
Otherwise seems reasonable to me.
Thanks for looking!
Quoted 3 lines
Quoted 3 lines
target/arm/cpu.h +0
-0} isar;uint64_t midr;uint32_t revidr;
RFC PATCH 2/3 arm: handle CCSIDR_EL1 as a demuxed register
In reply to Cornelia HuckMove handling of CCSIDR_EL1 over to the new *_IDREG_DEMUX infrastructure.
--- hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu-sysregs.h | 1 + target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.h | 6 ---- target/arm/cpu64.c | 12 ++++---- target/arm/helper.c | 2 +- target/arm/tcg/cpu32.c | 32 +++++++++---------- target/arm/tcg/cpu64.c | 60 ++++++++++++++++++------------------ 8 files changed, 56 insertions(+), 60 deletions(-)
hw/intc/armv7m_nvic.c +1 -1
@@ -1337,7 +1337,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)case 0xd80 :/* CSSIDR */ {int idx = cpu->env.v7m.csselr[attrs.secure] &R_V7M_CSSELR_INDEX_MASK ; -return cpu->ccsidr[idx]; +return GET_IDREG_DEMUX (&cpu->isar,CCSIDR , idx); }case 0xd84 :/* CSSELR */ return cpu->env.v7m.csselr[attrs.secure];
target/arm/cpu-sysregs.h +1 -0
@@ -37,6 +37,7 @@ typedef enum ARMSysRegs {/* ID registers that vary based upon another register */ typedef enum ARMIDRegisterDemuxIdx { +CCSIDR_EL1_DEMUX_IDX ,NUM_ID_DEMUX_IDX , }ARMIDRegisterDemuxIdx ;
target/arm/cpu-sysregs.h.inc +1 -0
@@ -36,6 +36,7 @@ DEF(MVFR2_EL1, 3, 0, 0, 3, 2) DEF(ID_PFR2_EL1, 3, 0, 0, 3, 4) DEF(ID_DFR1_EL1, 3, 0, 0, 3, 5) DEF(ID_MMFR5_EL1, 3, 0, 0, 3, 6) +DEF(CCSIDR_EL1, 3, 1, 0, 0, 0) DEF(CLIDR_EL1, 3, 1, 0, 0, 1) DEF(ID_AA64ZFR0_EL1, 3, 0, 0, 4, 4) DEF(CTR_EL0, 3, 3, 0, 0, 1)
target/arm/cpu.h +0 -6
@@ -1112,10 +1112,6 @@ struct ArchCPU {uint64_t pmceid0;uint64_t pmceid1;uint64_t mp_affinity;/* MP ID without feature bits */ -/* The elements of this array are the CCSIDR values for each cache, -* in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. -*/ -uint64_t ccsidr[16 ];uint64_t reset_cbar;uint32_t reset_auxcr;bool reset_hivecs;
@@ -2072,8 +2068,6 @@ FIELD(MFAR, FPA, 12, 40) FIELD(MFAR, NSE, 62, 1)FIELD (MFAR ,NS ,63 ,1 ) -QEMU_BUILD_BUG_ON (ARRAY_SIZE (((ARMCPU *)0 )->ccsidr) <=R_V7M_CSSELR_INDEX_MASK ); -/* If adding a feature bit which corresponds to a Linux ELF * HWCAP bit, remember to update the feature-bit-to-hwcap * mapping in linux-user/elfload.c:get_elf_hwcap().
target/arm/cpu64.c +6 -6
@@ -684,11 +684,11 @@ static void aarch64_a57_initfn(Object *obj) cpu->isar.reset_pmcr_el0 =0x41013000 ;SET_IDREG (isar,CLIDR ,0x0a200023 );/* 32KB L1 dcache */ - cpu->ccsidr[0 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,64 ,32 * KiB,7 ); +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,64 ,32 * KiB,7 ));/* 48KB L1 icache */ - cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,3 ,64 ,48 * KiB,2 ); +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,make_ccsidr (CCSIDR_FORMAT_LEGACY ,3 ,64 ,48 * KiB,2 ));/* 2048KB L2 cache */ - cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,64 ,2 * MiB,7 ); +SET_IDREG_DEMUX (isar,CCSIDR ,2 ,make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,64 ,2 * MiB,7 ));set_dczid_bs (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ;
@@ -746,11 +746,11 @@ static void aarch64_a53_initfn(Object *obj) cpu->isar.reset_pmcr_el0 =0x41033000 ;SET_IDREG (isar,CLIDR ,0x0a200023 );/* 32KB L1 dcache */ - cpu->ccsidr[0 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,64 ,32 * KiB,7 ); +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,64 ,32 * KiB,7 ));/* 32KB L1 icache */ - cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,1 ,64 ,32 * KiB,2 ); +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,make_ccsidr (CCSIDR_FORMAT_LEGACY ,1 ,64 ,32 * KiB,2 ));/* 1024KB L2 cache */ - cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,64 ,1 * MiB,7 ); +SET_IDREG_DEMUX (isar,CCSIDR ,2 ,make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,64 ,1 * MiB,7 ));set_dczid_bs (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ;
target/arm/helper.c +1 -1
@@ -866,7 +866,7 @@ static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri)uint32_t index =A32_BANKED_REG_GET (env, csselr, ri->secure &ARM_CP_SECSTATE_S ); -return cpu->ccsidr[index]; +return GET_IDREG_DEMUX (&cpu->isar,CCSIDR , index); } static void csselr_write(CPUARMState *env, const ARMCPRegInfo *ri,
target/arm/tcg/cpu32.c +16 -16
@@ -372,9 +372,9 @@ static void cortex_a8_initfn(Object *obj)SET_IDREG (isar,ID_ISAR4 ,0x00111142 ); cpu->isar.dbgdidr =0x15141000 ;SET_IDREG (isar,CLIDR , (1 <<27 ) | (2 <<24 ) |3 ); - cpu->ccsidr[0 ] =0xe007e01a ;/* 16k L1 dcache. */ - cpu->ccsidr[1 ] =0x2007e01a ;/* 16k L1 icache. */ - cpu->ccsidr[2 ] =0xf0000000 ;/* No L2 icache. */ +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,0xe007e01a );/* 16k L1 dcache. */ +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,0x2007e01a );/* 16k L1 icache. */ +SET_IDREG_DEMUX (isar,CCSIDR ,2 ,0xf0000000 );/* No L2 icache. */ cpu->reset_auxcr =2 ; cpu->isar.reset_pmcr_el0 =0x41002000 ;define_arm_cp_regs (cpu, cortexa8_cp_reginfo);
@@ -448,8 +448,8 @@ static void cortex_a9_initfn(Object *obj)SET_IDREG (isar,ID_ISAR4 ,0x00111142 ); cpu->isar.dbgdidr =0x35141000 ;SET_IDREG (isar,CLIDR , (1 <<27 ) | (1 <<24 ) |3 ); - cpu->ccsidr[0 ] =0xe00fe019 ;/* 16k L1 dcache. */ - cpu->ccsidr[1 ] =0x200fe019 ;/* 16k L1 icache. */ +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,0xe00fe019 );/* 16k L1 dcache. */ +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,0x200fe019 );/* 16k L1 icache. */ cpu->isar.reset_pmcr_el0 =0x41093000 ;define_arm_cp_regs (cpu, cortexa9_cp_reginfo); }
@@ -520,9 +520,9 @@ static void cortex_a7_initfn(Object *obj) cpu->isar.dbgdevid =0x01110f13 ; cpu->isar.dbgdevid1 =0x1 ;SET_IDREG (isar,CLIDR ,0x0a200023 ); - cpu->ccsidr[0 ] =0x701fe00a ;/* 32K L1 dcache */ - cpu->ccsidr[1 ] =0x201fe00a ;/* 32K L1 icache */ - cpu->ccsidr[2 ] =0x711fe07a ;/* 4096K L2 unified cache */ +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,0x701fe00a );/* 32K L1 dcache */ +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,0x201fe00a );/* 32K L1 icache */ +SET_IDREG_DEMUX (isar,CCSIDR ,2 ,0x711fe07a );/* 4096K L2 unified cache */ cpu->isar.reset_pmcr_el0 =0x41072000 ;define_arm_cp_regs (cpu, cortexa15_cp_reginfo);/* Same as A15 */ }
@@ -568,9 +568,9 @@ static void cortex_a15_initfn(Object *obj) cpu->isar.dbgdevid =0x01110f13 ; cpu->isar.dbgdevid1 =0x0 ;SET_IDREG (isar,CLIDR ,0x0a200023 ); - cpu->ccsidr[0 ] =0x701fe00a ;/* 32K L1 dcache */ - cpu->ccsidr[1 ] =0x201fe00a ;/* 32K L1 icache */ - cpu->ccsidr[2 ] =0x711fe07a ;/* 4096K L2 unified cache */ +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,0x701fe00a );/* 32K L1 dcache */ +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,0x201fe00a );/* 32K L1 icache */ +SET_IDREG_DEMUX (isar,CCSIDR ,2 ,0x711fe07a );/* 4096K L2 unified cache */ cpu->isar.reset_pmcr_el0 =0x410F3000 ;define_arm_cp_regs (cpu, cortexa15_cp_reginfo); }
@@ -759,8 +759,8 @@ static void cortex_r52_initfn(Object *obj)SET_IDREG (isar,ID_ISAR5 ,0x00010001 ); cpu->isar.dbgdidr =0x77168000 ;SET_IDREG (isar,CLIDR , (1 <<27 ) | (1 <<24 ) |0x3 ); - cpu->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe00a ;/* 32KB L1 icache */ +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,0x700fe01a );/* 32KB L1 dcache */ +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,0x201fe00a );/* 32KB L1 icache */ cpu->pmsav7_dregion =16 ; cpu->pmsav8r_hdregion =16 ;
@@ -853,9 +853,9 @@ static void arm_max_initfn(Object *obj)SET_IDREG (isar,ID_ISAR6 ,0 ); cpu->isar.reset_pmcr_el0 =0x41013000 ;SET_IDREG (isar,CLIDR ,0x0a200023 ); - cpu->ccsidr[0 ] =0x701fe00a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe012 ;/* 48KB L1 icache */ - cpu->ccsidr[2 ] =0x70ffe07a ;/* 2048KB L2 cache */ +SET_IDREG_DEMUX (isar,CCSIDR ,0 ,0x701fe00a );/* 32KB L1 dcache */ +SET_IDREG_DEMUX (isar,CCSIDR ,1 ,0x201fe012 );/* 48KB L1 icache */ +SET_IDREG_DEMUX (isar,CCSIDR ,2 ,0x70ffe07a );/* 2048KB L2 cache */ define_cortex_a72_a57_a53_cp_reginfo (cpu);aa32_max_features (cpu);
target/arm/tcg/cpu64.c +30 -30
140 lines not on this page · raw message
Signature · 1 line
2.52.0
RFC PATCH 3/3 arm/kvm: get demuxed ID registers from kvm
In reply to Cornelia HuckWe now have the infrastructure in place to get and save demuxed ID registers from kvm. Use it to get the values that kvm emulates for CCSIDR_EL1.
--- target/arm/kvm.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
target/arm/kvm.c +33 -0
@@ -243,6 +243,33 @@ static int get_host_cpu_reg(int fd, ARMHostCPUFeatures *ahcf,return ret; } +static int get_host_cpu_reg_demux (int fd,ARMHostCPUFeatures *ahcf, +ARMIDRegisterIdx index,int subindex) +{ + +struct kvm_one_reg one_reg = { + .id =KVM_REG_ARM64 |KVM_REG_SIZE_U32 |KVM_REG_ARM_DEMUX , + }; +ARMIDRegisterDemuxIdx demux_index; + +switch (index) { +case CCSIDR_EL1_IDX : +if (subindex <14 ) { + one_reg.id |=KVM_REG_ARM_DEMUX_ID_CCSIDR | subindex; + }else { +return -EINVAL ; + } + demux_index =CCSIDR_EL1_DEMUX_IDX ; +break ; +default : +return -EINVAL ; + } + one_reg.addr = (uintptr_t )&ahcf->isar.idregs_demux[demux_index][subindex]; + +return ioctl (fd,KVM_GET_ONE_REG , &one_reg); + +} +static bool kvm_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf) {/* Identify the feature bits corresponding to the host CPU, and
@@ -256,6 +283,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)bool pmu_supported = false;uint64_t features =0 ;int err; +int i;/* * target = -1 informs kvm_arm_create_scratch_host_vcpu()
@@ -416,6 +444,11 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)*/ err |=get_host_cpu_reg (fd, ahcf,ID_AA64ZFR0_EL1_IDX ); } +/* grab demuxed registers */ +for (i =0 ; i <14 ; i++) { +/* KVM only allows 0..13 */ + err |=get_host_cpu_reg_demux (fd, ahcf,CCSIDR_EL1_IDX , i); + } }kvm_arm_destroy_scratch_host_vcpu (fdarray);
Signature · 1 line
2.52.0
On Mon, 19 Jan 2026 18:27:29 +0100
Cornelia Huck <[email protected]> wrote:
Hi Cornelia,
Quoted 33 lines
Note: this is on top of <[email protected]> ("[PATCH v3 0/2] arm: move
DCZID_EL0to idregs array")While trying to move to an autogenerated cpu-sysregs.h.inc (so that we may keep a common view on registers), we should first address the ID registers that are still kept outside of ARMISARegisters. Other than
DCZID_EL0(addressed by the series this one goes on top of), that's theCCSIDR_EL1values kept in cpu->cssidr[] (indexed viaCSSELR_EL1.)My idea was to provide {GET,SET}_IDREG_DEMUX helper that work similar to {GET,SET}_IDREG and operate on a two-dimensional array. As a side effect, this also allows to get the values KVM provides for
CCSIDR_EL1(which are virtualized as well.)RFC because there are still some open questions:
- The demux array cannot easily be autogenerated. We can get rid of the ccsidr[] array, but we now have an autogenerated entry in the non-demux array that does nothing. Both are not that nice.
- I'm not sure if we need any compat handling for KVM (on TCG, everything should stay the same.) In theory, the KVM interface allows setting values from userspace (I didn't try.)
- There's a slight disagreement between the current code (providing 16 entries forCCSIDR_EL1) and the KVM code (providing (7 cache levels) * (data/unified, instruction) = 14 entries.) WithFEAT_MTE2, we might be needing 7 more entries.Feedback appreciated.
Cornelia Huck (3):
arm: handle demuxed ID registers
arm: handleCCSIDR_EL1as a demuxed register
arm/kvm: get demuxed ID registers from kvm
Quoted 11 lines
hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu-sysregs.h | 6 ++++ target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.h | 26 ++++++++++++---- target/arm/cpu64.c | 12 ++++---- target/arm/helper.c | 2 +- target/arm/kvm.c | 33 ++++++++++++++++++++ target/arm/tcg/cpu32.c | 32 +++++++++---------- target/arm/tcg/cpu64.c | 60 ++++++++++++++++++------------------ 9 files changed, 114 insertions(+), 60 deletions(-)
This impacts my set https://lore.kernel.org/all/[email protected]/
I tested it with mine of course it required a few changes, but looks like working on TCG, didn't try KVM.
Quoted 52 lines · Alireza Sanaee
On Mon, 19 Jan 2026 18:27:29 +0100
Cornelia Huck <[email protected]> wrote:Hi Cornelia,
Quoted 33 lines
Note: this is on top of <[email protected]> ("[PATCH v3 0/2] arm: move
DCZID_EL0to idregs array")While trying to move to an autogenerated cpu-sysregs.h.inc (so that we may keep a common view on registers), we should first address the ID registers that are still kept outside of ARMISARegisters. Other than
DCZID_EL0(addressed by the series this one goes on top of), that's theCCSIDR_EL1values kept in cpu->cssidr[] (indexed viaCSSELR_EL1.)My idea was to provide {GET,SET}_IDREG_DEMUX helper that work similar to {GET,SET}_IDREG and operate on a two-dimensional array. As a side effect, this also allows to get the values KVM provides for
CCSIDR_EL1(which are virtualized as well.)RFC because there are still some open questions:
- The demux array cannot easily be autogenerated. We can get rid of the ccsidr[] array, but we now have an autogenerated entry in the non-demux array that does nothing. Both are not that nice.
- I'm not sure if we need any compat handling for KVM (on TCG, everything should stay the same.) In theory, the KVM interface allows setting values from userspace (I didn't try.)
- There's a slight disagreement between the current code (providing 16 entries forCCSIDR_EL1) and the KVM code (providing (7 cache levels) * (data/unified, instruction) = 14 entries.) WithFEAT_MTE2, we might be needing 7 more entries.Feedback appreciated.
Cornelia Huck (3):
arm: handle demuxed ID registers
arm: handleCCSIDR_EL1as a demuxed register
arm/kvm: get demuxed ID registers from kvmQuoted 11 lines
hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu-sysregs.h | 6 ++++ target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.h | 26 ++++++++++++---- target/arm/cpu64.c | 12 ++++---- target/arm/helper.c | 2 +- target/arm/kvm.c | 33 ++++++++++++++++++++ target/arm/tcg/cpu32.c | 32 +++++++++---------- target/arm/tcg/cpu64.c | 60 ++++++++++++++++++------------------ 9 files changed, 114 insertions(+), 60 deletions(-)
Quoted 1 line
This impacts my set https://lore.kernel.org/all/[email protected]/
Duh, that series had actually been sitting in my "to look at" queue...
Quoted 4 lines
I tested it with mine of course it required a few changes, but looks like working on TCG, didn't try KVM.
Tested-by Alireza Sanaee <[email protected]>
Thanks for testing! I'll also try to take a look at your series.
Quoted 56 lines · On Wed, 21 Jan 2026 17:28:07 +0100 Cornelia Huck <[email protected]> wrote:
Quoted 52 lines · Alireza Sanaee
On Mon, 19 Jan 2026 18:27:29 +0100
Cornelia Huck <[email protected]> wrote:Hi Cornelia,
Quoted 33 lines
Note: this is on top of <[email protected]> ("[PATCH v3 0/2] arm: move
DCZID_EL0to idregs array")While trying to move to an autogenerated cpu-sysregs.h.inc (so that we may keep a common view on registers), we should first address the ID registers that are still kept outside of ARMISARegisters. Other than
DCZID_EL0(addressed by the series this one goes on top of), that's theCCSIDR_EL1values kept in cpu->cssidr[] (indexed viaCSSELR_EL1.)My idea was to provide {GET,SET}_IDREG_DEMUX helper that work similar to {GET,SET}_IDREG and operate on a two-dimensional array. As a side effect, this also allows to get the values KVM provides for
CCSIDR_EL1(which are virtualized as well.)RFC because there are still some open questions:
- The demux array cannot easily be autogenerated. We can get rid of the ccsidr[] array, but we now have an autogenerated entry in the non-demux array that does nothing. Both are not that nice.
- I'm not sure if we need any compat handling for KVM (on TCG, everything should stay the same.) In theory, the KVM interface allows setting values from userspace (I didn't try.)
- There's a slight disagreement between the current code (providing 16 entries forCCSIDR_EL1) and the KVM code (providing (7 cache levels) * (data/unified, instruction) = 14 entries.) WithFEAT_MTE2, we might be needing 7 more entries.Feedback appreciated.
Cornelia Huck (3):
arm: handle demuxed ID registers
arm: handleCCSIDR_EL1as a demuxed register
arm/kvm: get demuxed ID registers from kvmQuoted 11 lines
hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu-sysregs.h | 6 ++++ target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.h | 26 ++++++++++++---- target/arm/cpu64.c | 12 ++++---- target/arm/helper.c | 2 +- target/arm/kvm.c | 33 ++++++++++++++++++++ target/arm/tcg/cpu32.c | 32 +++++++++---------- target/arm/tcg/cpu64.c | 60 ++++++++++++++++++------------------ 9 files changed, 114 insertions(+), 60 deletions(-)Quoted 1 line
This impacts my set https://lore.kernel.org/all/[email protected]/
Quoted 10 lines
Duh, that series had actually been sitting in my "to look at" queue...
Quoted 4 lines
I tested it with mine of course it required a few changes, but looks like working on TCG, didn't try KVM.
Tested-by Alireza Sanaee <[email protected]>Thanks for testing! I'll also try to take a look at your series.
Thanks Cornelia, that patch has been sitting there forever literally :)
Quoted 14 lines · Cornelia Huck
Note: this is on top of <[email protected]> ("[PATCH v3 0/2] arm: move
DCZID_EL0to idregs array")While trying to move to an autogenerated cpu-sysregs.h.inc (so that we may keep a common view on registers), we should first address the ID registers that are still kept outside of ARMISARegisters. Other than
DCZID_EL0(addressed by the series this one goes on top of), that's theCCSIDR_EL1values kept in cpu->cssidr[] (indexed viaCSSELR_EL1.)My idea was to provide {GET,SET}_IDREG_DEMUX helper that work similar to {GET,SET}_IDREG and operate on a two-dimensional array. As a side effect, this also allows to get the values KVM provides for
CCSIDR_EL1(which are virtualized as well.)
Quoted 12 lines
RFC because there are still some open questions:
- The demux array cannot easily be autogenerated. We can get rid of the ccsidr[] array, but we now have an autogenerated entry in the non-demux array that does nothing. Both are not that nice.
- I'm not sure if we need any compat handling for KVM (on TCG, everything should stay the same.) In theory, the KVM interface allows setting values from userspace (I didn't try.)
- There's a slight disagreement between the current code (providing 16 entries forCCSIDR_EL1) and the KVM code (providing (7 cache levels) * (data/unified, instruction) = 14 entries.) WithFEAT_MTE2, we might be needing 7 more entries.
LGTM!
Thanks,
Sebastian