1fcb1398fSOlivier DeprezSecure Partition Manager 2fcb1398fSOlivier Deprez************************ 3fcb1398fSOlivier Deprez 4fcb1398fSOlivier Deprez.. contents:: 5fcb1398fSOlivier Deprez 69eea92a1SOlivier Deprez.. toctree:: 79eea92a1SOlivier Deprez ffa-manifest-binding 89eea92a1SOlivier Deprez 9fcb1398fSOlivier DeprezAcronyms 10fcb1398fSOlivier Deprez======== 11fcb1398fSOlivier Deprez 128a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 13fcb1398fSOlivier Deprez| DTS | Device Tree Source | 148a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 158a5bd3cfSOlivier Deprez| FF-A | Firmware Framework for Arm A-profile | 168a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 17fcb1398fSOlivier Deprez| NWd | Normal World | 188a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 19fcb1398fSOlivier Deprez| SP | Secure Partition | 208a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 21b5dd2422SOlivier Deprez| SPD | Secure Payload Dispatcher | 228a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 23fcb1398fSOlivier Deprez| SPM | Secure Partition Manager | 248a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 25fcb1398fSOlivier Deprez| SPMC | SPM Core | 268a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 27fcb1398fSOlivier Deprez| SPMD | SPM Dispatcher | 288a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 29fcb1398fSOlivier Deprez| SWd | Secure World | 308a5bd3cfSOlivier Deprez+--------+--------------------------------------+ 31fcb1398fSOlivier Deprez 32fcb1398fSOlivier DeprezForeword 33fcb1398fSOlivier Deprez======== 34fcb1398fSOlivier Deprez 359eea92a1SOlivier DeprezThree implementations of a Secure Partition Manager co-exist in the TF-A 369eea92a1SOlivier Deprezcodebase: 37fcb1398fSOlivier Deprez 389eea92a1SOlivier Deprez#. S-EL2 SPMC based on the FF-A specification `[1]`_, enabling virtualization in 39*65e573fcSMadhukar Pappireddy the secure world, managing multiple S-EL1 or S-EL0 partitions `[5]`_. 409eea92a1SOlivier Deprez#. EL3 SPMC based on the FF-A specification, managing a single S-EL1 partition 41*65e573fcSMadhukar Pappireddy without virtualization in the secure world `[6]`_. 429eea92a1SOlivier Deprez#. EL3 SPM based on the MM specification, legacy implementation managing a 439eea92a1SOlivier Deprez single S-EL0 partition `[2]`_. 44fcb1398fSOlivier Deprez 459eea92a1SOlivier DeprezThese implementations differ in their respective SW architecture and only one 46*65e573fcSMadhukar Pappireddycan be selected at build time. 47fcb1398fSOlivier Deprez 48fcb1398fSOlivier DeprezSupport for legacy platforms 49fcb1398fSOlivier Deprez---------------------------- 50fcb1398fSOlivier Deprez 519eea92a1SOlivier DeprezThe SPM is split into a dispatcher and a core component (respectively SPMD and 529eea92a1SOlivier DeprezSPMC) residing at different exception levels. To permit the FF-A specification 539eea92a1SOlivier Deprezadoption and a smooth migration, the SPMD supports an SPMC residing either at 549eea92a1SOlivier DeprezS-EL1 or S-EL2: 55fcb1398fSOlivier Deprez 569eea92a1SOlivier Deprez- The SPMD is located at EL3 and mainly relays the FF-A protocol from NWd 579eea92a1SOlivier Deprez (Hypervisor or OS kernel) to the SPMC. 589eea92a1SOlivier Deprez- The same SPMD component is used for both S-EL1 and S-EL2 SPMC configurations. 599eea92a1SOlivier Deprez- The SPMC exception level is a build time choice. 60fcb1398fSOlivier Deprez 619eea92a1SOlivier DeprezTF-A supports both cases: 629eea92a1SOlivier Deprez 639eea92a1SOlivier Deprez- S-EL1 SPMC for platforms not supporting the FEAT_SEL2 architecture 64b5dd2422SOlivier Deprez extension. The SPMD relays the FF-A protocol from EL3 to S-EL1. 659eea92a1SOlivier Deprez- S-EL2 SPMC for platforms implementing the FEAT_SEL2 architecture 66b5dd2422SOlivier Deprez extension. The SPMD relays the FF-A protocol from EL3 to S-EL2. 67fcb1398fSOlivier Deprez 68fcb1398fSOlivier DeprezTF-A build options 69fcb1398fSOlivier Deprez================== 70fcb1398fSOlivier Deprez 71b5dd2422SOlivier DeprezThis section explains the TF-A build options involved in building with 72b5dd2422SOlivier Deprezsupport for an FF-A based SPM where the SPMD is located at EL3 and the 731d63ae4dSMarc BonniciSPMC located at S-EL1, S-EL2 or EL3: 74fcb1398fSOlivier Deprez 75b5dd2422SOlivier Deprez- **SPD=spmd**: this option selects the SPMD component to relay the FF-A 76fcb1398fSOlivier Deprez protocol from NWd to SWd back and forth. It is not possible to 77fcb1398fSOlivier Deprez enable another Secure Payload Dispatcher when this option is chosen. 78b5dd2422SOlivier Deprez- **SPMD_SPM_AT_SEL2**: this option adjusts the SPMC exception 791d63ae4dSMarc Bonnici level to being at S-EL2. It defaults to enabled (value 1) when 80fcb1398fSOlivier Deprez SPD=spmd is chosen. 811d63ae4dSMarc Bonnici- **SPMC_AT_EL3**: this option adjusts the SPMC exception level to being 82*65e573fcSMadhukar Pappireddy at EL3. If neither ``SPMD_SPM_AT_SEL2`` or ``SPMC_AT_EL3`` are enabled the 83*65e573fcSMadhukar Pappireddy SPMC exception level is set to S-EL1. 84b5dd2422SOlivier Deprez ``SPMD_SPM_AT_SEL2`` is enabled. The context save/restore routine 85b5dd2422SOlivier Deprez and exhaustive list of registers is visible at `[4]`_. 86801cd3c8SNishant Sharma- **SPMC_AT_EL3_SEL0_SP**: this option enables the support to load SEL0 SP 87801cd3c8SNishant Sharma when SPMC at EL3 support is enabled. 88b5dd2422SOlivier Deprez- **SP_LAYOUT_FILE**: this option specifies a text description file 89b5dd2422SOlivier Deprez providing paths to SP binary images and manifests in DTS format 90*65e573fcSMadhukar Pappireddy (see `[3]`_). It 91fcb1398fSOlivier Deprez is required when ``SPMD_SPM_AT_SEL2`` is enabled hence when multiple 929eea92a1SOlivier Deprez secure partitions are to be loaded by BL2 on behalf of the SPMC. 93fcb1398fSOlivier Deprez 94f1910cc1SGovindraj Raja+---------------+------------------+-------------+-------------------------+ 95f1910cc1SGovindraj Raja| | SPMD_SPM_AT_SEL2 | SPMC_AT_EL3 | CTX_INCLUDE_EL2_REGS(*) | 96f1910cc1SGovindraj Raja+---------------+------------------+-------------+-------------------------+ 971d63ae4dSMarc Bonnici| SPMC at S-EL1 | 0 | 0 | 0 | 98f1910cc1SGovindraj Raja+---------------+------------------+-------------+-------------------------+ 99f1910cc1SGovindraj Raja| SPMC at S-EL2 | 1 (default when | 0 | 1 | 100f1910cc1SGovindraj Raja| | SPD=spmd) | | | 101f1910cc1SGovindraj Raja+---------------+------------------+-------------+-------------------------+ 102f1910cc1SGovindraj Raja| SPMC at EL3 | 0 | 1 | 0 | 103f1910cc1SGovindraj Raja+---------------+------------------+-------------+-------------------------+ 104fcb1398fSOlivier Deprez 105fcb1398fSOlivier DeprezOther combinations of such build options either break the build or are not 106fcb1398fSOlivier Deprezsupported. 107fcb1398fSOlivier Deprez 108b5dd2422SOlivier DeprezNotes: 109b5dd2422SOlivier Deprez 110b5dd2422SOlivier Deprez- Only Arm's FVP platform is supported to use with the TF-A reference software 111b5dd2422SOlivier Deprez stack. 1129eea92a1SOlivier Deprez- When ``SPMD_SPM_AT_SEL2=1``, the reference software stack assumes enablement 1139eea92a1SOlivier Deprez of FEAT_PAuth, FEAT_BTI and FEAT_MTE architecture extensions. 114f1910cc1SGovindraj Raja- ``(*) CTX_INCLUDE_EL2_REGS``, this flag is |TF-A| internal and informational 115f1910cc1SGovindraj Raja in this table. When set, it provides the generic support for saving/restoring 116f1910cc1SGovindraj Raja EL2 registers required when S-EL2 firmware is present. 117b5dd2422SOlivier Deprez- BL32 option is re-purposed to specify the SPMC image. It can specify either 118b5dd2422SOlivier Deprez the Hafnium binary path (built for the secure world) or the path to a TEE 119b5dd2422SOlivier Deprez binary implementing FF-A interfaces. 120b5dd2422SOlivier Deprez- BL33 option can specify the TFTF binary or a normal world loader 1219eea92a1SOlivier Deprez such as U-Boot or the UEFI framework payload. 122fcb1398fSOlivier Deprez 1239eea92a1SOlivier DeprezSample TF-A build command line when the SPMC is located at S-EL1 1249eea92a1SOlivier Deprez(e.g. when the FEAT_SEL2 architecture extension is not implemented): 125fcb1398fSOlivier Deprez 126fcb1398fSOlivier Deprez.. code:: shell 127fcb1398fSOlivier Deprez 128fcb1398fSOlivier Deprez make \ 129fcb1398fSOlivier Deprez CROSS_COMPILE=aarch64-none-elf- \ 130fcb1398fSOlivier Deprez SPD=spmd \ 131fcb1398fSOlivier Deprez SPMD_SPM_AT_SEL2=0 \ 132fcb1398fSOlivier Deprez BL32=<path-to-tee-binary> \ 133b5dd2422SOlivier Deprez BL33=<path-to-bl33-binary> \ 134fcb1398fSOlivier Deprez PLAT=fvp \ 135fcb1398fSOlivier Deprez all fip 136fcb1398fSOlivier Deprez 1379eea92a1SOlivier DeprezSample TF-A build command line when FEAT_SEL2 architecture extension is 1389eea92a1SOlivier Deprezimplemented and the SPMC is located at S-EL2: 139b2836dfeSNicola Mazzucato 140fcb1398fSOlivier Deprez.. code:: shell 141fcb1398fSOlivier Deprez 142fcb1398fSOlivier Deprez make \ 143fcb1398fSOlivier Deprez CROSS_COMPILE=aarch64-none-elf- \ 144b5dd2422SOlivier Deprez PLAT=fvp \ 145fcb1398fSOlivier Deprez SPD=spmd \ 146b5dd2422SOlivier Deprez ARM_ARCH_MINOR=5 \ 147b5dd2422SOlivier Deprez BRANCH_PROTECTION=1 \ 148b5dd2422SOlivier Deprez CTX_INCLUDE_PAUTH_REGS=1 \ 149c282384dSGovindraj Raja ENABLE_FEAT_MTE2=1 \ 150b5dd2422SOlivier Deprez BL32=<path-to-hafnium-binary> \ 151b5dd2422SOlivier Deprez BL33=<path-to-bl33-binary> \ 152fcb1398fSOlivier Deprez SP_LAYOUT_FILE=sp_layout.json \ 153fcb1398fSOlivier Deprez all fip 154fcb1398fSOlivier Deprez 1559eea92a1SOlivier DeprezSample TF-A build command line when FEAT_SEL2 architecture extension is 1569eea92a1SOlivier Deprezimplemented, the SPMC is located at S-EL2, and enabling secure boot: 157b2836dfeSNicola Mazzucato 158fcb1398fSOlivier Deprez.. code:: shell 159fcb1398fSOlivier Deprez 160fcb1398fSOlivier Deprez make \ 161fcb1398fSOlivier Deprez CROSS_COMPILE=aarch64-none-elf- \ 162b5dd2422SOlivier Deprez PLAT=fvp \ 163fcb1398fSOlivier Deprez SPD=spmd \ 164b5dd2422SOlivier Deprez ARM_ARCH_MINOR=5 \ 165b5dd2422SOlivier Deprez BRANCH_PROTECTION=1 \ 166b5dd2422SOlivier Deprez CTX_INCLUDE_PAUTH_REGS=1 \ 167c282384dSGovindraj Raja ENABLE_FEAT_MTE2=1 \ 168b5dd2422SOlivier Deprez BL32=<path-to-hafnium-binary> \ 169b5dd2422SOlivier Deprez BL33=<path-to-bl33-binary> \ 170b5dd2422SOlivier Deprez SP_LAYOUT_FILE=sp_layout.json \ 171fcb1398fSOlivier Deprez MBEDTLS_DIR=<path-to-mbedtls-lib> \ 172fcb1398fSOlivier Deprez TRUSTED_BOARD_BOOT=1 \ 173fcb1398fSOlivier Deprez COT=dualroot \ 174fcb1398fSOlivier Deprez ARM_ROTPK_LOCATION=devel_rsa \ 175fcb1398fSOlivier Deprez ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \ 176fcb1398fSOlivier Deprez GENERATE_COT=1 \ 177fcb1398fSOlivier Deprez all fip 178fcb1398fSOlivier Deprez 1799eea92a1SOlivier DeprezSample TF-A build command line when the SPMC is located at EL3: 1801d63ae4dSMarc Bonnici 1811d63ae4dSMarc Bonnici.. code:: shell 1821d63ae4dSMarc Bonnici 1831d63ae4dSMarc Bonnici make \ 1841d63ae4dSMarc Bonnici CROSS_COMPILE=aarch64-none-elf- \ 1851d63ae4dSMarc Bonnici SPD=spmd \ 1861d63ae4dSMarc Bonnici SPMD_SPM_AT_SEL2=0 \ 1871d63ae4dSMarc Bonnici SPMC_AT_EL3=1 \ 1881d63ae4dSMarc Bonnici BL32=<path-to-tee-binary> \ 1891d63ae4dSMarc Bonnici BL33=<path-to-bl33-binary> \ 1901d63ae4dSMarc Bonnici PLAT=fvp \ 1911d63ae4dSMarc Bonnici all fip 1921d63ae4dSMarc Bonnici 193801cd3c8SNishant SharmaSample TF-A build command line when the SPMC is located at EL3 and SEL0 SP is 194801cd3c8SNishant Sharmaenabled: 195801cd3c8SNishant Sharma 196801cd3c8SNishant Sharma.. code:: shell 197801cd3c8SNishant Sharma 198801cd3c8SNishant Sharma make \ 199801cd3c8SNishant Sharma CROSS_COMPILE=aarch64-none-elf- \ 200801cd3c8SNishant Sharma SPD=spmd \ 201801cd3c8SNishant Sharma SPMD_SPM_AT_SEL2=0 \ 202801cd3c8SNishant Sharma SPMC_AT_EL3=1 \ 203801cd3c8SNishant Sharma SPMC_AT_EL3_SEL0_SP=1 \ 204801cd3c8SNishant Sharma BL32=<path-to-tee-binary> \ 205801cd3c8SNishant Sharma BL33=<path-to-bl33-binary> \ 206801cd3c8SNishant Sharma PLAT=fvp \ 207801cd3c8SNishant Sharma all fip 208801cd3c8SNishant Sharma 209fcb1398fSOlivier DeprezBoot process 210fcb1398fSOlivier Deprez============ 211fcb1398fSOlivier Deprez 212*65e573fcSMadhukar PappireddyThe boot process involving SPMC is highly dependent on the SPMC implementation. 213*65e573fcSMadhukar PappireddyIt is recommended to refer to corresponding SPMC documentation for further 214*65e573fcSMadhukar Pappireddydetails. Some aspects of boot process are described here in the greater interest 215*65e573fcSMadhukar Pappireddyof the project. 216fcb1398fSOlivier Deprez 217fcb1398fSOlivier DeprezSPMC boot 218*65e573fcSMadhukar Pappireddy--------- 219fcb1398fSOlivier Deprez 220*65e573fcSMadhukar PappireddyWhen SPMC resides at a lower EL i.e., S-EL1 or S-EL2, it is loaded by BL2 as the 221*65e573fcSMadhukar PappireddyBL32 image. The SPMC manifest is loaded by BL2 as the ``TOS_FW_CONFIG`` image `[7]`_. 222fcb1398fSOlivier Deprez 223*65e573fcSMadhukar PappireddyBL2 passes the SPMC manifest address to BL31 through a register. At boot time, 224*65e573fcSMadhukar Pappireddythe SPMD in BL31 runs from the primary core, initializes the core contexts and 225*65e573fcSMadhukar Pappireddylaunches the SPMC (BL32) passing the following information through registers: 226f2dcf418SOlivier Deprez 227f2dcf418SOlivier Deprez- X0 holds the ``TOS_FW_CONFIG`` physical address (or SPMC manifest blob). 228f2dcf418SOlivier Deprez- X1 holds the ``HW_CONFIG`` physical address. 229f2dcf418SOlivier Deprez- X4 holds the currently running core linear id. 230fcb1398fSOlivier Deprez 231aeea04d4SRaghu Krishnamurthy 232fcb1398fSOlivier DeprezReferences 233fcb1398fSOlivier Deprez========== 234fcb1398fSOlivier Deprez 235fcb1398fSOlivier Deprez.. _[1]: 236fcb1398fSOlivier Deprez 2378a5bd3cfSOlivier Deprez[1] `Arm Firmware Framework for Arm A-profile <https://developer.arm.com/docs/den0077/latest>`__ 238fcb1398fSOlivier Deprez 239fcb1398fSOlivier Deprez.. _[2]: 240fcb1398fSOlivier Deprez 2416844c347SMadhukar Pappireddy[2] :ref:`Secure Partition Manager using MM interface<Secure Partition Manager (MM)>` 242fcb1398fSOlivier Deprez 243fcb1398fSOlivier Deprez.. _[3]: 244fcb1398fSOlivier Deprez 245*65e573fcSMadhukar Pappireddy[3] https://hafnium.readthedocs.io/en/latest/secure-partition-manager/secure-partition-manager.html#secure-partitions-layout-file 246fcb1398fSOlivier Deprez 247fcb1398fSOlivier Deprez.. _[4]: 248fcb1398fSOlivier Deprez 249fcb1398fSOlivier Deprez[4] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime/aarch64/context.S#n45 250fcb1398fSOlivier Deprez 251fcb1398fSOlivier Deprez.. _[5]: 252fcb1398fSOlivier Deprez 253*65e573fcSMadhukar Pappireddy[5] https://hafnium.readthedocs.io/en/latest/secure-partition-manager/index.html 254fcb1398fSOlivier Deprez 255fcb1398fSOlivier Deprez.. _[6]: 256fcb1398fSOlivier Deprez 257*65e573fcSMadhukar Pappireddy[6] :ref:`EL3 Secure Partition Manager<EL3 Secure Partition Manager>` 258fcb1398fSOlivier Deprez 259fcb1398fSOlivier Deprez.. _[7]: 260fcb1398fSOlivier Deprez 261*65e573fcSMadhukar Pappireddy[7] https://trustedfirmware-a.readthedocs.io/en/latest/design/firmware-design.html#dynamic-configuration-during-cold-boot 262f2dcf418SOlivier Deprez 263fcb1398fSOlivier Deprez-------------- 264fcb1398fSOlivier Deprez 2650a33adc0SGovindraj Raja*Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.* 266