Skip to content
Permalink
Browse files

arch: arm: allocate a wide stack guard for FP-capable threads

When an FP capable thread is created (i.e. with K_FP_REGS
option) we want to allocate a wider MPU stack guard region,
to be able to successfully detect stack overflows. For that
we also need to re-adjust the values that will be passed to
the thread's stack_info .start and .size parameters.

applicable) for a thread which intends to use the FP services.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information...
ioannisg authored and andrewboie committed May 28, 2019
1 parent eefea9d commit 1ef7a858a04863344edad5adb697c29b3fa9be61
Showing with 18 additions and 0 deletions.
  1. +18 −0 arch/arm/core/thread.c
@@ -94,6 +94,24 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
*/
stackSize -= MPU_GUARD_ALIGN_AND_SIZE;
#endif

#if defined(CONFIG_FLOAT) && defined(CONFIG_FP_SHARING) \
&& defined(CONFIG_MPU_STACK_GUARD)
/* For a thread which intends to use the FP services, it is required to
* allocate a wider MPU guard region, to always successfully detect an
* overflow of the stack.
*
* Note that the wider MPU regions requires re-adjusting the stack_info
* .start and .size.
*
*/
if ((options & K_FP_REGS) != 0) {
pStackMem += MPU_GUARD_ALIGN_AND_SIZE_FLOAT
- MPU_GUARD_ALIGN_AND_SIZE;
stackSize -= MPU_GUARD_ALIGN_AND_SIZE_FLOAT
- MPU_GUARD_ALIGN_AND_SIZE;
}
#endif
stackEnd = pStackMem + stackSize;

struct __esf *pInitCtx;

0 comments on commit 1ef7a85

Please sign in to comment.
You can’t perform that action at this time.