target/arm: fix incorrect current EL bug in aarch32 exception emulation
PATCH 1/1 target/arm: fix incorrect current EL bug in aarch32 exception emulation
The arm_current_el() should be invoked after mode switching. Otherwise, we get a wrong current EL value, since current EL is also determined by current mode.
--- target/arm/helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
target/arm/helper.c +4 -1
@@ -9172,7 +9172,6 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,/* Change the CPU state so as to actually take the exception. */ switch_mode (env, new_mode); - new_el =arm_current_el (env);/* * For exceptions taken to AArch32 we must clear the SS bit in both
@@ -9184,6 +9183,10 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->condexec_bits =0 ;/* Switch to the new mode, and to the correct instruction set. */ env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; + +/* This must be after mode switching. */ + new_el =arm_current_el (env); +/* Set new mode endianness */ env->uncached_cpsr &= ~CPSR_E ;if (env->cp15.sctlr_el[new_el] &SCTLR_EE ) {
Signature · 1 line
2.25.1
Quoted 9 lines · Changbin Du
The
arm_current_el()should be invoked after mode switching. Otherwise, we get a wrong current EL value, since current EL is also determined by current mode.Fixes 4a2696c0d4 ("target/arm: Set PAN bit as required on exception entry")Signed-off-by Changbin Du <[email protected]>--- target/arm/helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
r~
Hi, Peter,
Could you take this fix as high priority? This bug has made qemu-system-arm broken.
Quoted 36 lines · Changbin Du
The
arm_current_el()should be invoked after mode switching. Otherwise, we get a wrong current EL value, since current EL is also determined by current mode.Fixes 4a2696c0d4 ("target/arm: Set PAN bit as required on exception entry")Signed-off-by Changbin Du <[email protected]>--- target/arm/helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)target/arm/helper.c +4
-1@@ -9172,7 +9172,6 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,/* Change the CPU state so as to actually take the exception. */ switch_mode (env, new_mode); - new_el =arm_current_el (env);/* * For exceptions taken to AArch32 we must clear the SS bit in both @@ -9184,6 +9183,10 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->condexec_bits =0 ;/* Switch to the new mode, and to the correct instruction set. */ env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; + +/* This must be after mode switching. */ + new_el =arm_current_el (env); +/* Set new mode endianness */ env->uncached_cpsr &= ~CPSR_E ;if (env->cp15.sctlr_el[new_el] &SCTLR_EE ) {Signature · 1 line
2.25.1
Signature · 2 lines
Cheers, Changbin Du
Peter Maydell
AppliedQuoted 35 lines · Changbin Du
The
arm_current_el()should be invoked after mode switching. Otherwise, we get a wrong current EL value, since current EL is also determined by current mode.Fixes 4a2696c0d4 ("target/arm: Set PAN bit as required on exception entry")Signed-off-by Changbin Du <[email protected]>--- target/arm/helper.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)target/arm/helper.c +4
-2@@ -9172,7 +9172,6 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,/* Change the CPU state so as to actually take the exception. */ switch_mode (env, new_mode); - new_el =arm_current_el (env);/* * For exceptions taken to AArch32 we must clear the SS bit in both @@ -9184,6 +9183,10 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->condexec_bits =0 ;/* Switch to the new mode, and to the correct instruction set. */ env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; + +/* This must be after mode switching. */ + new_el =arm_current_el (env); +/* Set new mode endianness */ env->uncached_cpsr &= ~CPSR_E ;if (env->cp15.sctlr_el[new_el] &SCTLR_EE ) { --
Quoted 1 line
2.25.1
Applied to target-arm.next, thanks.
-- PMM