Skip to content

Commit 86c1b57

Browse files
ioannisgnashif
authored andcommitted
arm: cortex_m: select by default FP sharing mode when using the FPU
For applications that make use of the FPU in cortex m, we enforce the FPU sharing registers mode, because the compiler, under certain optimization regimes, may use FP instructions and create FP context in any thread, so the unshared registers mode is not practically supported. In addition to that we force FPU_SHARING to depend on MULTITHREADING, as FPU sharing mode does not make sense outside the normal multi-threaded builds. Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent 2642eb2 commit 86c1b57

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

arch/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,22 @@ config FPU
764764

765765
config FPU_SHARING
766766
bool "FPU register sharing"
767-
depends on FPU
767+
depends on FPU && MULTITHREADING
768+
default y if ARM && ARMV7_M_ARMV8_M_FP
768769
help
769770
This option enables preservation of the hardware floating point registers
770771
across context switches to allow multiple threads to perform concurrent
771772
floating point operations.
772773

774+
Note that on Cortex-M processors with the floating point extension we
775+
enable by default the FPU register sharing mode, as some GCC compilers
776+
may activate a floating point context by generating FP instructions for
777+
any thread, and that context must be preserved when switching such
778+
threads in and out. The developers can still disable the FP sharing
779+
mode in their application projects, and switch to Unshared FP registers
780+
mode, if it is guaranteed that the image code does not generate FP
781+
instructions outside the single thread context that is allowed to do so.
782+
773783
endmenu
774784

775785
menu "Cache Options"

0 commit comments

Comments
 (0)