* [PATCH 0/7] target/arm/hvf cleanups
@ 2025-08-18 4:13 Richard Henderson
2025-08-18 4:13 ` [PATCH 1/7] target/arm: Introduce KVMID_AA64_SYS_REG64 Richard Henderson
` (8 more replies)
0 siblings, 9 replies; 21+ messages in thread
From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw)
To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd
While working on other things cpregs related, I noticed that
target/arm/hvf failed to produce a sorted cpreg_indexes[].
I wondered if that explained the migration-test failure that
we have, but no such luck. (I have no idea how to debug that
test, btw; so far it is still just a mysterious SIGSEGV.)
r~
Richard Henderson (7):
target/arm: Introduce KVMID_AA64_SYS_REG64
target/arm: Move compare_u64 to helper.c
target/arm/hvf: Split out sysreg.c.inc
target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID
target/arm/hvf: Remove hvf_sreg_match.key
target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list
target/arm/hvf: Sort the cpreg_indexes array
target/arm/cpregs.h | 3 +
target/arm/kvm-consts.h | 11 ++
target/arm/helper.c | 11 ++
target/arm/hvf/hvf.c | 230 +++++++++---------------------------
target/arm/kvm.c | 11 --
target/arm/hvf/sysreg.c.inc | 146 +++++++++++++++++++++++
6 files changed, 224 insertions(+), 188 deletions(-)
create mode 100644 target/arm/hvf/sysreg.c.inc
--
2.43.0
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 1/7] target/arm: Introduce KVMID_AA64_SYS_REG64 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 4:13 ` [PATCH 2/7] target/arm: Move compare_u64 to helper.c Richard Henderson ` (7 subsequent siblings) 8 siblings, 0 replies; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd Allow us to create kvm ids directly, rather than going through ENCODE_AA64_CP_REG + cpreg_to_kvm_id. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/kvm-consts.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h index c44d23dbe7..90d792ad42 100644 --- a/target/arm/kvm-consts.h +++ b/target/arm/kvm-consts.h @@ -180,4 +180,15 @@ MISMATCH_CHECK(CP_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_ARM64_SYSREG_OP2_SHIFT); #undef MISMATCH_CHECK +#define KVMID_AA64_SYS_REG_(crn, crm, op0, op1, op2) \ + (CP_REG_AA64_MASK | CP_REG_ARM64_SYSREG | \ + ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) + +#define KVMID_AA64_SYS_REG64(crn, crm, op0, op1, op2) \ + (KVMID_AA64_SYS_REG_(crn, crm, op0, op1, op2) | CP_REG_SIZE_U64) + #endif -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/7] target/arm: Move compare_u64 to helper.c 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson 2025-08-18 4:13 ` [PATCH 1/7] target/arm: Introduce KVMID_AA64_SYS_REG64 Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 6:12 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 3/7] target/arm/hvf: Split out sysreg.c.inc Richard Henderson ` (6 subsequent siblings) 8 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd We will use this function beyond kvm.c. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/cpregs.h | 3 +++ target/arm/helper.c | 11 +++++++++++ target/arm/kvm.c | 11 ----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index c9506aa6d5..2854960c08 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -1189,4 +1189,7 @@ static inline bool arm_cpreg_traps_in_nv(const ARMCPRegInfo *ri) (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)), \ (_val)) +/* Compare uint64_t for qsort and bsearch. */ +int compare_u64(const void *a, const void *b); + #endif /* TARGET_ARM_CPREGS_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 0c1299ff84..d230f9e766 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -40,6 +40,17 @@ static void switch_mode(CPUARMState *env, int mode); +int compare_u64(const void *a, const void *b) +{ + if (*(uint64_t *)a > *(uint64_t *)b) { + return 1; + } + if (*(uint64_t *)a < *(uint64_t *)b) { + return -1; + } + return 0; +} + uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri) { assert(ri->fieldoffset); diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 6672344855..9e569eff65 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -718,17 +718,6 @@ void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group, memory_region_ref(kd->mr); } -static int compare_u64(const void *a, const void *b) -{ - if (*(uint64_t *)a > *(uint64_t *)b) { - return 1; - } - if (*(uint64_t *)a < *(uint64_t *)b) { - return -1; - } - return 0; -} - /* * cpreg_values are sorted in ascending order by KVM register ID * (see kvm_arm_init_cpreg_list). This allows us to cheaply find -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 2/7] target/arm: Move compare_u64 to helper.c 2025-08-18 4:13 ` [PATCH 2/7] target/arm: Move compare_u64 to helper.c Richard Henderson @ 2025-08-18 6:12 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 6:12 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm On 18/8/25 06:13, Richard Henderson wrote: > We will use this function beyond kvm.c. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/cpregs.h | 3 +++ > target/arm/helper.c | 11 +++++++++++ > target/arm/kvm.c | 11 ----------- > 3 files changed, 14 insertions(+), 11 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/7] target/arm/hvf: Split out sysreg.c.inc 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson 2025-08-18 4:13 ` [PATCH 1/7] target/arm: Introduce KVMID_AA64_SYS_REG64 Richard Henderson 2025-08-18 4:13 ` [PATCH 2/7] target/arm: Move compare_u64 to helper.c Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 6:13 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID Richard Henderson ` (5 subsequent siblings) 8 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd Move the list of supported sysregs to a reuseable file. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/hvf/hvf.c | 147 ++---------------------------------- target/arm/hvf/sysreg.c.inc | 146 +++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 141 deletions(-) create mode 100644 target/arm/hvf/sysreg.c.inc diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 47b0cd3a35..f0e4b75e6a 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -403,150 +403,15 @@ struct hvf_sreg_match { uint32_t cp_idx; }; +#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) \ + { HVF_ID, HVF_SYSREG(crn, crm, op0, op1, op2) }, + static struct hvf_sreg_match hvf_sreg_match[] = { - { HV_SYS_REG_DBGBVR0_EL1, HVF_SYSREG(0, 0, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR0_EL1, HVF_SYSREG(0, 0, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR0_EL1, HVF_SYSREG(0, 0, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR0_EL1, HVF_SYSREG(0, 0, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR1_EL1, HVF_SYSREG(0, 1, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR1_EL1, HVF_SYSREG(0, 1, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR1_EL1, HVF_SYSREG(0, 1, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR1_EL1, HVF_SYSREG(0, 1, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR2_EL1, HVF_SYSREG(0, 2, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR2_EL1, HVF_SYSREG(0, 2, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR2_EL1, HVF_SYSREG(0, 2, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR2_EL1, HVF_SYSREG(0, 2, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR3_EL1, HVF_SYSREG(0, 3, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR3_EL1, HVF_SYSREG(0, 3, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR3_EL1, HVF_SYSREG(0, 3, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR3_EL1, HVF_SYSREG(0, 3, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR4_EL1, HVF_SYSREG(0, 4, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR4_EL1, HVF_SYSREG(0, 4, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR4_EL1, HVF_SYSREG(0, 4, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR4_EL1, HVF_SYSREG(0, 4, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR5_EL1, HVF_SYSREG(0, 5, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR5_EL1, HVF_SYSREG(0, 5, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR5_EL1, HVF_SYSREG(0, 5, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR5_EL1, HVF_SYSREG(0, 5, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR6_EL1, HVF_SYSREG(0, 6, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR6_EL1, HVF_SYSREG(0, 6, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR6_EL1, HVF_SYSREG(0, 6, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR6_EL1, HVF_SYSREG(0, 6, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR7_EL1, HVF_SYSREG(0, 7, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR7_EL1, HVF_SYSREG(0, 7, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR7_EL1, HVF_SYSREG(0, 7, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR7_EL1, HVF_SYSREG(0, 7, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR8_EL1, HVF_SYSREG(0, 8, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR8_EL1, HVF_SYSREG(0, 8, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR8_EL1, HVF_SYSREG(0, 8, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR8_EL1, HVF_SYSREG(0, 8, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR9_EL1, HVF_SYSREG(0, 9, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR9_EL1, HVF_SYSREG(0, 9, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR9_EL1, HVF_SYSREG(0, 9, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR9_EL1, HVF_SYSREG(0, 9, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR10_EL1, HVF_SYSREG(0, 10, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR10_EL1, HVF_SYSREG(0, 10, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR10_EL1, HVF_SYSREG(0, 10, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR10_EL1, HVF_SYSREG(0, 10, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR11_EL1, HVF_SYSREG(0, 11, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR11_EL1, HVF_SYSREG(0, 11, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR11_EL1, HVF_SYSREG(0, 11, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR11_EL1, HVF_SYSREG(0, 11, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR12_EL1, HVF_SYSREG(0, 12, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR12_EL1, HVF_SYSREG(0, 12, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR12_EL1, HVF_SYSREG(0, 12, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR12_EL1, HVF_SYSREG(0, 12, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR13_EL1, HVF_SYSREG(0, 13, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR13_EL1, HVF_SYSREG(0, 13, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR13_EL1, HVF_SYSREG(0, 13, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR13_EL1, HVF_SYSREG(0, 13, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR14_EL1, HVF_SYSREG(0, 14, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR14_EL1, HVF_SYSREG(0, 14, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR14_EL1, HVF_SYSREG(0, 14, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR14_EL1, HVF_SYSREG(0, 14, 2, 0, 7) }, - - { HV_SYS_REG_DBGBVR15_EL1, HVF_SYSREG(0, 15, 2, 0, 4) }, - { HV_SYS_REG_DBGBCR15_EL1, HVF_SYSREG(0, 15, 2, 0, 5) }, - { HV_SYS_REG_DBGWVR15_EL1, HVF_SYSREG(0, 15, 2, 0, 6) }, - { HV_SYS_REG_DBGWCR15_EL1, HVF_SYSREG(0, 15, 2, 0, 7) }, - -#ifdef SYNC_NO_RAW_REGS - /* - * The registers below are manually synced on init because they are - * marked as NO_RAW. We still list them to make number space sync easier. - */ - { HV_SYS_REG_MDCCINT_EL1, HVF_SYSREG(0, 2, 2, 0, 0) }, - { HV_SYS_REG_MIDR_EL1, HVF_SYSREG(0, 0, 3, 0, 0) }, - { HV_SYS_REG_MPIDR_EL1, HVF_SYSREG(0, 0, 3, 0, 5) }, - { 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) }, - { 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) }, - { HV_SYS_REG_ID_AA64ISAR1_EL1, HVF_SYSREG(0, 6, 3, 0, 1) }, -#ifdef SYNC_NO_MMFR0 - /* We keep the hardware MMFR0 around. HW limits are there anyway */ - { HV_SYS_REG_ID_AA64MMFR0_EL1, HVF_SYSREG(0, 7, 3, 0, 0) }, -#endif - { HV_SYS_REG_ID_AA64MMFR1_EL1, HVF_SYSREG(0, 7, 3, 0, 1) }, - { HV_SYS_REG_ID_AA64MMFR2_EL1, HVF_SYSREG(0, 7, 3, 0, 2) }, - /* Add ID_AA64MMFR3_EL1 here when HVF supports it */ - - { HV_SYS_REG_MDSCR_EL1, HVF_SYSREG(0, 2, 2, 0, 2) }, - { HV_SYS_REG_SCTLR_EL1, HVF_SYSREG(1, 0, 3, 0, 0) }, - { HV_SYS_REG_CPACR_EL1, HVF_SYSREG(1, 0, 3, 0, 2) }, - { HV_SYS_REG_TTBR0_EL1, HVF_SYSREG(2, 0, 3, 0, 0) }, - { HV_SYS_REG_TTBR1_EL1, HVF_SYSREG(2, 0, 3, 0, 1) }, - { HV_SYS_REG_TCR_EL1, HVF_SYSREG(2, 0, 3, 0, 2) }, - - { HV_SYS_REG_APIAKEYLO_EL1, HVF_SYSREG(2, 1, 3, 0, 0) }, - { HV_SYS_REG_APIAKEYHI_EL1, HVF_SYSREG(2, 1, 3, 0, 1) }, - { HV_SYS_REG_APIBKEYLO_EL1, HVF_SYSREG(2, 1, 3, 0, 2) }, - { HV_SYS_REG_APIBKEYHI_EL1, HVF_SYSREG(2, 1, 3, 0, 3) }, - { HV_SYS_REG_APDAKEYLO_EL1, HVF_SYSREG(2, 2, 3, 0, 0) }, - { HV_SYS_REG_APDAKEYHI_EL1, HVF_SYSREG(2, 2, 3, 0, 1) }, - { HV_SYS_REG_APDBKEYLO_EL1, HVF_SYSREG(2, 2, 3, 0, 2) }, - { HV_SYS_REG_APDBKEYHI_EL1, HVF_SYSREG(2, 2, 3, 0, 3) }, - { HV_SYS_REG_APGAKEYLO_EL1, HVF_SYSREG(2, 3, 3, 0, 0) }, - { HV_SYS_REG_APGAKEYHI_EL1, HVF_SYSREG(2, 3, 3, 0, 1) }, - - { HV_SYS_REG_SPSR_EL1, HVF_SYSREG(4, 0, 3, 0, 0) }, - { HV_SYS_REG_ELR_EL1, HVF_SYSREG(4, 0, 3, 0, 1) }, - { HV_SYS_REG_SP_EL0, HVF_SYSREG(4, 1, 3, 0, 0) }, - { HV_SYS_REG_AFSR0_EL1, HVF_SYSREG(5, 1, 3, 0, 0) }, - { HV_SYS_REG_AFSR1_EL1, HVF_SYSREG(5, 1, 3, 0, 1) }, - { HV_SYS_REG_ESR_EL1, HVF_SYSREG(5, 2, 3, 0, 0) }, - { HV_SYS_REG_FAR_EL1, HVF_SYSREG(6, 0, 3, 0, 0) }, - { HV_SYS_REG_PAR_EL1, HVF_SYSREG(7, 4, 3, 0, 0) }, - { HV_SYS_REG_MAIR_EL1, HVF_SYSREG(10, 2, 3, 0, 0) }, - { HV_SYS_REG_AMAIR_EL1, HVF_SYSREG(10, 3, 3, 0, 0) }, - { HV_SYS_REG_VBAR_EL1, HVF_SYSREG(12, 0, 3, 0, 0) }, - { HV_SYS_REG_CONTEXTIDR_EL1, HVF_SYSREG(13, 0, 3, 0, 1) }, - { HV_SYS_REG_TPIDR_EL1, HVF_SYSREG(13, 0, 3, 0, 4) }, - { HV_SYS_REG_CNTKCTL_EL1, HVF_SYSREG(14, 1, 3, 0, 0) }, - { HV_SYS_REG_CSSELR_EL1, HVF_SYSREG(0, 0, 3, 2, 0) }, - { HV_SYS_REG_TPIDR_EL0, HVF_SYSREG(13, 0, 3, 3, 2) }, - { HV_SYS_REG_TPIDRRO_EL0, HVF_SYSREG(13, 0, 3, 3, 3) }, - { HV_SYS_REG_CNTV_CTL_EL0, HVF_SYSREG(14, 3, 3, 3, 1) }, - { HV_SYS_REG_CNTV_CVAL_EL0, HVF_SYSREG(14, 3, 3, 3, 2) }, - { HV_SYS_REG_SP_EL1, HVF_SYSREG(4, 1, 3, 4, 0) }, +#include "sysreg.c.inc" }; +#undef DEF_SYSREG + int hvf_get_registers(CPUState *cpu) { ARMCPU *arm_cpu = ARM_CPU(cpu); diff --git a/target/arm/hvf/sysreg.c.inc b/target/arm/hvf/sysreg.c.inc new file mode 100644 index 0000000000..222698f1d1 --- /dev/null +++ b/target/arm/hvf/sysreg.c.inc @@ -0,0 +1,146 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +DEF_SYSREG(HV_SYS_REG_DBGBVR0_EL1, 0, 0, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR0_EL1, 0, 0, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR0_EL1, 0, 0, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR0_EL1, 0, 0, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR1_EL1, 0, 1, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR1_EL1, 0, 1, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR1_EL1, 0, 1, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR1_EL1, 0, 1, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR2_EL1, 0, 2, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR2_EL1, 0, 2, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR2_EL1, 0, 2, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR2_EL1, 0, 2, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR3_EL1, 0, 3, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR3_EL1, 0, 3, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR3_EL1, 0, 3, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR3_EL1, 0, 3, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR4_EL1, 0, 4, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR4_EL1, 0, 4, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR4_EL1, 0, 4, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR4_EL1, 0, 4, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR5_EL1, 0, 5, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR5_EL1, 0, 5, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR5_EL1, 0, 5, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR5_EL1, 0, 5, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR6_EL1, 0, 6, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR6_EL1, 0, 6, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR6_EL1, 0, 6, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR6_EL1, 0, 6, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR7_EL1, 0, 7, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR7_EL1, 0, 7, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR7_EL1, 0, 7, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR7_EL1, 0, 7, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR8_EL1, 0, 8, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR8_EL1, 0, 8, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR8_EL1, 0, 8, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR8_EL1, 0, 8, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR9_EL1, 0, 9, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR9_EL1, 0, 9, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR9_EL1, 0, 9, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR9_EL1, 0, 9, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR10_EL1, 0, 10, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR10_EL1, 0, 10, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR10_EL1, 0, 10, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR10_EL1, 0, 10, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR11_EL1, 0, 11, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR11_EL1, 0, 11, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR11_EL1, 0, 11, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR11_EL1, 0, 11, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR12_EL1, 0, 12, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR12_EL1, 0, 12, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR12_EL1, 0, 12, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR12_EL1, 0, 12, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR13_EL1, 0, 13, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR13_EL1, 0, 13, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR13_EL1, 0, 13, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR13_EL1, 0, 13, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR14_EL1, 0, 14, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR14_EL1, 0, 14, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR14_EL1, 0, 14, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR14_EL1, 0, 14, 2, 0, 7) + +DEF_SYSREG(HV_SYS_REG_DBGBVR15_EL1, 0, 15, 2, 0, 4) +DEF_SYSREG(HV_SYS_REG_DBGBCR15_EL1, 0, 15, 2, 0, 5) +DEF_SYSREG(HV_SYS_REG_DBGWVR15_EL1, 0, 15, 2, 0, 6) +DEF_SYSREG(HV_SYS_REG_DBGWCR15_EL1, 0, 15, 2, 0, 7) + +#ifdef SYNC_NO_RAW_REGS +/* + * The registers below are manually synced on init because they are + * marked as NO_RAW. We still list them to make number space sync easier. + */ +DEF_SYSREG(HV_SYS_REG_MDCCINT_EL1, 0, 2, 2, 0, 0) +DEF_SYSREG(HV_SYS_REG_MIDR_EL1, 0, 0, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_MPIDR_EL1, 0, 0, 3, 0, 5) +DEF_SYSREG(HV_SYS_REG_ID_AA64PFR0_EL1, 0, 4, 3, 0, 0) +#endif + +DEF_SYSREG(HV_SYS_REG_ID_AA64PFR1_EL1, 0, 4, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_ID_AA64DFR0_EL1, 0, 5, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_ID_AA64DFR1_EL1, 0, 5, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_ID_AA64ISAR0_EL1, 0, 6, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_ID_AA64ISAR1_EL1, 0, 6, 3, 0, 1) + +#ifdef SYNC_NO_MMFR0 +/* We keep the hardware MMFR0 around. HW limits are there anyway */ +DEF_SYSREG(HV_SYS_REG_ID_AA64MMFR0_EL1, 0, 7, 3, 0, 0) +#endif + +DEF_SYSREG(HV_SYS_REG_ID_AA64MMFR1_EL1, 0, 7, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_ID_AA64MMFR2_EL1, 0, 7, 3, 0, 2) +/* Add ID_AA64MMFR3_EL1 here when HVF supports it */ + +DEF_SYSREG(HV_SYS_REG_MDSCR_EL1, 0, 2, 2, 0, 2) +DEF_SYSREG(HV_SYS_REG_SCTLR_EL1, 1, 0, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_CPACR_EL1, 1, 0, 3, 0, 2) +DEF_SYSREG(HV_SYS_REG_TTBR0_EL1, 2, 0, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_TTBR1_EL1, 2, 0, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_TCR_EL1, 2, 0, 3, 0, 2) + +DEF_SYSREG(HV_SYS_REG_APIAKEYLO_EL1, 2, 1, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_APIAKEYHI_EL1, 2, 1, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_APIBKEYLO_EL1, 2, 1, 3, 0, 2) +DEF_SYSREG(HV_SYS_REG_APIBKEYHI_EL1, 2, 1, 3, 0, 3) +DEF_SYSREG(HV_SYS_REG_APDAKEYLO_EL1, 2, 2, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_APDAKEYHI_EL1, 2, 2, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_APDBKEYLO_EL1, 2, 2, 3, 0, 2) +DEF_SYSREG(HV_SYS_REG_APDBKEYHI_EL1, 2, 2, 3, 0, 3) +DEF_SYSREG(HV_SYS_REG_APGAKEYLO_EL1, 2, 3, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_APGAKEYHI_EL1, 2, 3, 3, 0, 1) + +DEF_SYSREG(HV_SYS_REG_SPSR_EL1, 4, 0, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_ELR_EL1, 4, 0, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_SP_EL0, 4, 1, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_AFSR0_EL1, 5, 1, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_AFSR1_EL1, 5, 1, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_ESR_EL1, 5, 2, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_FAR_EL1, 6, 0, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_PAR_EL1, 7, 4, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_MAIR_EL1, 10, 2, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_AMAIR_EL1, 10, 3, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_VBAR_EL1, 12, 0, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_CONTEXTIDR_EL1, 13, 0, 3, 0, 1) +DEF_SYSREG(HV_SYS_REG_TPIDR_EL1, 13, 0, 3, 0, 4) +DEF_SYSREG(HV_SYS_REG_CNTKCTL_EL1, 14, 1, 3, 0, 0) +DEF_SYSREG(HV_SYS_REG_CSSELR_EL1, 0, 0, 3, 2, 0) +DEF_SYSREG(HV_SYS_REG_TPIDR_EL0, 13, 0, 3, 3, 2) +DEF_SYSREG(HV_SYS_REG_TPIDRRO_EL0, 13, 0, 3, 3, 3) +DEF_SYSREG(HV_SYS_REG_CNTV_CTL_EL0, 14, 3, 3, 3, 1) +DEF_SYSREG(HV_SYS_REG_CNTV_CVAL_EL0, 14, 3, 3, 3, 2) +DEF_SYSREG(HV_SYS_REG_SP_EL1, 4, 1, 3, 4, 0) -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 3/7] target/arm/hvf: Split out sysreg.c.inc 2025-08-18 4:13 ` [PATCH 3/7] target/arm/hvf: Split out sysreg.c.inc Richard Henderson @ 2025-08-18 6:13 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 6:13 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm On 18/8/25 06:13, Richard Henderson wrote: > Move the list of supported sysregs to a reuseable file. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/hvf/hvf.c | 147 ++---------------------------------- > target/arm/hvf/sysreg.c.inc | 146 +++++++++++++++++++++++++++++++++++ > 2 files changed, 152 insertions(+), 141 deletions(-) > create mode 100644 target/arm/hvf/sysreg.c.inc Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson ` (2 preceding siblings ...) 2025-08-18 4:13 ` [PATCH 3/7] target/arm/hvf: Split out sysreg.c.inc Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 12:41 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 5/7] target/arm/hvf: Remove hvf_sreg_match.key Richard Henderson ` (4 subsequent siblings) 8 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd Conversion between KVM system registers ids and the HVF system register ids is trivial. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/hvf/hvf.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index f0e4b75e6a..2577dc1c0c 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -403,6 +403,26 @@ struct hvf_sreg_match { uint32_t cp_idx; }; +/* + * QEMU uses KVM system register ids in the migration format. + * Conveniently, HVF uses the same encoding of the op* and cr* parameters + * within the low 16 bits of the ids. Thus conversion between the + * formats is trivial. + */ + +#define KVMID_TO_HVF(KVM) ((KVM) & 0xffff) +#define HVF_TO_KVMID(HVF) \ + (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF)) + +/* Verify this at compile-time. */ + +#define DEF_SYSREG(HVF_ID, ...) \ + QEMU_BUILD_BUG_ON(HVF_ID != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARGS__))); + +#include "sysreg.c.inc" + +#undef DEF_SYSREG + #define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) \ { HVF_ID, HVF_SYSREG(crn, crm, op0, op1, op2) }, -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-08-18 4:13 ` [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID Richard Henderson @ 2025-08-18 12:41 ` Philippe Mathieu-Daudé 2025-08-18 13:21 ` Richard Henderson 0 siblings, 1 reply; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 12:41 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm, Mohamed Mediouni On 18/8/25 06:13, Richard Henderson wrote: > Conversion between KVM system registers ids and the HVF system > register ids is trivial. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/hvf/hvf.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c > index f0e4b75e6a..2577dc1c0c 100644 > --- a/target/arm/hvf/hvf.c > +++ b/target/arm/hvf/hvf.c > @@ -403,6 +403,26 @@ struct hvf_sreg_match { > uint32_t cp_idx; > }; > > +/* > + * QEMU uses KVM system register ids in the migration format. > + * Conveniently, HVF uses the same encoding of the op* and cr* parameters > + * within the low 16 bits of the ids. Thus conversion between the > + * formats is trivial. > + */ > + > +#define KVMID_TO_HVF(KVM) ((KVM) & 0xffff) > +#define HVF_TO_KVMID(HVF) \ > + (CP_REG_ARM64 | CP_REG_SIZE_U64 | CP_REG_ARM64_SYSREG | (HVF)) > + > +/* Verify this at compile-time. */ > + > +#define DEF_SYSREG(HVF_ID, ...) \ > + QEMU_BUILD_BUG_ON(HVF_ID != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(__VA_ARGS__))); Rebasing Mohamed's work I'm getting: In file included from ../../target/arm/hvf/hvf.c:413: ../../target/arm/hvf/sysreg.c.inc:156:1: error: static assertion failed due to requirement '!(HV_SYS_REG_MDCR_EL2 != (((((1 << 28) | (19 << 16) | ((3) << 14) | ((4) << 11) | ((1) << 7) | ((1) << 3) | ((1) << 0)) | 13510798882111488ULL)) & 65535))': not expecting: HV_SYS_REG_MDCR_EL2 != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(1, 1, 3, 4, 1)) 156 | DEF_SYSREG(HV_SYS_REG_MDCR_EL2, 1, 1, 3, 4, 1) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Having in <Hypervisor.h> -> <Hypervisor/hv_vcpu_types.h>: // Exception Level 2 (EL2) registers. // These registers are only available if EL2 was enabled in the VM configuration. HV_SYS_REG_CNTHCTL_EL2 = 0xe708, HV_SYS_REG_CNTHP_CTL_EL2 = 0xe711, HV_SYS_REG_CNTHP_CVAL_EL2 = 0xe712, HV_SYS_REG_CNTHP_TVAL_EL2 = 0xe710, HV_SYS_REG_CNTVOFF_EL2 = 0xe703, HV_SYS_REG_CPTR_EL2 = 0xe08a, HV_SYS_REG_ELR_EL2 = 0xe201, HV_SYS_REG_ESR_EL2 = 0xe290, HV_SYS_REG_FAR_EL2 = 0xe300, HV_SYS_REG_HCR_EL2 = 0xe088, HV_SYS_REG_HPFAR_EL2 = 0xe304, HV_SYS_REG_MAIR_EL2 = 0xe510, HV_SYS_REG_MDCR_EL2 = 0xe019, <---- HV_SYS_REG_SCTLR_EL2 = 0xe080, HV_SYS_REG_SPSR_EL2 = 0xe200, HV_SYS_REG_SP_EL2 = 0xf208, HV_SYS_REG_TCR_EL2 = 0xe102, HV_SYS_REG_TPIDR_EL2 = 0xe682, HV_SYS_REG_TTBR0_EL2 = 0xe100, HV_SYS_REG_TTBR1_EL2 = 0xe101, HV_SYS_REG_VBAR_EL2 = 0xe600, HV_SYS_REG_VMPIDR_EL2 = 0xe005, HV_SYS_REG_VPIDR_EL2 = 0xe000, HV_SYS_REG_VTCR_EL2 = 0xe10a, HV_SYS_REG_VTTBR_EL2 = 0xe108, > + > +#include "sysreg.c.inc" > + > +#undef DEF_SYSREG > + > #define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) \ > { HVF_ID, HVF_SYSREG(crn, crm, op0, op1, op2) }, > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-08-18 12:41 ` Philippe Mathieu-Daudé @ 2025-08-18 13:21 ` Richard Henderson 2025-08-18 15:46 ` Philippe Mathieu-Daudé 0 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 13:21 UTC (permalink / raw) To: Philippe Mathieu-Daudé, qemu-devel Cc: mads, agraf, qemu-arm, Mohamed Mediouni On 8/18/25 22:41, Philippe Mathieu-Daudé wrote: > Rebasing Mohamed's work I'm getting: > > In file included from ../../target/arm/hvf/hvf.c:413: > ../../target/arm/hvf/sysreg.c.inc:156:1: error: static assertion failed due to requirement > '!(HV_SYS_REG_MDCR_EL2 != (((((1 << 28) | (19 << 16) | ((3) << 14) | ((4) << 11) | ((1) << > 7) | ((1) << 3) | ((1) << 0)) | 13510798882111488ULL)) & 65535))': not expecting: > HV_SYS_REG_MDCR_EL2 != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(1, 1, 3, 4, 1)) > 156 | DEF_SYSREG(HV_SYS_REG_MDCR_EL2, 1, 1, 3, 4, 1) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > HV_SYS_REG_MDCR_EL2 = 0xe019, <---- How odd. It should be e089, if it were encoded like all the others. I wonder if this is a manual typo that's now baked into the api, or if it's an OS bug. r~ ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-08-18 13:21 ` Richard Henderson @ 2025-08-18 15:46 ` Philippe Mathieu-Daudé 2025-08-18 18:37 ` Danny Canter 0 siblings, 1 reply; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 15:46 UTC (permalink / raw) To: Richard Henderson, qemu-devel Cc: mads, agraf, qemu-arm, Mohamed Mediouni, Danny Canter, Cameron Esfahani, Akihiko Odaki Cc'ing Apple folks hoping they can forward or directly help :) On 18/8/25 15:21, Richard Henderson wrote: > On 8/18/25 22:41, Philippe Mathieu-Daudé wrote: >> Rebasing Mohamed's work I'm getting: >> >> In file included from ../../target/arm/hvf/hvf.c:413: >> ../../target/arm/hvf/sysreg.c.inc:156:1: error: static assertion >> failed due to requirement '!(HV_SYS_REG_MDCR_EL2 != (((((1 << 28) | >> (19 << 16) | ((3) << 14) | ((4) << 11) | ((1) << 7) | ((1) << 3) | >> ((1) << 0)) | 13510798882111488ULL)) & 65535))': not expecting: >> HV_SYS_REG_MDCR_EL2 != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(1, 1, 3, 4, 1)) >> 156 | DEF_SYSREG(HV_SYS_REG_MDCR_EL2, 1, 1, 3, 4, 1) >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > >> HV_SYS_REG_MDCR_EL2 = 0xe019, <---- > > How odd. It should be e089, if it were encoded like all the others. > > I wonder if this is a manual typo that's now baked into the api, or if > it's an OS bug. > > > r~ > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-08-18 15:46 ` Philippe Mathieu-Daudé @ 2025-08-18 18:37 ` Danny Canter 2025-09-01 15:02 ` Philippe Mathieu-Daudé 0 siblings, 1 reply; 21+ messages in thread From: Danny Canter @ 2025-08-18 18:37 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: Richard Henderson, qemu-devel, mads, agraf, qemu-arm, Mohamed Mediouni, Cameron Esfahani, Akihiko Odaki [-- Attachment #1: Type: text/plain, Size: 1427 bytes --] Howdy, On macOS versions/SDKs before 26 you are correct, we had an invalid enum value for HV_SYS_REG_MDCR_EL2 in the API, but the hv_vcpu_get/set_sys_reg APIs work with this value even though the encoding is incorrect. The enum value has been remedied in 26+ (0xe089 as you pointed out) and has been done in a backwards compatible way internally in the framework. > On Aug 18, 2025, at 8:46 AM, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Cc'ing Apple folks hoping they can forward or directly help :) > > On 18/8/25 15:21, Richard Henderson wrote: >> On 8/18/25 22:41, Philippe Mathieu-Daudé wrote: >>> Rebasing Mohamed's work I'm getting: >>> >>> In file included from ../../target/arm/hvf/hvf.c:413: >>> ../../target/arm/hvf/sysreg.c.inc:156:1: error: static assertion failed due to requirement '!(HV_SYS_REG_MDCR_EL2 != (((((1 << 28) | (19 << 16) | ((3) << 14) | ((4) << 11) | ((1) << 7) | ((1) << 3) | ((1) << 0)) | 13510798882111488ULL)) & 65535))': not expecting: HV_SYS_REG_MDCR_EL2 != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(1, 1, 3, 4, 1)) >>> 156 | DEF_SYSREG(HV_SYS_REG_MDCR_EL2, 1, 1, 3, 4, 1) >>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>> HV_SYS_REG_MDCR_EL2 = 0xe019, <---- >> How odd. It should be e089, if it were encoded like all the others. >> I wonder if this is a manual typo that's now baked into the api, or if it's an OS bug. >> r~ > [-- Attachment #2: Type: text/html, Size: 2973 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-08-18 18:37 ` Danny Canter @ 2025-09-01 15:02 ` Philippe Mathieu-Daudé 2025-09-02 13:40 ` Richard Henderson 0 siblings, 1 reply; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-09-01 15:02 UTC (permalink / raw) To: Richard Henderson Cc: qemu-devel, mads, agraf, Danny Canter, qemu-arm, Mohamed Mediouni, Cameron Esfahani, Akihiko Odaki On 18/8/25 20:37, Danny Canter wrote: > Howdy, > > On macOS versions/SDKs before 26 you are correct, we had an invalid enum > value for HV_SYS_REG_MDCR_EL2 in the API, but the hv_vcpu_get/ > set_sys_reg APIs work with this value even though the > encoding is incorrect. The enum value has been remedied in 26+ (0xe089 > as you pointed out) and has been done in a backwards compatible way > internally in the framework. Thanks Danny! Richard, should we guard the QEMU_BUILD_BUG_ON() macro with: #if defined(MAC_OS_VERSION_26_0) && \ MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_26_0 ? > >> On Aug 18, 2025, at 8:46 AM, Philippe Mathieu-Daudé >> <philmd@linaro.org> wrote: >> >> Cc'ing Apple folks hoping they can forward or directly help :) >> >> On 18/8/25 15:21, Richard Henderson wrote: >>> On 8/18/25 22:41, Philippe Mathieu-Daudé wrote: >>>> Rebasing Mohamed's work I'm getting: >>>> >>>> In file included from ../../target/arm/hvf/hvf.c:413: >>>> ../../target/arm/hvf/sysreg.c.inc:156:1: error: static assertion >>>> failed due to requirement '!(HV_SYS_REG_MDCR_EL2 != (((((1 << 28) | >>>> (19 << 16) | ((3) << 14) | ((4) << 11) | ((1) << 7) | ((1) << 3) | >>>> ((1) << 0)) | 13510798882111488ULL)) & 65535))': not expecting: >>>> HV_SYS_REG_MDCR_EL2 != KVMID_TO_HVF(KVMID_AA64_SYS_REG64(1, 1, 3, 4, 1)) >>>> 156 | DEF_SYSREG(HV_SYS_REG_MDCR_EL2, 1, 1, 3, 4, 1) >>>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>>> HV_SYS_REG_MDCR_EL2 = 0xe019, <---- >>> How odd. It should be e089, if it were encoded like all the others. >>> I wonder if this is a manual typo that's now baked into the api, or >>> if it's an OS bug. >>> r~ >> > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID 2025-09-01 15:02 ` Philippe Mathieu-Daudé @ 2025-09-02 13:40 ` Richard Henderson 0 siblings, 0 replies; 21+ messages in thread From: Richard Henderson @ 2025-09-02 13:40 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: qemu-devel, mads, agraf, Danny Canter, qemu-arm, Mohamed Mediouni, Cameron Esfahani, Akihiko Odaki On 9/1/25 01:02, Philippe Mathieu-Daudé wrote: > On 18/8/25 20:37, Danny Canter wrote: >> Howdy, >> >> On macOS versions/SDKs before 26 you are correct, we had an invalid enum value for >> HV_SYS_REG_MDCR_EL2 in the API, but the hv_vcpu_get/ set_sys_reg APIs work with this >> value even though the >> encoding is incorrect. The enum value has been remedied in 26+ (0xe089 as you pointed >> out) and has been done in a backwards compatible way internally in the framework. > > Thanks Danny! > > Richard, should we guard the QEMU_BUILD_BUG_ON() macro with: > > #if defined(MAC_OS_VERSION_26_0) && \ > MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_26_0 > > ? That's one possibility. Another is to remap the one broken enum, since this fix is described to be backward compatible. r~ ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/7] target/arm/hvf: Remove hvf_sreg_match.key 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson ` (3 preceding siblings ...) 2025-08-18 4:13 ` [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 6:15 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list Richard Henderson ` (3 subsequent siblings) 8 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd Use conversion functions instead of table lookup. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/hvf/hvf.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 2577dc1c0c..46e52e8d34 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -152,9 +152,6 @@ void hvf_arm_init_debug(void) g_array_sized_new(true, true, sizeof(HWWatchpoint), max_hw_wps); } -#define HVF_SYSREG(crn, crm, op0, op1, op2) \ - ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, crn, crm, op0, op1, op2) - #define SYSREG_OP0_SHIFT 20 #define SYSREG_OP0_MASK 0x3 #define SYSREG_OP0(sysreg) ((sysreg >> SYSREG_OP0_SHIFT) & SYSREG_OP0_MASK) @@ -399,7 +396,6 @@ static const struct hvf_reg_match hvf_fpreg_match[] = { struct hvf_sreg_match { int reg; - uint32_t key; uint32_t cp_idx; }; @@ -423,8 +419,7 @@ struct hvf_sreg_match { #undef DEF_SYSREG -#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) \ - { HVF_ID, HVF_SYSREG(crn, crm, op0, op1, op2) }, +#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) { HVF_ID }, static struct hvf_sreg_match hvf_sreg_match[] = { #include "sysreg.c.inc" @@ -469,13 +464,16 @@ int hvf_get_registers(CPUState *cpu) pstate_write(env, val); for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) { + int hvf_id = hvf_sreg_match[i].reg; + uint64_t kvm_id = HVF_TO_KVMID(hvf_id); + if (hvf_sreg_match[i].cp_idx == -1) { continue; } if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ - switch (hvf_sreg_match[i].reg) { + switch (hvf_id) { case HV_SYS_REG_DBGBVR0_EL1: case HV_SYS_REG_DBGBCR0_EL1: case HV_SYS_REG_DBGWVR0_EL1: @@ -549,8 +547,10 @@ int hvf_get_registers(CPUState *cpu) * vCPU but simply keep the values from the previous * environment. */ - const ARMCPRegInfo *ri; - ri = get_arm_cp_reginfo(arm_cpu->cp_regs, hvf_sreg_match[i].key); + uint32_t key = kvm_to_cpreg_id(kvm_id); + const ARMCPRegInfo *ri = + get_arm_cp_reginfo(arm_cpu->cp_regs, key); + val = read_raw_cp_reg(env, ri); arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] = val; @@ -559,7 +559,7 @@ int hvf_get_registers(CPUState *cpu) } } - ret = hv_vcpu_get_sys_reg(cpu->accel->fd, hvf_sreg_match[i].reg, &val); + ret = hv_vcpu_get_sys_reg(cpu->accel->fd, hvf_id, &val); assert_hvf_ok(ret); arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] = val; @@ -606,13 +606,15 @@ int hvf_put_registers(CPUState *cpu) assert(write_cpustate_to_list(arm_cpu, false)); for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) { + int hvf_id = hvf_sreg_match[i].reg; + if (hvf_sreg_match[i].cp_idx == -1) { continue; } if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ - switch (hvf_sreg_match[i].reg) { + switch (hvf_id) { case HV_SYS_REG_DBGBVR0_EL1: case HV_SYS_REG_DBGBCR0_EL1: case HV_SYS_REG_DBGWVR0_EL1: @@ -687,7 +689,7 @@ int hvf_put_registers(CPUState *cpu) } val = arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx]; - ret = hv_vcpu_set_sys_reg(cpu->accel->fd, hvf_sreg_match[i].reg, val); + ret = hv_vcpu_set_sys_reg(cpu->accel->fd, hvf_id, val); assert_hvf_ok(ret); } @@ -922,14 +924,15 @@ int hvf_arch_init_vcpu(CPUState *cpu) /* Populate cp list for all known sysregs */ for (i = 0; i < sregs_match_len; i++) { - const ARMCPRegInfo *ri; - uint32_t key = hvf_sreg_match[i].key; + int hvf_id = hvf_sreg_match[i].reg; + uint64_t kvm_id = HVF_TO_KVMID(hvf_id); + uint32_t key = kvm_to_cpreg_id(kvm_id); + const ARMCPRegInfo *ri = get_arm_cp_reginfo(arm_cpu->cp_regs, key); - ri = get_arm_cp_reginfo(arm_cpu->cp_regs, key); if (ri) { assert(!(ri->type & ARM_CP_NO_RAW)); hvf_sreg_match[i].cp_idx = sregs_cnt; - arm_cpu->cpreg_indexes[sregs_cnt++] = cpreg_to_kvm_id(key); + arm_cpu->cpreg_indexes[sregs_cnt++] = kvm_id; } else { hvf_sreg_match[i].cp_idx = -1; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 5/7] target/arm/hvf: Remove hvf_sreg_match.key 2025-08-18 4:13 ` [PATCH 5/7] target/arm/hvf: Remove hvf_sreg_match.key Richard Henderson @ 2025-08-18 6:15 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 6:15 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm On 18/8/25 06:13, Richard Henderson wrote: > Use conversion functions instead of table lookup. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/hvf/hvf.c | 35 +++++++++++++++++++---------------- > 1 file changed, 19 insertions(+), 16 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson ` (4 preceding siblings ...) 2025-08-18 4:13 ` [PATCH 5/7] target/arm/hvf: Remove hvf_sreg_match.key Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 6:17 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 7/7] target/arm/hvf: Sort the cpreg_indexes array Richard Henderson ` (2 subsequent siblings) 8 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd Change hvf_get_registers and hvf_put_registers to iterate over cpregs_indexes instead of hvf_sreg_match. This lets us drop the cp_idx member of hvf_sreg_match, which leaves only one member in the struct. Replace the struct with a const array. Instead of int, use the proper enum type: hv_sys_reg_t. Rename from hvf_sreg_match to hvf_sreg_list because there is no longer any matching going on. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/hvf/hvf.c | 45 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 46e52e8d34..647eb675ef 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -394,11 +394,6 @@ static const struct hvf_reg_match hvf_fpreg_match[] = { { HV_SIMD_FP_REG_Q31, offsetof(CPUARMState, vfp.zregs[31]) }, }; -struct hvf_sreg_match { - int reg; - uint32_t cp_idx; -}; - /* * QEMU uses KVM system register ids in the migration format. * Conveniently, HVF uses the same encoding of the op* and cr* parameters @@ -419,9 +414,9 @@ struct hvf_sreg_match { #undef DEF_SYSREG -#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) { HVF_ID }, +#define DEF_SYSREG(HVF_ID, crn, crm, op0, op1, op2) HVF_ID, -static struct hvf_sreg_match hvf_sreg_match[] = { +static const hv_sys_reg_t hvf_sreg_list[] = { #include "sysreg.c.inc" }; @@ -434,7 +429,7 @@ int hvf_get_registers(CPUState *cpu) hv_return_t ret; uint64_t val; hv_simd_fp_uchar16_t fpval; - int i; + int i, n; for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) { ret = hv_vcpu_get_reg(cpu->accel->fd, hvf_reg_match[i].reg, &val); @@ -463,13 +458,9 @@ int hvf_get_registers(CPUState *cpu) assert_hvf_ok(ret); pstate_write(env, val); - for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) { - int hvf_id = hvf_sreg_match[i].reg; - uint64_t kvm_id = HVF_TO_KVMID(hvf_id); - - if (hvf_sreg_match[i].cp_idx == -1) { - continue; - } + for (i = 0, n = arm_cpu->cpreg_array_len; i < n; i++) { + uint64_t kvm_id = arm_cpu->cpreg_indexes[i]; + int hvf_id = KVMID_TO_HVF(kvm_id); if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ @@ -553,7 +544,7 @@ int hvf_get_registers(CPUState *cpu) val = read_raw_cp_reg(env, ri); - arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] = val; + arm_cpu->cpreg_values[i] = val; continue; } } @@ -562,7 +553,7 @@ int hvf_get_registers(CPUState *cpu) ret = hv_vcpu_get_sys_reg(cpu->accel->fd, hvf_id, &val); assert_hvf_ok(ret); - arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx] = val; + arm_cpu->cpreg_values[i] = val; } assert(write_list_to_cpustate(arm_cpu)); @@ -578,7 +569,7 @@ int hvf_put_registers(CPUState *cpu) hv_return_t ret; uint64_t val; hv_simd_fp_uchar16_t fpval; - int i; + int i, n; for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) { val = *(uint64_t *)((void *)env + hvf_reg_match[i].offset); @@ -605,12 +596,9 @@ int hvf_put_registers(CPUState *cpu) aarch64_save_sp(env, arm_current_el(env)); assert(write_cpustate_to_list(arm_cpu, false)); - for (i = 0; i < ARRAY_SIZE(hvf_sreg_match); i++) { - int hvf_id = hvf_sreg_match[i].reg; - - if (hvf_sreg_match[i].cp_idx == -1) { - continue; - } + for (i = 0, n = arm_cpu->cpreg_array_len; i < n; i++) { + uint64_t kvm_id = arm_cpu->cpreg_indexes[i]; + int hvf_id = KVMID_TO_HVF(kvm_id); if (cpu->accel->guest_debug_enabled) { /* Handle debug registers */ @@ -688,7 +676,7 @@ int hvf_put_registers(CPUState *cpu) } } - val = arm_cpu->cpreg_values[hvf_sreg_match[i].cp_idx]; + val = arm_cpu->cpreg_values[i]; ret = hv_vcpu_set_sys_reg(cpu->accel->fd, hvf_id, val); assert_hvf_ok(ret); } @@ -899,7 +887,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) { ARMCPU *arm_cpu = ARM_CPU(cpu); CPUARMState *env = &arm_cpu->env; - uint32_t sregs_match_len = ARRAY_SIZE(hvf_sreg_match); + uint32_t sregs_match_len = ARRAY_SIZE(hvf_sreg_list); uint32_t sregs_cnt = 0; uint64_t pfr; hv_return_t ret; @@ -924,17 +912,14 @@ int hvf_arch_init_vcpu(CPUState *cpu) /* Populate cp list for all known sysregs */ for (i = 0; i < sregs_match_len; i++) { - int hvf_id = hvf_sreg_match[i].reg; + hv_sys_reg_t hvf_id = hvf_sreg_list[i]; uint64_t kvm_id = HVF_TO_KVMID(hvf_id); uint32_t key = kvm_to_cpreg_id(kvm_id); const ARMCPRegInfo *ri = get_arm_cp_reginfo(arm_cpu->cp_regs, key); if (ri) { assert(!(ri->type & ARM_CP_NO_RAW)); - hvf_sreg_match[i].cp_idx = sregs_cnt; arm_cpu->cpreg_indexes[sregs_cnt++] = kvm_id; - } else { - hvf_sreg_match[i].cp_idx = -1; } } arm_cpu->cpreg_array_len = sregs_cnt; -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list 2025-08-18 4:13 ` [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list Richard Henderson @ 2025-08-18 6:17 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 6:17 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm On 18/8/25 06:13, Richard Henderson wrote: > Change hvf_get_registers and hvf_put_registers to iterate over > cpregs_indexes instead of hvf_sreg_match. > > This lets us drop the cp_idx member of hvf_sreg_match, which leaves > only one member in the struct. Replace the struct with a const array. > Instead of int, use the proper enum type: hv_sys_reg_t. > Rename from hvf_sreg_match to hvf_sreg_list because there is no > longer any matching going on. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/hvf/hvf.c | 45 +++++++++++++++----------------------------- > 1 file changed, 15 insertions(+), 30 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 7/7] target/arm/hvf: Sort the cpreg_indexes array 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson ` (5 preceding siblings ...) 2025-08-18 4:13 ` [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list Richard Henderson @ 2025-08-18 4:13 ` Richard Henderson 2025-08-18 6:18 ` Philippe Mathieu-Daudé 2025-08-18 12:25 ` [PATCH 0/7] target/arm/hvf cleanups Philippe Mathieu-Daudé 2025-08-20 11:52 ` Mads Ynddal 8 siblings, 1 reply; 21+ messages in thread From: Richard Henderson @ 2025-08-18 4:13 UTC (permalink / raw) To: qemu-devel; +Cc: mads, agraf, qemu-arm, philmd Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/hvf/hvf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 647eb675ef..88ed96be11 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -925,6 +925,9 @@ int hvf_arch_init_vcpu(CPUState *cpu) arm_cpu->cpreg_array_len = sregs_cnt; arm_cpu->cpreg_vmstate_array_len = sregs_cnt; + /* cpreg tuples must be in strictly ascending order */ + qsort(arm_cpu->cpreg_indexes, sregs_cnt, sizeof(uint64_t), compare_u64); + assert(write_cpustate_to_list(arm_cpu, false)); /* Set CP_NO_RAW system registers on init */ -- 2.43.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 7/7] target/arm/hvf: Sort the cpreg_indexes array 2025-08-18 4:13 ` [PATCH 7/7] target/arm/hvf: Sort the cpreg_indexes array Richard Henderson @ 2025-08-18 6:18 ` Philippe Mathieu-Daudé 0 siblings, 0 replies; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 6:18 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm On 18/8/25 06:13, Richard Henderson wrote: > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/hvf/hvf.c | 3 +++ > 1 file changed, 3 insertions(+) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/7] target/arm/hvf cleanups 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson ` (6 preceding siblings ...) 2025-08-18 4:13 ` [PATCH 7/7] target/arm/hvf: Sort the cpreg_indexes array Richard Henderson @ 2025-08-18 12:25 ` Philippe Mathieu-Daudé 2025-08-20 11:52 ` Mads Ynddal 8 siblings, 0 replies; 21+ messages in thread From: Philippe Mathieu-Daudé @ 2025-08-18 12:25 UTC (permalink / raw) To: Richard Henderson, qemu-devel; +Cc: mads, agraf, qemu-arm On 18/8/25 06:13, Richard Henderson wrote: > While working on other things cpregs related, I noticed that > target/arm/hvf failed to produce a sorted cpreg_indexes[]. > > I wondered if that explained the migration-test failure that > we have, but no such luck. (I have no idea how to debug that > test, btw; so far it is still just a mysterious SIGSEGV.) I'm experiencing a pleasant speedup. I suppose this is expected, due to the array rearrangement. > Richard Henderson (7): > target/arm: Introduce KVMID_AA64_SYS_REG64 > target/arm: Move compare_u64 to helper.c > target/arm/hvf: Split out sysreg.c.inc > target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID > target/arm/hvf: Remove hvf_sreg_match.key > target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list > target/arm/hvf: Sort the cpreg_indexes array Series: Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/7] target/arm/hvf cleanups 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson ` (7 preceding siblings ...) 2025-08-18 12:25 ` [PATCH 0/7] target/arm/hvf cleanups Philippe Mathieu-Daudé @ 2025-08-20 11:52 ` Mads Ynddal 8 siblings, 0 replies; 21+ messages in thread From: Mads Ynddal @ 2025-08-20 11:52 UTC (permalink / raw) To: Richard Henderson; +Cc: qemu-devel, agraf, qemu-arm, philmd > On 18 Aug 2025, at 06.13, Richard Henderson <richard.henderson@linaro.org> wrote: > > While working on other things cpregs related, I noticed that > target/arm/hvf failed to produce a sorted cpreg_indexes[]. > > I wondered if that explained the migration-test failure that > we have, but no such luck. (I have no idea how to debug that > test, btw; so far it is still just a mysterious SIGSEGV.) > > > r~ > > > Richard Henderson (7): > target/arm: Introduce KVMID_AA64_SYS_REG64 > target/arm: Move compare_u64 to helper.c > target/arm/hvf: Split out sysreg.c.inc > target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID > target/arm/hvf: Remove hvf_sreg_match.key > target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list > target/arm/hvf: Sort the cpreg_indexes array > > target/arm/cpregs.h | 3 + > target/arm/kvm-consts.h | 11 ++ > target/arm/helper.c | 11 ++ > target/arm/hvf/hvf.c | 230 +++++++++--------------------------- > target/arm/kvm.c | 11 -- > target/arm/hvf/sysreg.c.inc | 146 +++++++++++++++++++++++ > 6 files changed, 224 insertions(+), 188 deletions(-) > create mode 100644 target/arm/hvf/sysreg.c.inc > > -- > 2.43.0 > I noted the issue with HV_SYS_REG_MDCR_EL2, but assume we'll fix it down the line. For the series: Reviewed-by: Mads Ynddal <mads@ynddal.dk> ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-09-02 13:41 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-08-18 4:13 [PATCH 0/7] target/arm/hvf cleanups Richard Henderson 2025-08-18 4:13 ` [PATCH 1/7] target/arm: Introduce KVMID_AA64_SYS_REG64 Richard Henderson 2025-08-18 4:13 ` [PATCH 2/7] target/arm: Move compare_u64 to helper.c Richard Henderson 2025-08-18 6:12 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 3/7] target/arm/hvf: Split out sysreg.c.inc Richard Henderson 2025-08-18 6:13 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 4/7] target/arm/hvf: Add KVMID_TO_HVF, HVF_TO_KVMID Richard Henderson 2025-08-18 12:41 ` Philippe Mathieu-Daudé 2025-08-18 13:21 ` Richard Henderson 2025-08-18 15:46 ` Philippe Mathieu-Daudé 2025-08-18 18:37 ` Danny Canter 2025-09-01 15:02 ` Philippe Mathieu-Daudé 2025-09-02 13:40 ` Richard Henderson 2025-08-18 4:13 ` [PATCH 5/7] target/arm/hvf: Remove hvf_sreg_match.key Richard Henderson 2025-08-18 6:15 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 6/7] target/arm/hvf: Replace hvf_sreg_match with hvf_sreg_list Richard Henderson 2025-08-18 6:17 ` Philippe Mathieu-Daudé 2025-08-18 4:13 ` [PATCH 7/7] target/arm/hvf: Sort the cpreg_indexes array Richard Henderson 2025-08-18 6:18 ` Philippe Mathieu-Daudé 2025-08-18 12:25 ` [PATCH 0/7] target/arm/hvf cleanups Philippe Mathieu-Daudé 2025-08-20 11:52 ` Mads Ynddal
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).