arch: arm: cortex-m: fix PSPLIM configuring in context-switch
When configuring the built-in stack guard, via setting the PSPLIM register, during thread context-switch, we shall only set PSPLIM to "guard" the thread's privileged stack area when the thread is actually using it (PSP is on this stack). Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
16ce4b6953
commit
a5ecd71163
1 changed files with 11 additions and 3 deletions
|
@ -208,7 +208,15 @@ void configure_builtin_stack_guard(struct k_thread *thread)
|
|||
__set_PSPLIM(0);
|
||||
return;
|
||||
}
|
||||
u32_t guard_start = thread->arch.priv_stack_start ?
|
||||
/* Only configure PSPLIM to guard the privileged stack area, if
|
||||
* the thread is currently using it, otherwise guard the default
|
||||
* thread stack. Note that the conditional check relies on the
|
||||
* thread privileged stack being allocated in higher memory area
|
||||
* than the default thread stack (ensured by design).
|
||||
*/
|
||||
u32_t guard_start =
|
||||
((thread->arch.priv_stack_start) &&
|
||||
(__get_PSP() >= thread->arch.priv_stack_start)) ?
|
||||
(u32_t)thread->arch.priv_stack_start :
|
||||
(u32_t)thread->stack_obj;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue