target/arm: Only evaluate SCR_EL3.PIEN if ARM_FEATURE_EL3 is present
Running KVM with (as of writing, out-of-tree) support for FEAT_S2PIE on -cpu max gets stuck in an infinite loop of stage-2 permission faults due to the PTW incorrectly using an effective value of 0 for S2PIR_EL2. Similar to how S1PIE is handled, only use the IMPLEMENTATION SPECIFIC value of 0 for S2PIR_EL2 if EL3 is implemented and PIEN=0. Cc: qemu-stable@nongnu.org Fixes: a811c5dafb ("target/arm: Implement get_S2prot_indirect") Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Oliver Upton <oupton@kernel.org> Message-id: 20260626231738.947317-1-oupton@kernel.org [PMM: removed hardcoded tab] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Oliver Upton committed
Jun 26, 2026 at 16:17 UTC
d77a93ca4b53da18ce01c5b7678e0eb435851919
1 file changed
+7
-2
target/arm/ptw.c
+7
-2
@@ -1490,9 +1490,14 @@ static int get_S2prot_indirect(CPUARMState *env, GetPhysAddrResult *result,
1490
PAGE_READ | PAGE_WRITE },
1491
};
1492
1493
- uint64_t pir = (env->cp15.scr_el3 & SCR_PIEN ? env->cp15.s2pir_el2 : 0);
1494
- int s2pi = extract64(pir, pi_index * 4, 4);
1493
+ uint64_t pir = env->cp15.s2pir_el2;
1494
+ int s2pi;
1495
1496
+ if (arm_feature(env, ARM_FEATURE_EL3) && !(env->cp15.scr_el3 & SCR_PIEN)) {
1497
+ pir = 0;
1498
+ }
1499
+
1500
+ s2pi = extract64(pir, pi_index * 4, 4);
1501
result->f.prot = perm_table[s2pi][2];
1502
return perm_table[s2pi][s1_is_el0];
1503
}