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,9 +208,17 @@ void configure_builtin_stack_guard(struct k_thread *thread)
|
||||||
__set_PSPLIM(0);
|
__set_PSPLIM(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
u32_t guard_start = thread->arch.priv_stack_start ?
|
/* Only configure PSPLIM to guard the privileged stack area, if
|
||||||
(u32_t)thread->arch.priv_stack_start :
|
* the thread is currently using it, otherwise guard the default
|
||||||
(u32_t)thread->stack_obj;
|
* 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;
|
||||||
|
|
||||||
__ASSERT(thread->stack_info.start == ((u32_t)thread->stack_obj),
|
__ASSERT(thread->stack_info.start == ((u32_t)thread->stack_obj),
|
||||||
"stack_info.start does not point to the start of the"
|
"stack_info.start does not point to the start of the"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue