]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
target/arm: fix crash on pmu register access
authorAndrew Jones <drjones@redhat.com>
Mon, 25 Mar 2019 14:16:47 +0000 (14:16 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 25 Mar 2019 14:16:47 +0000 (14:16 +0000)
Fix a QEMU NULL derefence that occurs when the guest attempts to
enable PMU counters with a non-v8 cpu model or a v8 cpu model
which has not configured a PMU.

Fixes: 4e7beb0cc0f3 ("target/arm: Add a timer to predict PMU counter overflow")
Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20190322162333.17159-2-drjones@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target/arm/helper.c

index c8d3c213b6b748bcfbb306c9807ae655c19cb357..fc73488f6cc0606859ce2558e36e5d9360f744b7 100644 (file)
@@ -1259,6 +1259,10 @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
     int el = arm_current_el(env);
     uint8_t hpmn = env->cp15.mdcr_el2 & MDCR_HPMN;
 
+    if (!arm_feature(env, ARM_FEATURE_PMU)) {
+        return false;
+    }
+
     if (!arm_feature(env, ARM_FEATURE_EL2) ||
             (counter < hpmn || counter == 31)) {
         e = env->cp15.c9_pmcr & PMCRE;