arm: add DCZID_EL0 to idregs array
PATCH 1/1 arm: add DCZID_EL0 to idregs array
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access dcz_blocksize via a wrapper working on DCZID_EL.BS.
KVM currently does not support DCZID_EL0 via ONE_REG, and actually does not need to work with it, so provide a dummy value for now.
---
This is another followup on the ID register rework. The last missing set of registers are CCSIDR* and friends, then we should be able to switch to autogenerated registers (probably with a different script than the last attempt.)
--- target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.c | 2 +- target/arm/cpu.h | 15 +++++++++++++-- target/arm/cpu64.c | 4 ++-- target/arm/helper.c | 3 ++- target/arm/kvm.c | 7 +++++++ target/arm/tcg/cpu64.c | 22 +++++++++++----------- target/arm/tcg/helper-a64.c | 2 +- target/arm/tcg/mte_helper.c | 4 ++-- target/arm/tcg/translate-a64.c | 2 +- 10 files changed, 41 insertions(+), 21 deletions(-)
target/arm/cpu-sysregs.h.inc +1 -0
@@ -39,3 +39,4 @@ DEF(ID_MMFR5_EL1, 3, 0, 0, 3, 6) 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) +DEF(DCZID_EL0, 3, 3, 0, 0, 7)
target/arm/cpu.c +1 -1
@@ -2184,7 +2184,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)#endif if (tcg_enabled ()) { -int dcz_blocklen =4 << cpu->dcz_blocksize; +int dcz_blocklen =4 <<get_dcz_blocksize (cpu);/* * We only support DCZ blocklen that fits on one page.
target/arm/cpu.h +13 -2
@@ -1111,8 +1111,6 @@ struct ArchCPU {bool prop_pauth_qarma5;bool prop_lpa2; -/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ -uint8_t dcz_blocksize;/* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */ uint8_t gm_blocksize;
@@ -1178,6 +1176,19 @@ struct ARMCPUClass {ResettablePhases parent_phases; }; +static inline uint8_t get_dcz_blocksize (ARMCPU *cpu) +{ +return cpu->isar.idregs[DCZID_EL0_IDX ] &0xf ; +} + +static inline void set_dcz_blocksize (ARMCPU *cpu,uint8_t bs) +{ +uint64_t dczid = cpu->isar.idregs[DCZID_EL0_IDX ]; + +/* keep dzp unchanged */ + cpu->isar.idregs[DCZID_EL0_IDX ] = (dczid & ~0xf ) | bs; +} +/* Callback functions for the generic timer's timers. */ void arm_gt_ptimer_cb (void *opaque);void arm_gt_vtimer_cb (void *opaque);
target/arm/cpu64.c +2 -2
@@ -689,7 +689,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->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 ); - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;
@@ -751,7 +751,7 @@ static void aarch64_a53_initfn(Object *obj) cpu->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 ); - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;
target/arm/helper.c +2 -1
@@ -3324,7 +3324,8 @@ static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri)if (aa64_zva_access (env,NULL , false) ==CP_ACCESS_OK ) { dzp_bit =0 ; } -return cpu->dcz_blocksize | dzp_bit; + +return cpu->isar.idregs[DCZID_EL0_IDX ] | dzp_bit; } static CPAccessResult sp_el0_access(CPUARMState *env, const ARMCPRegInfo *ri,
target/arm/kvm.c +7 -0
@@ -2020,6 +2020,13 @@ int kvm_arch_init_vcpu(CPUState *cs) } cpu->mp_affinity = mpidr &ARM64_AFFINITY_MASK ; +/* +* We currently do not need this, except for tcg. Should KVM gain support +* for accessing DCZID_EL0 via ONE_REG, we'll overwrite this below. Just +* set a dummy value that corresponds to the minimum value for FEAT_MTE2. +*/ +set_dcz_blocksize (cpu,2 ); +return kvm_arm_init_cpreg_list (cpu); }
target/arm/tcg/cpu64.c +11 -11
@@ -72,7 +72,7 @@ static void aarch64_a35_initfn(Object *obj)SET_IDREG (isar,ID_AA64MMFR0 ,0x00101122 );SET_IDREG (isar,ID_AA64MMFR1 ,0 );SET_IDREG (isar,CLIDR ,0x0a200023 ); - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );/* From B2.4 AArch64 Virtual Memory control registers */ cpu->reset_sctlr =0x00c50838 ;
@@ -219,7 +219,7 @@ static void aarch64_a55_initfn(Object *obj)/* Ordered by B2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x84448004 ;/* L1Ip = VIPT */ - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );
@@ -325,7 +325,7 @@ static void aarch64_a72_initfn(Object *obj) cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,3 ,64 ,48 * KiB,2 );/* 1MB L2 cache */ cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,64 ,1 * MiB,7 ); - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;
@@ -352,7 +352,7 @@ static void aarch64_a76_initfn(Object *obj)/* Ordered by B2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x8444C004 ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );
@@ -424,7 +424,7 @@ static void aarch64_a78ae_initfn(Object *obj)/* Ordered by 3.2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x9444c004 ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64DFR0 ,0x0000000110305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0010100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000001200031ull );
@@ -517,7 +517,7 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,256 ,64 * KiB,2 );/* 8MB L2 cache */ cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,256 ,8 * MiB,7 ); - cpu->dcz_blocksize =6 ;/* 256 bytes */ +set_dcz_blocksize (cpu,6 );/* 256 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;
@@ -673,7 +673,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj)/* Ordered by B2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x8444c004 ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64DFR0 ,0x0000000110305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );
@@ -749,7 +749,7 @@ static void aarch64_neoverse_v1_initfn(Object *obj)/* Ordered by 3.2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0xb444c004 ;/* With DIC and IDC set */ - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64AFR0 ,0x00000000 );SET_IDREG (isar,ID_AA64AFR1 ,0x00000000 );SET_IDREG (isar,ID_AA64DFR0 ,0x000001f210305519ull );
@@ -1011,7 +1011,7 @@ static void aarch64_a710_initfn(Object *obj)SET_IDREG (isar,CLIDR ,0x0000001482000023ull ); cpu->gm_blocksize =4 ; cpu->ctr =0x000000049444c004ull ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );/* TODO FEAT_MPAM: mpamidr_el1 = 0x0000_0001_0006_003f */ /* Section B.5.2: PMCR_EL0 */
@@ -1113,7 +1113,7 @@ static void aarch64_neoverse_n2_initfn(Object *obj)SET_IDREG (isar,CLIDR ,0x0000001482000023ull ); cpu->gm_blocksize =4 ; cpu->ctr =0x00000004b444c004ull ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );/* TODO FEAT_MPAM: mpamidr_el1 = 0x0000_0001_001e_01ff */ /* Section B.7.2: PMCR_EL0 */
@@ -1377,7 +1377,7 @@ void aarch64_max_tcg_initfn(Object *obj)* blocksize since we don't have to follow what the hardware does. */ cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */ - cpu->dcz_blocksize =7 ;/* 512 bytes */ +set_dcz_blocksize (cpu,7 );/* 512 bytes */ #endif cpu->gm_blocksize =6 ;/* 256 bytes */
target/arm/tcg/helper-a64.c +1 -1
@@ -792,7 +792,7 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)* (which matches the usual QEMU behaviour of not implementing either * alignment faults or any memory attribute handling). */ -int blocklen =4 <<env_archcpu (env)->dcz_blocksize; +int blocklen =4 <<get_dcz_blocksize (env_archcpu (env));uint64_t vaddr = vaddr_in & ~(blocklen -1 );int mmu_idx =arm_env_mmu_index (env);void *mem;
target/arm/tcg/mte_helper.c +2 -2
@@ -545,7 +545,7 @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val)* i.e. 32 bytes, which is an unreasonably small dcz anyway, * to make sure that we can access one complete tag byte here. */ - log2_dcz_bytes =env_archcpu (env)->dcz_blocksize +2 ; + log2_dcz_bytes =get_dcz_blocksize (env_archcpu (env)) +2 ; log2_tag_bytes = log2_dcz_bytes - (LOG2_TAG_GRANULE +1 ); dcz_bytes = (intptr_t )1 << log2_dcz_bytes; tag_bytes = (intptr_t )1 << log2_tag_bytes;
@@ -945,7 +945,7 @@ uint64_t HELPER(mte_check_zva)(CPUARMState *env, uint32_t desc, uint64_t ptr)* i.e. 32 bytes, which is an unreasonably small dcz anyway, to make * sure that we can access one complete tag byte here. */ - log2_dcz_bytes =env_archcpu (env)->dcz_blocksize +2 ; + log2_dcz_bytes =get_dcz_blocksize (env_archcpu (env)) +2 ; log2_tag_bytes = log2_dcz_bytes - (LOG2_TAG_GRANULE +1 ); dcz_bytes = (intptr_t )1 << log2_dcz_bytes; tag_bytes = (intptr_t )1 << log2_tag_bytes;
target/arm/tcg/translate-a64.c +1 -1
@@ -10712,7 +10712,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->vec_stride =0 ; dc->cp_regs = arm_cpu->cp_regs; dc->features = env->features; - dc->dcz_blocksize = arm_cpu->dcz_blocksize; + dc->dcz_blocksize =get_dcz_blocksize (arm_cpu); dc->gm_blocksize = arm_cpu->gm_blocksize;#ifdef CONFIG_USER_ONLY
Signature · 1 line
2.51.1
Hi Connie,
Quoted 2 lines · Cornelia Huck
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access
dcz_blocksize
what do you mean by EL specific part?
you may simply say that at the moment only bs field is handled as part of cpu.dcz_blocklen
so you replace all the users of that field by accessors to the isar.idreg[] storage
Quoted 62 lines
via a wrapper working on DCZID_EL.BS.
KVM currently does not support
DCZID_EL0viaONE_REG, and actually does not need to work with it, so provide a dummy value for now.Signed-off-by Cornelia Huck <[email protected]>---
This is another followup on the ID register rework. The last missing set of registers are CCSIDR* and friends, then we should be able to switch to autogenerated registers (probably with a different script than the last attempt.)
--- target/arm/cpu-sysregs.h.inc | 1 + target/arm/cpu.c | 2 +- target/arm/cpu.h | 15 +++++++++++++-- target/arm/cpu64.c | 4 ++-- target/arm/helper.c | 3 ++- target/arm/kvm.c | 7 +++++++ target/arm/tcg/cpu64.c | 22 +++++++++++----------- target/arm/tcg/helper-a64.c | 2 +- target/arm/tcg/mte_helper.c | 4 ++-- target/arm/tcg/translate-a64.c | 2 +- 10 files changed, 41 insertions(+), 21 deletions(-)target/arm/cpu-sysregs.h.inc +1
-0@@ -39,3 +39,4 @@ DEF(ID_MMFR5_EL1, 3, 0, 0, 3, 6) 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) +DEF(DCZID_EL0, 3, 3, 0, 0, 7)target/arm/cpu.c +1
-1@@ -2184,7 +2184,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)#endif if (tcg_enabled ()) { -int dcz_blocklen =4 << cpu->dcz_blocksize; +int dcz_blocklen =4 <<get_dcz_blocksize (cpu);/* * We only support DCZ blocklen that fits on one page. target/arm/cpu.h +0
-2@@ -1111,8 +1111,6 @@ struct ArchCPU {bool prop_pauth_qarma5;bool prop_lpa2; -/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ -uint8_t dcz_blocksize;/* GM blocksize, in log_2(words), ie low 4 bits of GMID_EL0 */ uint8_t gm_blocksize;
target/arm/cpu.h struct ARMCPUClass { · line 1179
Quoted 4 lines
target/arm/cpu.h +1
-0@@ -1178,6 +1176,19 @@ struct ARMCPUClass {ResettablePhases parent_phases; }; +static inline uint8_t get_dcz_blocksize (ARMCPU *cpu)
While at it I would replace dcz_blocksize by dczid_el0_bs to be more explicit
target/arm/cpu.h struct ARMCPUClass { · line 1181
Quoted 2 lines
target/arm/cpu.h +2
-0+{ +return cpu->isar.idregs[DCZID_EL0_IDX ] &0xf ;
extract64?
target/arm/cpu.h struct ARMCPUClass { · line 1189
Quoted 8 lines
target/arm/cpu.h +8
-0+} + +static inline void set_dcz_blocksize (ARMCPU *cpu,uint8_t bs) +{ +uint64_t dczid = cpu->isar.idregs[DCZID_EL0_IDX ]; + +/* keep dzp unchanged */ + cpu->isar.idregs[DCZID_EL0_IDX ] = (dczid & ~0xf ) | bs;
deposit64?
target/arm/helper.c static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri)
Quoted 32 lines
target/arm/cpu.h +2
-0+} +/* Callback functions for the generic timer's timers. */ void arm_gt_ptimer_cb (void *opaque);void arm_gt_vtimer_cb (void *opaque);target/arm/cpu64.c +2
-2@@ -689,7 +689,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->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 ); - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;@@ -751,7 +751,7 @@ static void aarch64_a53_initfn(Object *obj) cpu->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 ); - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;target/arm/helper.c +0
-0@@ -3324,7 +3324,8 @@ static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri)
the name of the function seems to indicate you read the whole DCZID but I see the DZP bit is tweaked below. Do you get why we can't return the raw id reg?
target/arm/helper.c static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri) · line 3327
Quoted 5 lines
target/arm/helper.c +1
-1if (aa64_zva_access (env,NULL , false) ==CP_ACCESS_OK ) { dzp_bit =0 ; } -return cpu->dcz_blocksize | dzp_bit; +
nit spurious NL
Quoted 9 lines
target/arm/helper.c +1
-0+return cpu->isar.idregs[DCZID_EL0_IDX ] | dzp_bit; } static CPAccessResult sp_el0_access(CPUARMState *env, const ARMCPRegInfo *ri,target/arm/kvm.c +0
-0
target/arm/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 2028
Quoted 9 lines
target/arm/kvm.c +6
-0@@ -2020,6 +2020,13 @@ int kvm_arch_init_vcpu(CPUState *cs) } cpu->mp_affinity = mpidr &ARM64_AFFINITY_MASK ; +/* +* We currently do not need this, except for tcg. Should KVM gain support +* for accessing DCZID_EL0 via ONE_REG, we'll overwrite this below. Just +* set a dummy value that corresponds to the minimum value for FEAT_MTE2. +*/ +set_dcz_blocksize (cpu,2 );
it is not clear to me why we need that?
Quoted 147 lines
target/arm/kvm.c +1
-0+return kvm_arm_init_cpreg_list (cpu); }target/arm/tcg/cpu64.c +11
-11@@ -72,7 +72,7 @@ static void aarch64_a35_initfn(Object *obj)SET_IDREG (isar,ID_AA64MMFR0 ,0x00101122 );SET_IDREG (isar,ID_AA64MMFR1 ,0 );SET_IDREG (isar,CLIDR ,0x0a200023 ); - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );/* From B2.4 AArch64 Virtual Memory control registers */ cpu->reset_sctlr =0x00c50838 ;@@ -219,7 +219,7 @@ static void aarch64_a55_initfn(Object *obj)/* Ordered by B2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x84448004 ;/* L1Ip = VIPT */ - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );@@ -325,7 +325,7 @@ static void aarch64_a72_initfn(Object *obj) cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,3 ,64 ,48 * KiB,2 );/* 1MB L2 cache */ cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,64 ,1 * MiB,7 ); - cpu->dcz_blocksize =4 ;/* 64 bytes */ +set_dcz_blocksize (cpu,4 );/* 64 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;@@ -352,7 +352,7 @@ static void aarch64_a76_initfn(Object *obj)/* Ordered by B2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x8444C004 ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64DFR0 ,0x0000000010305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );@@ -424,7 +424,7 @@ static void aarch64_a78ae_initfn(Object *obj)/* Ordered by 3.2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x9444c004 ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64DFR0 ,0x0000000110305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0010100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000001200031ull );@@ -517,7 +517,7 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->ccsidr[1 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,4 ,256 ,64 * KiB,2 );/* 8MB L2 cache */ cpu->ccsidr[2 ] =make_ccsidr (CCSIDR_FORMAT_LEGACY ,16 ,256 ,8 * MiB,7 ); - cpu->dcz_blocksize =6 ;/* 256 bytes */ +set_dcz_blocksize (cpu,6 );/* 256 bytes */ cpu->gic_num_lrs =4 ; cpu->gic_vpribits =5 ; cpu->gic_vprebits =5 ;@@ -673,7 +673,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj)/* Ordered by B2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0x8444c004 ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64DFR0 ,0x0000000110305408ull );SET_IDREG (isar,ID_AA64ISAR0 ,0x0000100010211120ull );SET_IDREG (isar,ID_AA64ISAR1 ,0x0000000000100001ull );@@ -749,7 +749,7 @@ static void aarch64_neoverse_v1_initfn(Object *obj)/* Ordered by 3.2.4 AArch64 registers by functional group */ SET_IDREG (isar,CLIDR ,0x82000023 ); cpu->ctr =0xb444c004 ;/* With DIC and IDC set */ - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );SET_IDREG (isar,ID_AA64AFR0 ,0x00000000 );SET_IDREG (isar,ID_AA64AFR1 ,0x00000000 );SET_IDREG (isar,ID_AA64DFR0 ,0x000001f210305519ull );@@ -1011,7 +1011,7 @@ static void aarch64_a710_initfn(Object *obj)SET_IDREG (isar,CLIDR ,0x0000001482000023ull ); cpu->gm_blocksize =4 ; cpu->ctr =0x000000049444c004ull ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );/* TODO FEAT_MPAM: mpamidr_el1 = 0x0000_0001_0006_003f */ /* Section B.5.2: PMCR_EL0 */ @@ -1113,7 +1113,7 @@ static void aarch64_neoverse_n2_initfn(Object *obj)SET_IDREG (isar,CLIDR ,0x0000001482000023ull ); cpu->gm_blocksize =4 ; cpu->ctr =0x00000004b444c004ull ; - cpu->dcz_blocksize =4 ; +set_dcz_blocksize (cpu,4 );/* TODO FEAT_MPAM: mpamidr_el1 = 0x0000_0001_001e_01ff */ /* Section B.7.2: PMCR_EL0 */ @@ -1377,7 +1377,7 @@ void aarch64_max_tcg_initfn(Object *obj)* blocksize since we don't have to follow what the hardware does. */ cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */ - cpu->dcz_blocksize =7 ;/* 512 bytes */ +set_dcz_blocksize (cpu,7 );/* 512 bytes */ #endif cpu->gm_blocksize =6 ;/* 256 bytes */ target/arm/tcg/helper-a64.c +1
-1@@ -792,7 +792,7 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)* (which matches the usual QEMU behaviour of not implementing either * alignment faults or any memory attribute handling). */ -int blocklen =4 <<env_archcpu (env)->dcz_blocksize; +int blocklen =4 <<get_dcz_blocksize (env_archcpu (env));uint64_t vaddr = vaddr_in & ~(blocklen -1 );int mmu_idx =arm_env_mmu_index (env);void *mem;target/arm/tcg/mte_helper.c +2
-2@@ -545,7 +545,7 @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val)* i.e. 32 bytes, which is an unreasonably small dcz anyway, * to make sure that we can access one complete tag byte here. */ - log2_dcz_bytes =env_archcpu (env)->dcz_blocksize +2 ; + log2_dcz_bytes =get_dcz_blocksize (env_archcpu (env)) +2 ; log2_tag_bytes = log2_dcz_bytes - (LOG2_TAG_GRANULE +1 ); dcz_bytes = (intptr_t )1 << log2_dcz_bytes; tag_bytes = (intptr_t )1 << log2_tag_bytes;@@ -945,7 +945,7 @@ uint64_t HELPER(mte_check_zva)(CPUARMState *env, uint32_t desc, uint64_t ptr)* i.e. 32 bytes, which is an unreasonably small dcz anyway, to make * sure that we can access one complete tag byte here. */ - log2_dcz_bytes =env_archcpu (env)->dcz_blocksize +2 ; + log2_dcz_bytes =get_dcz_blocksize (env_archcpu (env)) +2 ; log2_tag_bytes = log2_dcz_bytes - (LOG2_TAG_GRANULE +1 ); dcz_bytes = (intptr_t )1 << log2_dcz_bytes; tag_bytes = (intptr_t )1 << log2_tag_bytes;target/arm/tcg/translate-a64.c +0
-0
target/arm/tcg/translate-a64.c static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, · line 10718
Quoted 8 lines
target/arm/tcg/translate-a64.c +1
-1@@ -10712,7 +10712,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->vec_stride =0 ; dc->cp_regs = arm_cpu->cp_regs; dc->features = env->features; - dc->dcz_blocksize = arm_cpu->dcz_blocksize; + dc->dcz_blocksize =get_dcz_blocksize (arm_cpu); dc->gm_blocksize = arm_cpu->gm_blocksize;#ifdef CONFIG_USER_ONLY
Thanks
Eric
Quoted 6 lines · Eric Auger
Hi Connie,
Quoted 2 lines · Cornelia Huck
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access
dcz_blocksizewhat do you mean by EL specific part?
DZP is depending on the current EL (see DC ZVA; it might trap for EL0/EL1.)
Quoted 5 lines
you may simply say that at the moment only bs field is handled as part of cpu.dcz_blocklen
so you replace all the users of that field by accessors to the isar.idreg[] storage
Hm, I'm not sure I understand this sentence -- what I wanted to say is that we care about DCZID_EL0.BS and moving DCZID_EL0 to idregs is made easier by a simple wrapper for that.
Quoted 6 lines
Quoted 6 lines
via a wrapper working on DCZID_EL.BS.
KVM currently does not support
DCZID_EL0viaONE_REG, and actually does not need to work with it, so provide a dummy value for now.Signed-off-by Cornelia Huck <[email protected]>
(...)
Quoted 7 lines
target/arm/cpu.h struct ARMCPUClass { · line 1179
Quoted 5 lines
target/arm/cpu.h +1
-0@@ -1178,6 +1176,19 @@ struct ARMCPUClass {ResettablePhases parent_phases; }; +static inline uint8_t get_dcz_blocksize (ARMCPU *cpu)While at it I would replace
dcz_blocksizebydczid_el0_bsto be more explicit
Can do; I wanted to make the diff more straightforward to use.
Quoted 12 lines
target/arm/cpu.h struct ARMCPUClass { · line 1181
Quoted 2 lines
target/arm/cpu.h +2
-0+{ +return cpu->isar.idregs[DCZID_EL0_IDX ] &0xf ;extract64?
target/arm/cpu.h struct ARMCPUClass { · line 1189
Quoted 8 lines
target/arm/cpu.h +8
-0+} + +static inline void set_dcz_blocksize (ARMCPU *cpu,uint8_t bs) +{ +uint64_t dczid = cpu->isar.idregs[DCZID_EL0_IDX ]; + +/* keep dzp unchanged */ + cpu->isar.idregs[DCZID_EL0_IDX ] = (dczid & ~0xf ) | bs;deposit64?
Can change.
Quoted 5 lines
Quoted 5 lines
target/arm/cpu.h +2
-0+} +/* Callback functions for the generic timer's timers. */ void arm_gt_ptimer_cb (void *opaque);void arm_gt_vtimer_cb (void *opaque);
(...)
Quoted 8 lines
target/arm/helper.c static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri)
Quoted 5 lines
target/arm/helper.c +0
-0@@ -3324,7 +3324,8 @@ static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri)the name of the function seems to indicate you read the whole DCZID but I see the DZP bit is tweaked below. Do you get why we can't return the raw id reg?
See above -- the value of DZP depends on the current EL (and some other bits, which don't change.)
Quoted 6 lines
target/arm/helper.c static uint64_t aa64_dczid_read(CPUARMState *env, const ARMCPRegInfo *ri) · line 3327
Quoted 5 lines
target/arm/helper.c +1
-1if (aa64_zva_access (env,NULL , false) ==CP_ACCESS_OK ) { dzp_bit =0 ; } -return cpu->dcz_blocksize | dzp_bit; +nit spurious NL
ok
Quoted 12 lines
Quoted 12 lines
target/arm/helper.c +1
-0+return cpu->isar.idregs[DCZID_EL0_IDX ] | dzp_bit; } static CPAccessResult sp_el0_access(CPUARMState *env, const ARMCPRegInfo *ri,target/arm/kvm.c +0
-0@@ -2020,6 +2020,13 @@ int kvm_arch_init_vcpu(CPUState *cs) } cpu->mp_affinity = mpidr &ARM64_AFFINITY_MASK ;
Quoted 7 lines
target/arm/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 2028
Quoted 6 lines
target/arm/kvm.c +6
-0+/* +* We currently do not need this, except for tcg. Should KVM gain support +* for accessing DCZID_EL0 via ONE_REG, we'll overwrite this below. Just +* set a dummy value that corresponds to the minimum value for FEAT_MTE2. +*/ +set_dcz_blocksize (cpu,2 );it is not clear to me why we need that?
We currently don't use it for kvm, but I wanted to put something non-bogus there. Alternatively, we could moan if we try to access the reg under kvm.
Quoted 4 lines
Quoted 4 lines
target/arm/kvm.c +1
-0+return kvm_arm_init_cpreg_list (cpu); }
Quoted 7 lines · Cornelia Huck
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access
dcz_blocksizevia a wrapper working on DCZID_EL.BS.KVM currently does not support
DCZID_EL0viaONE_REG, and actually does not need to work with it, so provide a dummy value for now.
That seems like an odd (unintended?) omission -- is it worth adding? (We would need to handle older kernels that don't expose it anyway, of course.)
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Cornelia Huck
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access
dcz_blocksizevia a wrapper working on DCZID_EL.BS.
Quoted 6 lines
Quoted 2 lines
KVM currently does not support
DCZID_EL0viaONE_REG, and actually does not need to work with it, so provide a dummy value for now.That seems like an odd (unintended?) omission -- is it worth adding? (We would need to handle older kernels that don't expose it anyway, of course.)
I'm not sure whether there's actually a usecase for KVM exposing this to the VMM - AFAICS, KVM doesn't do anything special for DC ZVA and friends, and doesn't tweak HCR_EL2.TDZ which would change behaviour.
Quoted 12 lines · Cornelia Huck
Quoted 9 lines · Peter Maydell
Quoted 7 lines · Cornelia Huck
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access
dcz_blocksizevia a wrapper working on DCZID_EL.BS.KVM currently does not support
DCZID_EL0viaONE_REG, and actually does not need to work with it, so provide a dummy value for now.
Quoted 7 lines
Quoted 3 lines
That seems like an odd (unintended?) omission -- is it worth adding? (We would need to handle older kernels that don't expose it anyway, of course.)
I'm not sure whether there's actually a usecase for KVM exposing this to the VMM - AFAICS, KVM doesn't do anything special for DC ZVA and friends, and doesn't tweak HCR_EL2.TDZ which would change behaviour.
I guess the only one I can think of is to correctly fail migration from a source CPU with a DCZID_EL0.BS that doesn't match the one on the destination CPU. (We can't lie to the guest about the blocksize as part of "tell the guest it has a different CPU type from the actual host" unless we want to trap and emulate all the DC ZVA etc insns...)
thanks
-- PMM
Quoted 21 lines · Peter Maydell
Quoted 12 lines · Cornelia Huck
Quoted 9 lines · Peter Maydell
Quoted 7 lines · Cornelia Huck
This requires a bit of care, since we still have to handle the EL specific part (DCZID_EL0.DZP). Callers can set/access
dcz_blocksizevia a wrapper working on DCZID_EL.BS.KVM currently does not support
DCZID_EL0viaONE_REG, and actually does not need to work with it, so provide a dummy value for now.Quoted 7 lines
Quoted 3 lines
That seems like an odd (unintended?) omission -- is it worth adding? (We would need to handle older kernels that don't expose it anyway, of course.)
I'm not sure whether there's actually a usecase for KVM exposing this to the VMM - AFAICS, KVM doesn't do anything special for DC ZVA and friends, and doesn't tweak HCR_EL2.TDZ which would change behaviour.
Quoted 6 lines
I guess the only one I can think of is to correctly fail migration from a source CPU with a DCZID_EL0.BS that doesn't match the one on the destination CPU. (We can't lie to the guest about the blocksize as part of "tell the guest it has a different CPU type from the actual host" unless we want to trap and emulate all the DC ZVA etc insns...)
Agreed.
Might actually be best to assert that kvm code is not doing anything with the reg, rather than providing a dummy value. I'll respin.