Build: Add option CONFIG_TFM_ENABLE_FPU
Add CONFIG_TFM_ENABLE_FPU for enabling the FPU coprocessors when either
or both of the SPE and the NSPE needs to operate the FPU. On an Armv8-M
platform with TrustZone, this option also enables Non-Secure access to
the FPU.
The motivation of this new option is that in the TrustZone architecture,
both the SPE and NSPE must enable the FPU consistently. If one of the
processing environments has the FPU coprocessors enabled and the other
has not, then a context switch (e.g. an interrupt) that happens during
a cross-environment call will trigger a NOCP (No coprocessor) usage
fault, if CONTROL.FPCA==1 (floating point context active). This fault
happens because CONTROL.FPCA is not banked, and the system see a
contradiction if the current side does not have the FPU enabled but
the floating point context (FPCA) has been set as active by the other
side.
CONFIG_TFM_FP=hard, which enables floating point instructions and the
hard float ABI, depends on CONFIG_TFM_ENABLE_FPU=ON as the FPU is used.
Therefore a dependency check has been added.
For a user of TF-M, setting CONFIG_TFM_ENABLE_FPU=ON while leaving
CONFIG_TFM_FP=soft (default) enables the FPU coprocessors but keeps
the TF-M SPE to be without any floating point operations. The user's
Non-Secure application is allowed to operate the FPU as needed.
Note: If the SPE operates the FPU (CONFIG_TFM_FP=hard), the compiler
support for patching the CVE-2021-35465 (VLLDM instruction security)
vulnerability is required for FPU context protection. If the NSPE is
the only side that operates the FPU, then the FPU context protection
can be skipped as the SPE does not touch the floating point registers
anyway.
Change-Id: I20c80f3d86087585bc569a1bfa183c7c22220c09
Signed-off-by: Lingkai Dong <lingkai.dong@arm.com>
diff --git a/docs/integration_guide/tfm_fpu_support.rst b/docs/integration_guide/tfm_fpu_support.rst
index 09f826b..df6cdca 100644
--- a/docs/integration_guide/tfm_fpu_support.rst
+++ b/docs/integration_guide/tfm_fpu_support.rst
@@ -24,6 +24,12 @@
Please refer to Arm musca S1 [7]_ platform as a reference implementation when
you enable FP support on your platforms.
+.. Note::
+ Alternatively, if you intend to use FP in your own NSPE application but the
+ TF-M SPE services that you enable do not require FP, you can set the CMake
+ configuration ``CONFIG_TFM_ENABLE_FPU`` to ``ON`` and **ignore** any
+ configurations described below.
+
============================
FP ABI type for SPE and NSPE
============================
@@ -65,6 +71,12 @@
FP software ABI type is default in TF-M.
+.. Note::
+ If you build TF-M SPE with ``CONFIG_TFM_FP=hard`` and provide your own NSPE
+ application, your own NSPE **must** take care of enabling floating point
+ coprocessors CP10 and CP11 on the NS side to avoid aforementioned NOCP usage
+ fault.
+
* ``CONFIG_TFM_LAZY_STACKING`` is used to enable/disable lazy stacking
feature. This feature is only valid for FP hardware ABI type.
NSPE is not allowed to enable/disable this feature. Let SPE decide the