Skip to content
Browse files

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

When an FP capable thread (i.e. with K_FP_REGS option)
transitions into user mode, we want to allocate a wider
MPU stack guard region, to be able to successfully detect
overflows of the privilege stack during system calls. For
that we also need to re-adjust the .priv_stack_start pointer,
which denotes the start of the writable area of the privilege
stack buffer.

Signed-off-by: Ioannis Glaropoulos <>
  • Loading branch information...
ioannisg authored and andrewboie committed Jun 18, 2019
1 parent 1ef7a85 commit 6a9b3f5ddd30123c1474e1cacb9075d5d0273e07
Showing with 6 additions and 0 deletions.
  1. +6 −0 arch/arm/core/thread.c
@@ -180,7 +180,13 @@ FUNC_NORETURN void z_arch_user_mode_enter(k_thread_entry_t user_entry,
* privileged stack. Adjust the available (writable) stack
* buffer area accordingly.
#if defined(CONFIG_FLOAT) && defined(CONFIG_FP_SHARING)
_current->arch.priv_stack_start +=
(_current->base.user_options & K_FP_REGS) ?
_current->arch.priv_stack_start += MPU_GUARD_ALIGN_AND_SIZE;

z_arm_userspace_enter(user_entry, p1, p2, p3,

0 comments on commit 6a9b3f5

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