mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 08:15:37 +00:00
target/arm: fix crash on pmu register access
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. Backports commit cbbb3041fe2f57a475cef5d6b0ef836118aad106 from qemu
This commit is contained in:
parent
2427ace0c0
commit
3c50e72c40
|
@ -1117,6 +1117,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;
|
||||
|
|
Loading…
Reference in a new issue