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