diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-10-08 14:55:04 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-10-08 14:55:04 +0100 |
commit | 5520318939fea5d659bf808157cd726cb967b761 (patch) | |
tree | 4f3e000a0fcf84469fda89278cba5fcd7d5d4361 /target/arm/internals.h | |
parent | 5529bf188d996391ff52a0e1801daf9c6a6bfcb0 (diff) |
target/arm: Add v8M stack checks on ADD/SUB/MOV of SP
Add code to insert calls to a helper function to do the stack
limit checking when we handle these forms of instruction
that write to SP:
* ADD (SP plus immediate)
* ADD (SP plus register)
* SUB (SP minus immediate)
* SUB (SP minus register)
* MOV (register)
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20181002163556.10279-5-peter.maydell@linaro.org
Diffstat (limited to 'target/arm/internals.h')
-rw-r--r-- | target/arm/internals.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/target/arm/internals.h b/target/arm/internals.h index 2495681435..bb5a63d6fe 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -817,4 +817,18 @@ static inline bool v7m_using_psp(CPUARMState *env) env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK; } +/** + * v7m_sp_limit: Return SP limit for current CPU state + * Return the SP limit value for the current CPU security state + * and stack pointer. + */ +static inline uint32_t v7m_sp_limit(CPUARMState *env) +{ + if (v7m_using_psp(env)) { + return env->v7m.psplim[env->v7m.secure]; + } else { + return env->v7m.msplim[env->v7m.secure]; + } +} + #endif |