mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 08:45:36 +00:00
target/arm: Add v8M stack checks for MSR to SP_NS
Updating the NS stack pointer via MSR to SP_NS should include a check whether the new SP value is below the stack limit. No other kinds of update to the various stack pointer and limit registers via MSR should perform a check. Backports commit 167765f0739e4a108e8c2e2ff2f37917df5658f9 from qemu
This commit is contained in:
parent
76f521e6c3
commit
ff812cc152
|
@ -10202,11 +10202,23 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
|
||||||
* currently in handler mode or not, using the NS CONTROL.SPSEL.
|
* currently in handler mode or not, using the NS CONTROL.SPSEL.
|
||||||
*/
|
*/
|
||||||
bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK;
|
bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK;
|
||||||
|
bool is_psp = !arm_v7m_is_handler_mode(env) && spsel;
|
||||||
|
uint32_t limit;
|
||||||
|
|
||||||
if (!env->v7m.secure) {
|
if (!env->v7m.secure) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!arm_v7m_is_handler_mode(env) && spsel) {
|
|
||||||
|
limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false];
|
||||||
|
|
||||||
|
if (val < limit) {
|
||||||
|
CPUState *cs = CPU(arm_env_get_cpu(env));
|
||||||
|
|
||||||
|
cpu_restore_state(cs, GETPC(), true);
|
||||||
|
raise_exception(env, EXCP_STKOF, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_psp) {
|
||||||
env->v7m.other_ss_psp = val;
|
env->v7m.other_ss_psp = val;
|
||||||
} else {
|
} else {
|
||||||
env->v7m.other_ss_msp = val;
|
env->v7m.other_ss_msp = val;
|
||||||
|
|
Loading…
Reference in a new issue