Skip to content

Commit

Permalink
target/arm: Catch illegal-exception-return from EL3 with bad NSE/NS
Browse files Browse the repository at this point in the history
The architecture requires (R_TYTWB) that an attempt to return from EL3
when SCR_EL3.{NSE,NS} are {1,0} is an illegal exception return. (This
enforces that the CPU can't ever be executing below EL3 with the
NSE,NS bits indicating an invalid security state.)

We were missing this check; add it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230807150618.101357-1-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Aug 31, 2023
1 parent 12517bc commit 35aa671
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions target/arm/tcg/helper-a64.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,15 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
spsr &= ~PSTATE_SS;
}

/*
* FEAT_RME forbids return from EL3 with an invalid security state.
* We don't need an explicit check for FEAT_RME here because we enforce
* in scr_write() that you can't set the NSE bit without it.
*/
if (cur_el == 3 && (env->cp15.scr_el3 & (SCR_NS | SCR_NSE)) == SCR_NSE) {
goto illegal_return;
}

new_el = el_from_spsr(spsr);
if (new_el == -1) {
goto illegal_return;
Expand Down

0 comments on commit 35aa671

Please sign in to comment.