Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 1 | ###################### |
| 2 | Floating-Point Support |
| 3 | ###################### |
| 4 | |
| 5 | TF-M adds several configuration flags to control Floating point (FP) [1]_ |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 6 | support in TF-M Secure Processing Environment (SPE) and Non Secure Processing |
| 7 | Environment (NSPE). |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 8 | |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 9 | * 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]_. |
Xinyu Zhang | 08cefc1 | 2023-11-21 17:12:24 +0800 | [diff] [blame] | 17 | * Support both IPC [5]_ and SFN [11]_ models in TF-M. |
Gabor Toth | 4d41411 | 2021-11-10 17:44:50 +0100 | [diff] [blame] | 18 | * Support Armv8-M mainline. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 19 | * Support isolation level 1,2,3. |
chesun01 | 305757f | 2023-02-21 14:19:24 +0800 | [diff] [blame] | 20 | * Support Arm Compiler for Embedded [10]_. ``Arm Compiler for Embedded 6.17`` |
| 21 | and later version shall be used to mitigate VLLDM instruction security |
| 22 | vulnerability [4]_. |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 23 | * Does not support use FPU in First-Level Interrupt Handling (FLIH) [6]_ at |
Feder Liang | 98e77a8 | 2021-11-25 14:34:23 +0800 | [diff] [blame] | 24 | current stage. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 25 | |
Jianliang Shen | 47d21e5 | 2022-08-02 14:36:00 +0800 | [diff] [blame] | 26 | Please refer to Arm AN521 or AN552 platform as a reference implementation when |
Feder Liang | 98e77a8 | 2021-11-25 14:34:23 +0800 | [diff] [blame] | 27 | you enable FP support on your platforms. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 28 | |
Lingkai Dong | 181c00c | 2022-04-25 11:36:34 +0100 | [diff] [blame] | 29 | .. Note:: |
| 30 | Alternatively, if you intend to use FP in your own NSPE application but the |
| 31 | TF-M SPE services that you enable do not require FP, you can set the CMake |
Gabor Toth | 4d41411 | 2021-11-10 17:44:50 +0100 | [diff] [blame] | 32 | configuration ``CONFIG_TFM_ENABLE_CP10CP11`` to ``ON`` and **ignore** any |
Lingkai Dong | 181c00c | 2022-04-25 11:36:34 +0100 | [diff] [blame] | 33 | configurations described below. |
| 34 | |
Xinyu Zhang | 8ec3063 | 2022-06-30 18:03:31 +0800 | [diff] [blame] | 35 | .. Note:: |
Roman Mazurak | 0a79e67 | 2024-08-14 16:48:13 +0300 | [diff] [blame] | 36 | CONFIG_TFM_DISABLE_CP10CP11 can be set to ON to disable CP10/CP11 coprocessors |
| 37 | in cases when it's expected that FPU must not be used neither by secure |
| 38 | nor by non-secure images. |
| 39 | |
| 40 | .. Note:: |
Jianliang Shen | 47d21e5 | 2022-08-02 14:36:00 +0800 | [diff] [blame] | 41 | FPU test issue has not been fixed yet on Musca-S1 [7]_. When running FPU |
| 42 | tests on Musca-S1, secure thread fails to trigger secure interrupt. FPU test |
| 43 | is disabled by default on Musca-S1 until the issue is fixed. |
| 44 | |
| 45 | .. Note:: |
Xinyu Zhang | 8ec3063 | 2022-06-30 18:03:31 +0800 | [diff] [blame] | 46 | ``GNU Arm Embedded Toolchain 10.3-2021.10`` may have issue that reports |
| 47 | ``'-mcpu=cortex-m55' conflicts with '-march=armv8.1-m.main'`` warning [8]_. |
| 48 | This issue has been fixed in the later version. |
| 49 | |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 50 | ============================ |
| 51 | FP ABI type for SPE and NSPE |
| 52 | ============================ |
Xinyu Zhang | 8ec3063 | 2022-06-30 18:03:31 +0800 | [diff] [blame] | 53 | FP design in Armv8.0-M [9]_ architecture requires consistent FP ABI types |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 54 | between SPE and NSPE. Furthermore, both sides shall set up CPACR individually |
| 55 | when FPU is used. Otherwise, No Coprocessor (NOCP) usage fault will be asserted |
| 56 | during FP context switch between security states. |
| 57 | |
| 58 | Secure and non-secure libraries are compiled with ``COMPILER_CP_FLAG`` and |
| 59 | linked with ``LINKER_CP_OPTION`` for different FP ABI types. All those |
| 60 | libraries shall be built with ``COMPLIER_CP_FLAG``. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 61 | |
Antonio de Angelis | 9d496a5 | 2025-01-07 21:18:00 +0000 | [diff] [blame] | 62 | If FP ABI types mismatch error is generated during build, please check whether |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 63 | the library is compiled with ``COMPILER_CP_FLAG``. |
| 64 | Example: |
| 65 | |
| 66 | .. code-block:: cmake |
| 67 | |
| 68 | target_compile_options(lib |
| 69 | PRIVATE |
| 70 | ${COMPILER_CP_FLAG} |
| 71 | ) |
| 72 | |
| 73 | =================================== |
| 74 | CMake configurations for FP support |
| 75 | =================================== |
| 76 | The following CMake configurations configure ``COMPILER_CP_FLAG`` in TF-M SPE. |
| 77 | |
Gabor Toth | 4d41411 | 2021-11-10 17:44:50 +0100 | [diff] [blame] | 78 | * ``CONFIG_TFM_ENABLE_FP`` is used to enable/disable FPU usage. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 79 | |
Gabor Toth | 4d41411 | 2021-11-10 17:44:50 +0100 | [diff] [blame] | 80 | +--------------------------+---------------------------+ |
| 81 | | CONFIG_TFM_ENABLE_FP | FP support | |
| 82 | +==========================+===========================+ |
chesun01 | 305757f | 2023-02-21 14:19:24 +0800 | [diff] [blame] | 83 | | off (default) | FP disabled | |
Gabor Toth | 4d41411 | 2021-11-10 17:44:50 +0100 | [diff] [blame] | 84 | +--------------------------+---------------------------+ |
| 85 | | on | FP enabled | |
| 86 | +--------------------------+---------------------------+ |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 87 | |
Lingkai Dong | 181c00c | 2022-04-25 11:36:34 +0100 | [diff] [blame] | 88 | .. Note:: |
Gabor Toth | 4d41411 | 2021-11-10 17:44:50 +0100 | [diff] [blame] | 89 | ``CONFIG_TFM_FLOAT_ABI`` depends on ``CONFIG_TFM_ENABLE_FP``. If |
| 90 | ``CONFIG_TFM_ENABLE_FP is set ``CONFIG_TFM_FLOAT_ABI`` is automatically |
| 91 | set to ``hard``. |
| 92 | |
| 93 | .. Note:: |
| 94 | If you build TF-M SPE with ``CONFIG_TFM_ENABLE_FP=on`` and provide your own |
| 95 | NSPE application, your own NSPE **must** take care of enabling floating point |
Lingkai Dong | 181c00c | 2022-04-25 11:36:34 +0100 | [diff] [blame] | 96 | coprocessors CP10 and CP11 on the NS side to avoid aforementioned NOCP usage |
| 97 | fault. |
| 98 | |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 99 | * ``CONFIG_TFM_LAZY_STACKING`` is used to enable/disable lazy stacking |
| 100 | feature. This feature is only valid for FP hardware ABI type. |
| 101 | NSPE is not allowed to enable/disable this feature. Let SPE decide the |
| 102 | secure/non-secure shared setting of lazy stacking to avoid the possible |
| 103 | side-path brought by flexibility. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 104 | |
| 105 | +------------------------------+---------------------------+ |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 106 | | CONFIG_TFM_LAZY_STACKING | Description | |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 107 | +==============================+===========================+ |
| 108 | | 0FF | Disable lazy stacking | |
| 109 | +------------------------------+---------------------------+ |
| 110 | | ON (default) | Enable lazy stacking | |
| 111 | +------------------------------+---------------------------+ |
| 112 | |
| 113 | * ``CONFIG_TFM_FP_ARCH`` specifies which FP architecture is available on the |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 114 | target, valid for FP hardware ABI type. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 115 | |
| 116 | FP architecture is processor dependent. For GNUARM compiler, example value |
chesun01 | 305757f | 2023-02-21 14:19:24 +0800 | [diff] [blame] | 117 | are: auto, fpv5-d16, fpv5-sp-d16, etc. For armclang, example value are: none, |
| 118 | softvfp, fpv5-d16, fpv5-sp-d16, etc. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 119 | |
Joakim Andersson | 9230926 | 2023-02-08 14:41:14 +0100 | [diff] [blame] | 120 | This parameter shall be specified by platform in preload.cmake. Please check |
| 121 | compiler reference manual and processor hardware manual for more details to |
| 122 | set correct FPU configuration for platform. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 123 | |
chesun01 | 305757f | 2023-02-21 14:19:24 +0800 | [diff] [blame] | 124 | * ``CONFIG_TFM_FP_ARCH_ASM`` specifies the target FPU architecture name shared |
| 125 | by Arm Compiler armasm and armlink. It is only used in the ``--fpu=`` argument |
| 126 | by Arm Compiler and shall be aligned with ``CONFIG_TFM_FP_ARCH``. |
| 127 | |
| 128 | FP architecture is processor dependent. For armasm and armlink, example value |
| 129 | are: SoftVFP, FPv5_D16, etc. |
| 130 | |
| 131 | This parameter shall be specified by platform in preload.cmake. Please check |
| 132 | compiler reference manual and processor hardware manual for more details to |
| 133 | set correct FPU configuration for platform. |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 134 | |
| 135 | ********* |
| 136 | Reference |
| 137 | ********* |
| 138 | .. [1] `High-Performance Hardware Support for Floating-Point Operations <https://www.arm.com/why-arm/technologies/floating-point>`_ |
| 139 | |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 140 | .. [2] `Float Point ABI <https://www.keil.com/support/man/docs/armclang_ref/armclang_ref_chr1417451577871.htm>`_ |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 141 | |
| 142 | .. [3] `GNU Arm Embedded Toolchain <https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm>`_ |
| 143 | |
Feder Liang | 8ac672f | 2021-12-09 15:03:04 +0800 | [diff] [blame] | 144 | .. [4] `VLLDM instruction Security Vulnerability <https://developer.arm.com/support/arm-security-updates/vlldm-instruction-security-vulnerability>`_ |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 145 | |
Elena Uziunaite | 66461ae | 2023-11-10 16:51:59 +0000 | [diff] [blame] | 146 | .. [5] `ArmĀ® Platform Security Architecture Firmware Framework 1.0 <https://developer.arm.com/documentation/den0063/latest/>`_ |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 147 | |
Anton Komlev | 3356ba3 | 2022-03-31 22:02:11 +0100 | [diff] [blame] | 148 | .. [6] :doc:`Secure Interrupt Integration Guide </integration_guide/tfm_secure_irq_integration_guide>` |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 149 | |
Matthew Dalzell | 988bbd6 | 2025-06-05 15:49:26 +0100 | [diff] [blame^] | 150 | .. [7] `Musca-S1 Test Chip Board <https://developer.arm.com/documentation/101835/0000/?lang=en>`_ |
Feder Liang | 98e77a8 | 2021-11-25 14:34:23 +0800 | [diff] [blame] | 151 | |
Xinyu Zhang | 8ec3063 | 2022-06-30 18:03:31 +0800 | [diff] [blame] | 152 | .. [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>`_ |
| 153 | |
| 154 | .. [9] `Armv8-M Architecture Reference Manual <https://developer.arm.com/documentation/ddi0553/latest>`_ |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 155 | |
chesun01 | 305757f | 2023-02-21 14:19:24 +0800 | [diff] [blame] | 156 | .. [10] `Arm Compiler for Embedded <https://developer.arm.com/Tools%20and%20Software/Arm%20Compiler%20for%20Embedded>`_ |
| 157 | |
Xinyu Zhang | 08cefc1 | 2023-11-21 17:12:24 +0800 | [diff] [blame] | 158 | .. [11] `FF-M v1.1 Extension <https://developer.arm.com/documentation/aes0039/latest/>`__ |
| 159 | |
Feder Liang | 4f7c75b | 2021-09-14 16:15:15 +0800 | [diff] [blame] | 160 | -------------- |
| 161 | |
Xinyu Zhang | 08cefc1 | 2023-11-21 17:12:24 +0800 | [diff] [blame] | 162 | *Copyright (c) 2021-2023, Arm Limited. All rights reserved.* |