We shouldn't be reading SCR_EL3 unless ARM_FEATURE_EL3 is enabled for
this system. If it is not there cannot be any offset so just return 0.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
---
 target/arm/helper.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 22f5117ee54..8946d2aad28 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1413,6 +1413,10 @@ void gt_rme_post_el_change(ARMCPU *cpu, void *ignored)
 
 static uint64_t gt_phys_raw_cnt_offset(CPUARMState *env)
 {
+    if (!arm_feature(env, ARM_FEATURE_EL3)) {
+        return 0;
+    }
+
     if ((env->cp15.scr_el3 & SCR_ECVEN) &&
         FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, ECV) &&
         arm_is_el2_enabled(env) &&
-- 
2.47.3


Reply via email to