Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 1 | Building TF-A Tests |
| 2 | =================== |
| 3 | |
| 4 | - Before building TF-A Tests, the environment variable ``CROSS_COMPILE`` must |
| 5 | point to the cross compiler. |
| 6 | |
| 7 | For AArch64: |
| 8 | |
| 9 | :: |
| 10 | |
| 11 | export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- |
| 12 | |
| 13 | For AArch32: |
| 14 | |
| 15 | :: |
| 16 | |
| 17 | export CROSS_COMPILE=<path-to-aarch32-gcc>/bin/arm-eabi- |
| 18 | |
Jayanth Dodderi Chidanand | f667cda | 2023-06-27 15:01:52 +0100 | [diff] [blame] | 19 | - It is possible to build TF-A Tests using clang (currently AArch64 only). To |
| 20 | do so ``CC`` needs to point to the clang binary. Only the compiler is switched; |
| 21 | the assembler and linker need to be provided by the GNU toolchain, thus |
| 22 | ``CROSS_COMPILE`` should be set as described above. |
| 23 | |
| 24 | clang will be selected when the base name of the path assigned to ``CC`` |
| 25 | contains the string 'clang'. |
| 26 | |
| 27 | - For AArch64 using clang: |
| 28 | |
| 29 | .. code:: shell |
| 30 | |
| 31 | export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- |
| 32 | make CC=<path-to-clang>/bin/clang PLAT=<platform> tftf |
| 33 | |
| 34 | - Currently, the following TF-A Tests targets are supported for clang build: |
| 35 | |
| 36 | ``tftf, ivy, realm, cactus, cactus_mm, ns_bl1u`` |
| 37 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 38 | - Change to the root directory of the TF-A Tests source tree and build. |
| 39 | |
| 40 | For AArch64: |
| 41 | |
| 42 | :: |
| 43 | |
| 44 | make PLAT=<platform> |
| 45 | |
| 46 | For AArch32: |
| 47 | |
| 48 | :: |
| 49 | |
| 50 | make PLAT=<platform> ARCH=aarch32 |
| 51 | |
| 52 | Notes: |
| 53 | |
| 54 | - If ``PLAT`` is not specified, ``fvp`` is assumed by default. See the |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 55 | `TF-A documentation`_ for more information on available build |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 56 | options. |
| 57 | |
| 58 | - By default this produces a release version of the build. To produce a |
| 59 | debug version instead, build the code with ``DEBUG=1``. |
| 60 | |
| 61 | - The build process creates products in a ``build/`` directory tree, |
| 62 | building the objects and binaries for each test image in separate |
| 63 | sub-directories. The following binary files are created from the |
| 64 | corresponding ELF files: |
| 65 | |
| 66 | - ``build/<platform>/<build-type>/tftf.bin`` |
| 67 | - ``build/<platform>/<build-type>/ns_bl1u.bin`` |
| 68 | - ``build/<platform>/<build-type>/ns_bl2u.bin`` |
| 69 | - ``build/<platform>/<build-type>/el3_payload.bin`` |
| 70 | - ``build/<platform>/<build-type>/cactus_mm.bin`` |
| 71 | - ``build/<platform>/<build-type>/cactus.bin`` |
| 72 | - ``build/<platform>/<build-type>/ivy.bin`` |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 73 | |
| 74 | where ``<platform>`` is the name of the chosen platform and ``<build-type>`` |
| 75 | is either ``debug`` or ``release``. The actual number of images might differ |
| 76 | depending on the platform. |
| 77 | |
| 78 | Refer to the sections below for more information about each image. |
| 79 | |
| 80 | - Build products for a specific build variant can be removed using: |
| 81 | |
| 82 | :: |
| 83 | |
| 84 | make DEBUG=<D> PLAT=<platform> clean |
| 85 | |
| 86 | ... where ``<D>`` is ``0`` or ``1``, as specified when building. |
| 87 | |
| 88 | The build tree can be removed completely using: |
| 89 | |
| 90 | :: |
| 91 | |
| 92 | make realclean |
| 93 | |
| 94 | - Use the following command to list all supported build commands: |
| 95 | |
| 96 | :: |
| 97 | |
| 98 | make help |
| 99 | |
| 100 | TFTF test image |
| 101 | ``````````````` |
| 102 | |
| 103 | ``tftf.bin`` is the main test image to exercise the TF-A features. The other |
| 104 | test images provided in this repository are optional dependencies that TFTF |
| 105 | needs to test some specific features. |
| 106 | |
| 107 | ``tftf.bin`` may be built independently of the other test images using the |
| 108 | following command: |
| 109 | |
| 110 | :: |
| 111 | |
| 112 | make PLAT=<platform> tftf |
| 113 | |
| 114 | In TF-A boot flow, ``tftf.bin`` replaces the ``BL33`` image and should be |
| 115 | injected in the FIP image. This might be achieved by running the following |
| 116 | command from the TF-A root directory: |
| 117 | |
| 118 | :: |
| 119 | |
Leonardo Sandoval | abf254f | 2020-06-29 17:46:28 -0500 | [diff] [blame] | 120 | BL33=<path/to/tftf.bin> make PLAT=<platform> fip |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 121 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 122 | Please refer to the `TF-A documentation`_ for further details. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 123 | |
Soby Mathew | 2a5b150 | 2022-11-02 04:29:07 +0000 | [diff] [blame] | 124 | Realm payload test image |
| 125 | ```````````````````````` |
| 126 | |
| 127 | ``realm.bin`` is the realm payload test image and is packaged along with |
| 128 | tftf for Realm Management Extension (RME) testing. This can be built using |
| 129 | the following command: |
| 130 | |
| 131 | :: |
| 132 | |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 133 | make PLAT=<platform> ENABLE_REALM_PAYLOAD_TESTS=1 tftf |
Soby Mathew | 2a5b150 | 2022-11-02 04:29:07 +0000 | [diff] [blame] | 134 | |
Shruti Gupta | c973b2a | 2023-07-12 12:10:54 +0100 | [diff] [blame] | 135 | The generated ``realm.bin`` is packaged as part of ``tftf.bin`` |
| 136 | to be used as a single BL33 image. |
Soby Mathew | 2a5b150 | 2022-11-02 04:29:07 +0000 | [diff] [blame] | 137 | |
| 138 | Please refer to the `TF-A RME documentation`_ for build and run instructions. |
| 139 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 140 | NS_BL1U and NS_BL2U test images |
| 141 | ``````````````````````````````` |
| 142 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 143 | ``ns_bl1u.bin`` and ``ns_bl2u.bin`` are test images that exercise the *Firmware |
| 144 | Update (FWU)* feature of TF-A [#]_. Throughout this document, they will be |
| 145 | referred as the *FWU test images*. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 146 | |
| 147 | In addition to updating the firmware, the FWU test images also embed some tests |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 148 | that exercise the FWU state machine implemented in the TF-A. They send valid |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 149 | and invalid SMC requests to the TF-A BL1 image in order to test its robustness. |
| 150 | |
| 151 | NS_BL1U test image |
| 152 | '''''''''''''''''' |
| 153 | |
| 154 | The ``NS_BL1U`` image acts as the `Application Processor (AP) Firmware Update |
| 155 | Boot ROM`. This typically is the first software agent executing on the AP in the |
| 156 | Normal World during a firmware update operation. Its primary purpose is to load |
| 157 | subsequent firmware update images from an external interface, such as NOR Flash, |
| 158 | and communicate with ``BL1`` to authenticate those images. |
| 159 | |
| 160 | The ``NS_BL1U`` test image provided in this repository performs the following |
| 161 | tasks: |
| 162 | |
| 163 | - Load FWU images from external non-volatile storage (typically flash memory) |
| 164 | to Non-Secure RAM. |
| 165 | |
| 166 | - Request TF-A BL1 to copy these images in Secure RAM and authenticate them. |
| 167 | |
| 168 | - Jump to ``NS_BL2U`` which carries out the next steps in the firmware update |
| 169 | process. |
| 170 | |
| 171 | This image may be built independently of the other test images using the |
| 172 | following command: |
| 173 | |
| 174 | :: |
| 175 | |
| 176 | make PLAT=<platform> ns_bl1u |
| 177 | |
| 178 | NS_BL2U test image |
| 179 | '''''''''''''''''' |
| 180 | |
| 181 | The ``NS_BL2U`` image acts as the `AP Firmware Updater`. Its primary |
| 182 | responsibility is to load a new set of firmware images from an external |
| 183 | interface and write them into non-volatile storage. |
| 184 | |
| 185 | The ``NS_BL2U`` test image provided in this repository overrides the original |
| 186 | FIP image stored in flash with the backup FIP image (see below). |
| 187 | |
| 188 | This image may be built independently of the other test images using the |
| 189 | following command: |
| 190 | |
| 191 | :: |
| 192 | |
| 193 | make PLAT=<platform> ns_bl2u |
| 194 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 195 | .. _build_putting_together: |
| 196 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 197 | Putting it all together |
| 198 | ''''''''''''''''''''''' |
| 199 | |
| 200 | The FWU test images should be used in conjunction with the TFTF image, as the |
| 201 | latter initiates the FWU process by corrupting the FIP image and resetting the |
| 202 | target. Once the FWU process is complete, TFTF takes over again and checks that |
| 203 | the firmware was successfully updated. |
| 204 | |
| 205 | To sum up, 3 images must be built out of the TF-A Tests repository in order to |
| 206 | test the TF-A Firmware Update feature: |
| 207 | |
| 208 | - ``ns_bl1u.bin`` |
| 209 | - ``ns_bl2u.bin`` |
| 210 | - ``tftf.bin`` |
| 211 | |
| 212 | Once that's done, they must be combined in the right way. |
| 213 | |
| 214 | - ``ns_bl1u.bin`` is a standalone image and does not require any further |
| 215 | processing. |
| 216 | |
| 217 | - ``ns_bl2u.bin`` must be injected into the ``FWU_FIP`` image. This might be |
| 218 | achieved by setting ``NS_BL2U=ns_bl2u.bin`` when building the ``FWU_FIP`` |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 219 | image out of the TF-A repository. Please refer to the section Building FIP |
| 220 | images with support for Trusted Board Boot in the `TF-A documentation`_. |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 221 | |
| 222 | - ``tftf.bin`` must be injected in the standard FIP image, as explained |
| 223 | in section `TFTF test image`_. |
| 224 | |
| 225 | Additionally, on Juno platform, the FWU FIP must contain a ``SCP_BL2U`` image. |
| 226 | This image can simply be a copy of the standard ``SCP_BL2`` image if no specific |
| 227 | firmware update operations need to be carried on the SCP side. |
| 228 | |
| 229 | Finally, the backup FIP image must be created. This can simply be a copy of the |
| 230 | standard FIP image, which means that the Firmware Update process will restore |
| 231 | the original, uncorrupted FIP image. |
| 232 | |
| 233 | EL3 test payload |
| 234 | ```````````````` |
| 235 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 236 | ``el3_payload.bin`` is a test image exercising the alternative EL3 payload boot |
| 237 | flow in TF-A. Refer to the `EL3 test payload README file`_ for more details |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 238 | about its behaviour and how to build and run it. |
| 239 | |
| 240 | SPM test images |
| 241 | ``````````````` |
| 242 | |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 243 | This repository contains three sample Secure Partitions (SP) meant to be used |
| 244 | with one implementation of a Secure Partition Manager (SPM): |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 245 | |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 246 | - Cactus-MM |
| 247 | - Cactus and Ivy |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 248 | |
| 249 | They are only supported on AArch64 FVP. They can be built independently of the |
| 250 | other test images using the following command: |
| 251 | |
| 252 | :: |
| 253 | |
| 254 | make PLAT=fvp cactus ivy cactus_mm |
| 255 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 256 | To run the full set of tests in the Secure Partitions, they should be used in |
| 257 | conjunction with the TFTF image. |
| 258 | |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 259 | Please refer to the `TF-A documentation`_ for further details. |
| 260 | |
| 261 | Cactus-MM |
| 262 | ''''''''' |
| 263 | |
| 264 | Cactus-MM is designed to test the TF-A EL3 SPM implementation |
| 265 | (`TF-A Secure Partition Manager (MM)`_) based on the |
| 266 | `Arm Management Mode Interface`_ (MM) |
| 267 | |
| 268 | This SP runs in Secure-EL0 and performs the following tasks: |
| 269 | |
| 270 | - Test that TF-A has correctly setup the secure partition environment: it |
| 271 | should be allowed to perform cache maintenance operations, access floating |
| 272 | point registers, etc. |
| 273 | |
| 274 | - Test that TF-A accepts to change data access permissions and instruction |
| 275 | permissions on behalf of the Secure Partition for memory regions the latter |
| 276 | owns. |
| 277 | |
| 278 | - Test communication with SPM through MM interface. |
| 279 | |
| 280 | In the TF-A boot flow, the partition replaces the ``BL32`` image and should be |
| 281 | injected in the FIP image. To test SPM-MM with Cactus-MM, it is enough to use |
| 282 | ``cactus_mm.bin`` as BL32 image. |
| 283 | |
| 284 | For SPM-MM, build TF-A following `Building TF-A Secure Partition Manager (MM)`_ and the following |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 285 | commands can be used to build the tests: |
| 286 | |
| 287 | :: |
| 288 | |
| 289 | # TF-A-Tests repository: |
| 290 | |
| 291 | make PLAT=fvp TESTS=spm-mm tftf cactus_mm |
| 292 | |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 293 | Cactus and Ivy |
| 294 | '''''''''''''' |
| 295 | |
| 296 | Cactus and Ivy are designed to test the FF-A based SPM implementation with |
| 297 | secure virtualization enabled. Refer to `Arm Firmware Framework for Armv8-A`_ |
| 298 | |
| 299 | In the TF-A reference code base, BL31 implements the SPMD and BL32 the SPMC. |
| 300 | The SPMC runs at S-EL2 and acts as a partition manager for multiple secure |
| 301 | partitions (`TF-A Secure Partition Manager (FF-A)`_): |
| 302 | |
| 303 | - Cactus is a sample FF-A compliant S-EL1 partition. As a matter of providing |
| 304 | a realistic test harness, three instances of the same partition binary are |
| 305 | launched as separate SPs (hence assigned three different FF-A IDs |
| 306 | corresponding each to a different secure partition). Each secure partition |
| 307 | instance has a separate manifest (`Cactus sample manifest`_, |
| 308 | `Cactus secondary manifest`_, `Cactus tertiary manifest`_ ). First two |
| 309 | instances are MP SPs. Third instance is a UP SP. Each instance runs a set |
| 310 | of built-in tests at boot time. They exercise SP to SPMC FF-A interfaces |
| 311 | contained in the secure world. The partition interacts with the SPMC through |
| 312 | SMC. Once the NWd and TFTF are started, another set of run-time tests |
| 313 | exercise the normal world to secure world primitives. |
| 314 | - Ivy is a specific kind of S-EL1 UP partition, where the S-EL1 exception level |
| 315 | consists of a thin shim layer. The applicative part of the partition is held |
| 316 | at S-EL0. The shim provides early bootstrap code, MMU configuration and a |
| 317 | vector table trapping S-EL0 requests. The application interacts with the shim |
| 318 | through FF-A protocol by the use of SVC instruction. The shim relays the |
| 319 | request to the SPMC by an SMC. The S-EL0 application doesn't require knowledge |
| 320 | of the shim, and can be self contained. |
| 321 | |
| 322 | This picture illustrates the test setup: |
| 323 | |
| 324 | .. image:: ../resources/tftf-cactus.png |
| 325 | |
| 326 | To build TFTF with SPM tests, Cactus and Ivy use: |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 327 | |
| 328 | :: |
| 329 | |
| 330 | # TF-A-Tests repository: |
| 331 | |
| 332 | make PLAT=fvp TESTS=spm tftf cactus ivy |
| 333 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 334 | -------------- |
| 335 | |
| 336 | .. [#] Therefore, the Trusted Board Boot feature must be enabled in TF-A for |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 337 | the FWU test images to work. Please refer the `TF-A documentation`_ for |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 338 | further details. |
| 339 | |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 340 | -------------- |
| 341 | |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 342 | *Copyright (c) 2019-2021, Arm Limited. All rights reserved.* |
Jimmy Brisson | 0862f01 | 2020-04-02 15:19:12 -0500 | [diff] [blame] | 343 | |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 344 | .. _EL3 test payload README file: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/el3_payload/README |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 345 | .. _Arm Management Mode Interface: https://developer.arm.com/documentation/den0060/a/ |
| 346 | .. _Arm Firmware Framework for Armv8-A: https://developer.arm.com/docs/den0077/latest |
Jimmy Brisson | 4844dc9 | 2020-04-02 15:19:34 -0500 | [diff] [blame] | 347 | .. _TF-A documentation: https://trustedfirmware-a.readthedocs.org |
Soby Mathew | 2a5b150 | 2022-11-02 04:29:07 +0000 | [diff] [blame] | 348 | .. _TF-A RME documentation: https://trustedfirmware-a.readthedocs.io/en/latest/components/realm-management-extension.html |
Olivier Deprez | a757366 | 2021-05-07 18:58:03 +0200 | [diff] [blame] | 349 | .. _TF-A Secure Partition Manager (FF-A): https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager.html |
| 350 | .. _TF-A Secure Partition Manager (MM): https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html |
| 351 | .. _Building TF-A Secure Partition Manager (MM): https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html#building-tf-a-with-secure-partition-support |
| 352 | .. _Cactus sample manifest: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus.dts?h=v2.5-rc1 |
| 353 | .. _Cactus secondary manifest: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus-secondary.dts?h=v2.5-rc1 |
| 354 | .. _Cactus tertiary manifest: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus-tertiary.dts?h=v2.5-rc1 |