From: Alex Bennée <[email protected]> Toggling the HCR state affects the offset calculated in gt_phys_raw_cnt_offset so we should trigger a re-calculation on its change.
Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]> --- target/arm/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 20165dbf48..93e3d8b575 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3716,6 +3716,7 @@ static const ARMCPRegInfo v8_aa32_el1_reginfo[] = { static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) { ARMCPU *cpu = env_archcpu(env); + bool hcr_change_timer; if (arm_feature(env, ARM_FEATURE_V8)) { valid_mask |= MAKE_64BIT_MASK(0, 34); /* ARMv8.0 */ @@ -3807,6 +3808,10 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) (HCR_VM | HCR_PTW | HCR_DC | HCR_DCT | HCR_FWB | HCR_NV | HCR_NV1)) { tlb_flush(CPU(cpu)); } + hcr_change_timer = (env->cp15.hcr_el2 ^ value) & + (HCR_E2H | HCR_TGE); + + /* update */ env->cp15.hcr_el2 = value; /* @@ -3828,6 +3833,11 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) arm_cpu_update_vinmi(cpu); arm_cpu_update_vfnmi(cpu); } + if (hcr_change_timer) { +#ifndef CONFIG_USER_ONLY + gt_recalc_timer(cpu, GTIMER_PHYS); +#endif + } } static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) -- 2.43.0
