mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/arm: SCR_EL3.RW should be treated as 1 if EL2 doesn't support AArch32
The definition of SCR_EL3.RW says that its effective value is 1 if: - EL2 is implemented and does not support AArch32, and SCR_EL3.NS is 1 - the effective value of SCR_EL3.{EEL2,NS} is {1,0} (i.e. we are Secure and Secure EL2 is disabled) We implement the second of these in arm_el_is_aa64(), but forgot the first. Provide a new function arm_scr_rw_eff() to return the effective value of SCR_EL3.RW, and use it in arm_el_is_aa64() and the other places that currently look directly at the bit value. (scr_write() enforces that the RW bit is RAO/WI if neither EL1 nor EL2 have AArch32 support, but if EL1 does but EL2 does not then the bit must still be writeable.) This will mean that if code at EL3 attempts to perform an exception return to AArch32 EL2 when EL2 is AArch64-only we will correctly handle this as an illegal exception return: it will be caught by the "return to an EL which is configured for a different register width" check in HELPER(exception_return). We do already have some CPU types which don't implement AArch32 above EL0, so this is technically a bug; it doesn't seem worth backporting to stable because no sensible guest code will be deliberately attempting to set the RW bit to a value corresponding to an unimplemented execution state and then checking that we did the right thing. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
2beb051191
commit
5d71c6820f
2 changed files with 25 additions and 5 deletions
|
@ -392,6 +392,27 @@ static inline FloatRoundMode arm_rmode_to_sf(ARMFPRounding rmode)
|
|||
return arm_rmode_to_sf_map[rmode];
|
||||
}
|
||||
|
||||
/* Return the effective value of SCR_EL3.RW */
|
||||
static inline bool arm_scr_rw_eff(CPUARMState *env)
|
||||
{
|
||||
/*
|
||||
* SCR_EL3.RW has an effective value of 1 if:
|
||||
* - we are NS and EL2 is implemented but doesn't support AArch32
|
||||
* - we are S and EL2 is enabled (in which case it must be AArch64)
|
||||
*/
|
||||
ARMCPU *cpu = env_archcpu(env);
|
||||
|
||||
if (env->cp15.scr_el3 & SCR_RW) {
|
||||
return true;
|
||||
}
|
||||
if (env->cp15.scr_el3 & SCR_NS) {
|
||||
return arm_feature(env, ARM_FEATURE_EL2) &&
|
||||
!cpu_isar_feature(aa64_aa32_el2, cpu);
|
||||
} else {
|
||||
return env->cp15.scr_el3 & SCR_EEL2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return true if the specified exception level is running in AArch64 state. */
|
||||
static inline bool arm_el_is_aa64(CPUARMState *env, int el)
|
||||
{
|
||||
|
@ -411,9 +432,8 @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
|
|||
return aa64;
|
||||
}
|
||||
|
||||
if (arm_feature(env, ARM_FEATURE_EL3) &&
|
||||
((env->cp15.scr_el3 & SCR_NS) || !(env->cp15.scr_el3 & SCR_EEL2))) {
|
||||
aa64 = aa64 && (env->cp15.scr_el3 & SCR_RW);
|
||||
if (arm_feature(env, ARM_FEATURE_EL3)) {
|
||||
aa64 = aa64 && arm_scr_rw_eff(env);
|
||||
}
|
||||
|
||||
if (el == 2) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue