blob: 71dbc87221d3eafc5351c9deeb74dea4c645d530 [file] [log] [blame]
Feder Liang4f7c75b2021-09-14 16:15:15 +08001######################
2Floating-Point Support
3######################
4
5TF-M adds several configuration flags to control Floating point (FP) [1]_
Feder Liang8ac672f2021-12-09 15:03:04 +08006support in TF-M Secure Processing Environment (SPE) and Non Secure Processing
7Environment (NSPE).
Feder Liang4f7c75b2021-09-14 16:15:15 +08008
Feder Liang8ac672f2021-12-09 15:03:04 +08009* Support FP in SPE or NSPE.
10* Support FP Application Binary Interface (ABI) [2]_ types: software, hardware.
11 SPE and NSPE shall use the same FP ABI type.
12* Support lazy stacking enable/disable in SPE only, NSPE is not allowed to
13 enable/disable this feature.
14* Support GNU Arm Embedded Toolchain [3]_. ``GNU Arm Embedded Toolchain 10.3-
15 2021.10`` and later version shall be used to mitigate VLLDM instruction
16 security vulnerability [4]_.
Feder Liang4f7c75b2021-09-14 16:15:15 +080017* Support Inter-Process Communication (IPC) [5]_ model in TF-M, and doesn't
Summer Qin2db78c82022-10-10 17:17:44 +080018 support SFN model.
Gabor Toth4d414112021-11-10 17:44:50 +010019* Support Armv8-M mainline.
Feder Liang4f7c75b2021-09-14 16:15:15 +080020* Support isolation level 1,2,3.
chesun01305757f2023-02-21 14:19:24 +080021* Support Arm Compiler for Embedded [10]_. ``Arm Compiler for Embedded 6.17``
22 and later version shall be used to mitigate VLLDM instruction security
23 vulnerability [4]_.
Feder Liang8ac672f2021-12-09 15:03:04 +080024* Does not support use FPU in First-Level Interrupt Handling (FLIH) [6]_ at
Feder Liang98e77a82021-11-25 14:34:23 +080025 current stage.
Feder Liang4f7c75b2021-09-14 16:15:15 +080026
Jianliang Shen47d21e52022-08-02 14:36:00 +080027Please refer to Arm AN521 or AN552 platform as a reference implementation when
Feder Liang98e77a82021-11-25 14:34:23 +080028you enable FP support on your platforms.
Feder Liang4f7c75b2021-09-14 16:15:15 +080029
Lingkai Dong181c00c2022-04-25 11:36:34 +010030.. Note::
31 Alternatively, if you intend to use FP in your own NSPE application but the
32 TF-M SPE services that you enable do not require FP, you can set the CMake
Gabor Toth4d414112021-11-10 17:44:50 +010033 configuration ``CONFIG_TFM_ENABLE_CP10CP11`` to ``ON`` and **ignore** any
Lingkai Dong181c00c2022-04-25 11:36:34 +010034 configurations described below.
35
Xinyu Zhang8ec30632022-06-30 18:03:31 +080036.. Note::
Jianliang Shen47d21e52022-08-02 14:36:00 +080037 FPU test issue has not been fixed yet on Musca-S1 [7]_. When running FPU
38 tests on Musca-S1, secure thread fails to trigger secure interrupt. FPU test
39 is disabled by default on Musca-S1 until the issue is fixed.
40
41.. Note::
Xinyu Zhang8ec30632022-06-30 18:03:31 +080042 ``GNU Arm Embedded Toolchain 10.3-2021.10`` may have issue that reports
43 ``'-mcpu=cortex-m55' conflicts with '-march=armv8.1-m.main'`` warning [8]_.
44 This issue has been fixed in the later version.
45
Feder Liang8ac672f2021-12-09 15:03:04 +080046============================
47FP ABI type for SPE and NSPE
48============================
Xinyu Zhang8ec30632022-06-30 18:03:31 +080049FP design in Armv8.0-M [9]_ architecture requires consistent FP ABI types
Feder Liang8ac672f2021-12-09 15:03:04 +080050between SPE and NSPE. Furthermore, both sides shall set up CPACR individually
51when FPU is used. Otherwise, No Coprocessor (NOCP) usage fault will be asserted
52during FP context switch between security states.
53
54Secure and non-secure libraries are compiled with ``COMPILER_CP_FLAG`` and
55linked with ``LINKER_CP_OPTION`` for different FP ABI types. All those
56libraries shall be built with ``COMPLIER_CP_FLAG``.
Feder Liang4f7c75b2021-09-14 16:15:15 +080057
58If FP ABI types mismatch error is generated during build, pleae check whether
59the library is compiled with ``COMPILER_CP_FLAG``.
60Example:
61
62.. code-block:: cmake
63
64 target_compile_options(lib
65 PRIVATE
66 ${COMPILER_CP_FLAG}
67 )
68
69===================================
70CMake configurations for FP support
71===================================
72The following CMake configurations configure ``COMPILER_CP_FLAG`` in TF-M SPE.
73
Gabor Toth4d414112021-11-10 17:44:50 +010074* ``CONFIG_TFM_ENABLE_FP`` is used to enable/disable FPU usage.
Feder Liang4f7c75b2021-09-14 16:15:15 +080075
Gabor Toth4d414112021-11-10 17:44:50 +010076 +--------------------------+---------------------------+
77 | CONFIG_TFM_ENABLE_FP | FP support |
78 +==========================+===========================+
chesun01305757f2023-02-21 14:19:24 +080079 | off (default) | FP disabled |
Gabor Toth4d414112021-11-10 17:44:50 +010080 +--------------------------+---------------------------+
81 | on | FP enabled |
82 +--------------------------+---------------------------+
Feder Liang4f7c75b2021-09-14 16:15:15 +080083
Lingkai Dong181c00c2022-04-25 11:36:34 +010084.. Note::
Gabor Toth4d414112021-11-10 17:44:50 +010085 ``CONFIG_TFM_FLOAT_ABI`` depends on ``CONFIG_TFM_ENABLE_FP``. If
86 ``CONFIG_TFM_ENABLE_FP is set ``CONFIG_TFM_FLOAT_ABI`` is automatically
87 set to ``hard``.
88
89.. Note::
90 If you build TF-M SPE with ``CONFIG_TFM_ENABLE_FP=on`` and provide your own
91 NSPE application, your own NSPE **must** take care of enabling floating point
Lingkai Dong181c00c2022-04-25 11:36:34 +010092 coprocessors CP10 and CP11 on the NS side to avoid aforementioned NOCP usage
93 fault.
94
Feder Liang8ac672f2021-12-09 15:03:04 +080095* ``CONFIG_TFM_LAZY_STACKING`` is used to enable/disable lazy stacking
96 feature. This feature is only valid for FP hardware ABI type.
97 NSPE is not allowed to enable/disable this feature. Let SPE decide the
98 secure/non-secure shared setting of lazy stacking to avoid the possible
99 side-path brought by flexibility.
Feder Liang4f7c75b2021-09-14 16:15:15 +0800100
101 +------------------------------+---------------------------+
Feder Liang8ac672f2021-12-09 15:03:04 +0800102 | CONFIG_TFM_LAZY_STACKING | Description |
Feder Liang4f7c75b2021-09-14 16:15:15 +0800103 +==============================+===========================+
104 | 0FF | Disable lazy stacking |
105 +------------------------------+---------------------------+
106 | ON (default) | Enable lazy stacking |
107 +------------------------------+---------------------------+
108
109* ``CONFIG_TFM_FP_ARCH`` specifies which FP architecture is available on the
Feder Liang8ac672f2021-12-09 15:03:04 +0800110 target, valid for FP hardware ABI type.
Feder Liang4f7c75b2021-09-14 16:15:15 +0800111
112 FP architecture is processor dependent. For GNUARM compiler, example value
chesun01305757f2023-02-21 14:19:24 +0800113 are: auto, fpv5-d16, fpv5-sp-d16, etc. For armclang, example value are: none,
114 softvfp, fpv5-d16, fpv5-sp-d16, etc.
Feder Liang4f7c75b2021-09-14 16:15:15 +0800115
Joakim Andersson92309262023-02-08 14:41:14 +0100116 This parameter shall be specified by platform in preload.cmake. Please check
117 compiler reference manual and processor hardware manual for more details to
118 set correct FPU configuration for platform.
Feder Liang4f7c75b2021-09-14 16:15:15 +0800119
chesun01305757f2023-02-21 14:19:24 +0800120* ``CONFIG_TFM_FP_ARCH_ASM`` specifies the target FPU architecture name shared
121 by Arm Compiler armasm and armlink. It is only used in the ``--fpu=`` argument
122 by Arm Compiler and shall be aligned with ``CONFIG_TFM_FP_ARCH``.
123
124 FP architecture is processor dependent. For armasm and armlink, example value
125 are: SoftVFP, FPv5_D16, etc.
126
127 This parameter shall be specified by platform in preload.cmake. Please check
128 compiler reference manual and processor hardware manual for more details to
129 set correct FPU configuration for platform.
Feder Liang4f7c75b2021-09-14 16:15:15 +0800130
131*********
132Reference
133*********
134.. [1] `High-Performance Hardware Support for Floating-Point Operations <https://www.arm.com/why-arm/technologies/floating-point>`_
135
Feder Liang8ac672f2021-12-09 15:03:04 +0800136.. [2] `Float Point ABI <https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_chr1417451577871.htm>`_
Feder Liang4f7c75b2021-09-14 16:15:15 +0800137
138.. [3] `GNU Arm Embedded Toolchain <https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm>`_
139
Feder Liang8ac672f2021-12-09 15:03:04 +0800140.. [4] `VLLDM instruction Security Vulnerability <https://developer.arm.com/support/arm-security-updates/vlldm-instruction-security-vulnerability>`_
Feder Liang4f7c75b2021-09-14 16:15:15 +0800141
Feder Liang8ac672f2021-12-09 15:03:04 +0800142.. [5] `ArmĀ® Platform Security Architecture Firmware Framework 1.0 <https://armkeil.blob.core.windows.net/developer/Files/pdf/PlatformSecurityArchitecture/Architect/DEN0063-PSA_Firmware_Framework-1.0.0-2.pdf>`_
Feder Liang4f7c75b2021-09-14 16:15:15 +0800143
Anton Komlev3356ba32022-03-31 22:02:11 +0100144.. [6] :doc:`Secure Interrupt Integration Guide </integration_guide/tfm_secure_irq_integration_guide>`
Feder Liang4f7c75b2021-09-14 16:15:15 +0800145
Feder Liang8ac672f2021-12-09 15:03:04 +0800146.. [7] `Musca-S1 Test Chip Board <https://developer.arm.com/tools-and-software/development-boards/iot-test-chips-and-boards/musca-s1-test-chip-board>`_
Feder Liang98e77a82021-11-25 14:34:23 +0800147
Xinyu Zhang8ec30632022-06-30 18:03:31 +0800148.. [8] `GCC Issue on '-mcpu=cortex-m55' conflicts with '-march=armv8.1-m.main' Warning <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97327>`_
149
150.. [9] `Armv8-M Architecture Reference Manual <https://developer.arm.com/documentation/ddi0553/latest>`_
Feder Liang4f7c75b2021-09-14 16:15:15 +0800151
chesun01305757f2023-02-21 14:19:24 +0800152.. [10] `Arm Compiler for Embedded <https://developer.arm.com/Tools%20and%20Software/Arm%20Compiler%20for%20Embedded>`_
153
Feder Liang4f7c75b2021-09-14 16:15:15 +0800154--------------
155
Xinyu Zhang8ec30632022-06-30 18:03:31 +0800156*Copyright (c) 2021-2022, Arm Limited. All rights reserved.*