Skip to content
Permalink
Browse files

arch: arm: drop FP full-access for builds without user mode

In ARM builds with FP services (CONFIG_FLOAT=y) but without user
mode support (CONFIG_USERSPACE=n) we do not need and should not
enable full-access to the FP co-processor. Instead, we should
enabled access by privileged code only.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information...
ioannisg authored and nashif committed Apr 4, 2019
1 parent 8a4c131 commit dba1b12267a685998badadd15ea0522ae30f55ea
Showing with 8 additions and 1 deletion.
  1. +8 −1 arch/arm/core/cortex_m/prep_c.c
@@ -119,9 +119,16 @@ static inline void enable_floating_point(void)
{
/*
* Upon reset, the Co-Processor Access Control Register is 0x00000000.
* Enable CP10 and CP11 co-processors to enable floating point.
* Enable CP10 and CP11 Co-Processors to enable access to floating
* point registers.
*/
#if defined(CONFIG_USERSPACE)
/* Full access */
SCB->CPACR |= CPACR_CP10_FULL_ACCESS | CPACR_CP11_FULL_ACCESS;
#else
/* Privileged access only */
SCB->CPACR |= CPACR_CP10_PRIV_ACCESS | CPACR_CP11_PRIV_ACCESS;
#endif /* CONFIG_USERSPACE */
/*
* Upon reset, the FPU Context Control Register is 0xC0000000
* (both Automatic and Lazy state preservation is enabled).

0 comments on commit dba1b12

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