Skip to content
Browse files

arch: arm: update thread options flag and CONTROL atomically

Under FP shared registers mode (CONFIG_FP_SHARING=y),
a thread's user_options flag is checked during swap and
during stack fail check. Therefore, in k_float_disable()
we want to ensure that a thread won't be swapped-out with
K_FP_REGS flag cleared but still FP-active (CONTROL.FPCA
being not zero). To ensure that we temporarily disable

Signed-off-by: Ioannis Glaropoulos <>
  • Loading branch information...
ioannisg authored and andrewboie committed Jun 18, 2019
1 parent f70093a commit 171272cf312cde3011f212d495fcca4c683f6327
Showing with 14 additions and 0 deletions.
  1. +14 −0 arch/arm/core/thread.c
@@ -351,9 +351,23 @@ int z_arch_float_disable(struct k_thread *thread)

/* Disable all floating point capabilities for the thread */

/* K_FP_REG flag is used in SWAP and stack check fail. Locking
* interrupts here prevents a possible context-switch or MPU
* fault to take an outdated thread user_options flag into
* account.
int key = z_arch_irq_lock();

thread->base.user_options &= ~K_FP_REGS;

__set_CONTROL(__get_CONTROL() & (~CONTROL_FPCA_Msk));

/* No need to add an ISB barrier after setting the CONTROL
* register; z_arch_irq_unlock() already adds one.


return 0;

0 comments on commit 171272c

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