blob: a181204b7c006be788eec2fd8c6b69af87215394 [file] [log] [blame]
Olivier Deprezfcb13982020-04-02 15:38:02 +02001Secure Partition Manager
2************************
3
4.. contents::
5
Olivier Deprez9eea92a2022-04-28 18:18:36 +02006.. toctree::
7 ffa-manifest-binding
8
Olivier Deprezfcb13982020-04-02 15:38:02 +02009Acronyms
10========
11
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +020012+--------+--------------------------------------+
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +020013| DTS | Device Tree Source |
14+--------+--------------------------------------+
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +020015| FF-A | Firmware Framework for Arm A-profile |
16+--------+--------------------------------------+
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +020017| NWd | Normal World |
18+--------+--------------------------------------+
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +020019| SP | Secure Partition |
20+--------+--------------------------------------+
21| SPD | Secure Payload Dispatcher |
22+--------+--------------------------------------+
23| SPM | Secure Partition Manager |
24+--------+--------------------------------------+
25| SPMC | SPM Core |
26+--------+--------------------------------------+
27| SPMD | SPM Dispatcher |
28+--------+--------------------------------------+
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +020029| SWd | Secure World |
30+--------+--------------------------------------+
Olivier Deprezfcb13982020-04-02 15:38:02 +020031
32Foreword
33========
34
Olivier Deprez9eea92a2022-04-28 18:18:36 +020035Three implementations of a Secure Partition Manager co-exist in the TF-A
36codebase:
Olivier Deprezfcb13982020-04-02 15:38:02 +020037
Olivier Deprez9eea92a2022-04-28 18:18:36 +020038#. S-EL2 SPMC based on the FF-A specification `[1]`_, enabling virtualization in
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -050039 the secure world, managing multiple S-EL1 or S-EL0 partitions `[5]`_.
Olivier Deprez9eea92a2022-04-28 18:18:36 +020040#. EL3 SPMC based on the FF-A specification, managing a single S-EL1 partition
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -050041 without virtualization in the secure world `[6]`_.
Olivier Deprez9eea92a2022-04-28 18:18:36 +020042#. EL3 SPM based on the MM specification, legacy implementation managing a
43 single S-EL0 partition `[2]`_.
Olivier Deprezfcb13982020-04-02 15:38:02 +020044
Olivier Deprez9eea92a2022-04-28 18:18:36 +020045These implementations differ in their respective SW architecture and only one
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -050046can be selected at build time.
Olivier Deprezfcb13982020-04-02 15:38:02 +020047
48Support for legacy platforms
49----------------------------
50
Olivier Deprez9eea92a2022-04-28 18:18:36 +020051The SPM is split into a dispatcher and a core component (respectively SPMD and
52SPMC) residing at different exception levels. To permit the FF-A specification
53adoption and a smooth migration, the SPMD supports an SPMC residing either at
54S-EL1 or S-EL2:
Olivier Deprezfcb13982020-04-02 15:38:02 +020055
Olivier Deprez9eea92a2022-04-28 18:18:36 +020056- The SPMD is located at EL3 and mainly relays the FF-A protocol from NWd
57 (Hypervisor or OS kernel) to the SPMC.
58- The same SPMD component is used for both S-EL1 and S-EL2 SPMC configurations.
59- The SPMC exception level is a build time choice.
Olivier Deprezfcb13982020-04-02 15:38:02 +020060
Olivier Deprez9eea92a2022-04-28 18:18:36 +020061TF-A supports both cases:
62
63- S-EL1 SPMC for platforms not supporting the FEAT_SEL2 architecture
Olivier Deprezb5dd2422021-04-30 14:42:24 +020064 extension. The SPMD relays the FF-A protocol from EL3 to S-EL1.
Olivier Deprez9eea92a2022-04-28 18:18:36 +020065- S-EL2 SPMC for platforms implementing the FEAT_SEL2 architecture
Olivier Deprezb5dd2422021-04-30 14:42:24 +020066 extension. The SPMD relays the FF-A protocol from EL3 to S-EL2.
Olivier Deprezfcb13982020-04-02 15:38:02 +020067
Olivier Deprezfcb13982020-04-02 15:38:02 +020068TF-A build options
69==================
70
Olivier Deprezb5dd2422021-04-30 14:42:24 +020071This section explains the TF-A build options involved in building with
72support for an FF-A based SPM where the SPMD is located at EL3 and the
Marc Bonnici1d63ae42021-12-01 18:00:40 +000073SPMC located at S-EL1, S-EL2 or EL3:
Olivier Deprezfcb13982020-04-02 15:38:02 +020074
Olivier Deprezb5dd2422021-04-30 14:42:24 +020075- **SPD=spmd**: this option selects the SPMD component to relay the FF-A
76 protocol from NWd to SWd back and forth. It is not possible to
77 enable another Secure Payload Dispatcher when this option is chosen.
78- **SPMD_SPM_AT_SEL2**: this option adjusts the SPMC exception
Marc Bonnici1d63ae42021-12-01 18:00:40 +000079 level to being at S-EL2. It defaults to enabled (value 1) when
Olivier Deprezb5dd2422021-04-30 14:42:24 +020080 SPD=spmd is chosen.
Marc Bonnici1d63ae42021-12-01 18:00:40 +000081- **SPMC_AT_EL3**: this option adjusts the SPMC exception level to being
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -050082 at EL3. If neither ``SPMD_SPM_AT_SEL2`` or ``SPMC_AT_EL3`` are enabled the
83 SPMC exception level is set to S-EL1.
Olivier Deprezb5dd2422021-04-30 14:42:24 +020084 ``SPMD_SPM_AT_SEL2`` is enabled. The context save/restore routine
85 and exhaustive list of registers is visible at `[4]`_.
Nishant Sharma801cd3c2023-06-27 00:36:01 +010086- **SPMC_AT_EL3_SEL0_SP**: this option enables the support to load SEL0 SP
87 when SPMC at EL3 support is enabled.
Olivier Deprezb5dd2422021-04-30 14:42:24 +020088- **SP_LAYOUT_FILE**: this option specifies a text description file
89 providing paths to SP binary images and manifests in DTS format
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -050090 (see `[3]`_). It
Olivier Deprezb5dd2422021-04-30 14:42:24 +020091 is required when ``SPMD_SPM_AT_SEL2`` is enabled hence when multiple
Olivier Deprez9eea92a2022-04-28 18:18:36 +020092 secure partitions are to be loaded by BL2 on behalf of the SPMC.
Olivier Deprezfcb13982020-04-02 15:38:02 +020093
Govindraj Rajaf1910cc2022-11-21 13:10:40 +000094+---------------+------------------+-------------+-------------------------+
95| | SPMD_SPM_AT_SEL2 | SPMC_AT_EL3 | CTX_INCLUDE_EL2_REGS(*) |
96+---------------+------------------+-------------+-------------------------+
97| SPMC at S-EL1 | 0 | 0 | 0 |
98+---------------+------------------+-------------+-------------------------+
99| SPMC at S-EL2 | 1 (default when | 0 | 1 |
100| | SPD=spmd) | | |
101+---------------+------------------+-------------+-------------------------+
102| SPMC at EL3 | 0 | 1 | 0 |
103+---------------+------------------+-------------+-------------------------+
Olivier Deprezfcb13982020-04-02 15:38:02 +0200104
105Other combinations of such build options either break the build or are not
106supported.
107
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200108Notes:
Olivier Deprezfcb13982020-04-02 15:38:02 +0200109
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200110- Only Arm's FVP platform is supported to use with the TF-A reference software
111 stack.
Olivier Deprez9eea92a2022-04-28 18:18:36 +0200112- When ``SPMD_SPM_AT_SEL2=1``, the reference software stack assumes enablement
Sona Mathew6f2b8812024-10-24 10:00:19 -0500113 of FEAT_PAuth, FEAT_BTI and FEAT_MTE2 architecture extensions.
Govindraj Rajaf1910cc2022-11-21 13:10:40 +0000114- ``(*) CTX_INCLUDE_EL2_REGS``, this flag is |TF-A| internal and informational
115 in this table. When set, it provides the generic support for saving/restoring
116 EL2 registers required when S-EL2 firmware is present.
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200117- BL32 option is re-purposed to specify the SPMC image. It can specify either
118 the Hafnium binary path (built for the secure world) or the path to a TEE
119 binary implementing FF-A interfaces.
120- BL33 option can specify the TFTF binary or a normal world loader
Olivier Deprez9eea92a2022-04-28 18:18:36 +0200121 such as U-Boot or the UEFI framework payload.
Olivier Deprezfcb13982020-04-02 15:38:02 +0200122
Olivier Deprez9eea92a2022-04-28 18:18:36 +0200123Sample TF-A build command line when the SPMC is located at S-EL1
124(e.g. when the FEAT_SEL2 architecture extension is not implemented):
Olivier Deprezfcb13982020-04-02 15:38:02 +0200125
126.. code:: shell
127
128 make \
129 CROSS_COMPILE=aarch64-none-elf- \
130 SPD=spmd \
131 SPMD_SPM_AT_SEL2=0 \
132 BL32=<path-to-tee-binary> \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200133 BL33=<path-to-bl33-binary> \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200134 PLAT=fvp \
135 all fip
136
Olivier Deprez9eea92a2022-04-28 18:18:36 +0200137Sample TF-A build command line when FEAT_SEL2 architecture extension is
138implemented and the SPMC is located at S-EL2:
Nicola Mazzucatob2836df2023-05-01 10:19:18 +0100139
Olivier Deprezfcb13982020-04-02 15:38:02 +0200140.. code:: shell
141
142 make \
143 CROSS_COMPILE=aarch64-none-elf- \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200144 PLAT=fvp \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200145 SPD=spmd \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200146 ARM_ARCH_MINOR=5 \
147 BRANCH_PROTECTION=1 \
148 CTX_INCLUDE_PAUTH_REGS=1 \
Govindraj Rajac2823842024-03-07 14:42:20 -0600149 ENABLE_FEAT_MTE2=1 \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200150 BL32=<path-to-hafnium-binary> \
151 BL33=<path-to-bl33-binary> \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200152 SP_LAYOUT_FILE=sp_layout.json \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200153 all fip
154
Olivier Deprez9eea92a2022-04-28 18:18:36 +0200155Sample TF-A build command line when FEAT_SEL2 architecture extension is
156implemented, the SPMC is located at S-EL2, and enabling secure boot:
Nicola Mazzucatob2836df2023-05-01 10:19:18 +0100157
Olivier Deprezfcb13982020-04-02 15:38:02 +0200158.. code:: shell
159
160 make \
161 CROSS_COMPILE=aarch64-none-elf- \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200162 PLAT=fvp \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200163 SPD=spmd \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200164 ARM_ARCH_MINOR=5 \
165 BRANCH_PROTECTION=1 \
166 CTX_INCLUDE_PAUTH_REGS=1 \
Govindraj Rajac2823842024-03-07 14:42:20 -0600167 ENABLE_FEAT_MTE2=1 \
Olivier Deprezb5dd2422021-04-30 14:42:24 +0200168 BL32=<path-to-hafnium-binary> \
169 BL33=<path-to-bl33-binary> \
170 SP_LAYOUT_FILE=sp_layout.json \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200171 MBEDTLS_DIR=<path-to-mbedtls-lib> \
172 TRUSTED_BOARD_BOOT=1 \
173 COT=dualroot \
174 ARM_ROTPK_LOCATION=devel_rsa \
175 ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \
176 GENERATE_COT=1 \
Olivier Deprezfcb13982020-04-02 15:38:02 +0200177 all fip
178
Olivier Deprez9eea92a2022-04-28 18:18:36 +0200179Sample TF-A build command line when the SPMC is located at EL3:
Marc Bonnici1d63ae42021-12-01 18:00:40 +0000180
181.. code:: shell
182
183 make \
184 CROSS_COMPILE=aarch64-none-elf- \
185 SPD=spmd \
186 SPMD_SPM_AT_SEL2=0 \
187 SPMC_AT_EL3=1 \
188 BL32=<path-to-tee-binary> \
189 BL33=<path-to-bl33-binary> \
190 PLAT=fvp \
191 all fip
192
Nishant Sharma801cd3c2023-06-27 00:36:01 +0100193Sample TF-A build command line when the SPMC is located at EL3 and SEL0 SP is
194enabled:
195
196.. code:: shell
197
198 make \
199 CROSS_COMPILE=aarch64-none-elf- \
200 SPD=spmd \
201 SPMD_SPM_AT_SEL2=0 \
202 SPMC_AT_EL3=1 \
203 SPMC_AT_EL3_SEL0_SP=1 \
204 BL32=<path-to-tee-binary> \
205 BL33=<path-to-bl33-binary> \
206 PLAT=fvp \
207 all fip
208
Olivier Deprezfcb13982020-04-02 15:38:02 +0200209Boot process
210============
211
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500212The boot process involving SPMC is highly dependent on the SPMC implementation.
213It is recommended to refer to corresponding SPMC documentation for further
214details. Some aspects of boot process are described here in the greater interest
215of the project.
Olivier Deprezfcb13982020-04-02 15:38:02 +0200216
217SPMC boot
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500218---------
Olivier Deprezfcb13982020-04-02 15:38:02 +0200219
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500220When SPMC resides at a lower EL i.e., S-EL1 or S-EL2, it is loaded by BL2 as the
221BL32 image. The SPMC manifest is loaded by BL2 as the ``TOS_FW_CONFIG`` image `[7]`_.
Olivier Deprezfcb13982020-04-02 15:38:02 +0200222
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500223BL2 passes the SPMC manifest address to BL31 through a register. At boot time,
224the SPMD in BL31 runs from the primary core, initializes the core contexts and
225launches the SPMC (BL32) passing the following information through registers:
Olivier Deprezf2dcf412021-06-21 09:47:13 +0200226
227- X0 holds the ``TOS_FW_CONFIG`` physical address (or SPMC manifest blob).
228- X1 holds the ``HW_CONFIG`` physical address.
229- X4 holds the currently running core linear id.
Olivier Deprezfcb13982020-04-02 15:38:02 +0200230
Raghu Krishnamurthyaeea04d2021-10-17 16:48:29 -0700231
Olivier Deprezfcb13982020-04-02 15:38:02 +0200232References
233==========
234
235.. _[1]:
236
Olivier Deprez8a5bd3c2021-09-01 10:25:21 +0200237[1] `Arm Firmware Framework for Arm A-profile <https://developer.arm.com/docs/den0077/latest>`__
Olivier Deprezfcb13982020-04-02 15:38:02 +0200238
239.. _[2]:
240
Madhukar Pappireddy6844c342020-07-29 09:37:25 -0500241[2] :ref:`Secure Partition Manager using MM interface<Secure Partition Manager (MM)>`
Olivier Deprezfcb13982020-04-02 15:38:02 +0200242
243.. _[3]:
244
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500245[3] https://hafnium.readthedocs.io/en/latest/secure-partition-manager/secure-partition-manager.html#secure-partitions-layout-file
Olivier Deprezfcb13982020-04-02 15:38:02 +0200246
247.. _[4]:
248
249[4] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime/aarch64/context.S#n45
250
251.. _[5]:
252
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500253[5] https://hafnium.readthedocs.io/en/latest/secure-partition-manager/index.html
Olivier Deprezfcb13982020-04-02 15:38:02 +0200254
255.. _[6]:
256
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500257[6] :ref:`EL3 Secure Partition Manager<EL3 Secure Partition Manager>`
Olivier Deprezfcb13982020-04-02 15:38:02 +0200258
259.. _[7]:
260
Madhukar Pappireddy65e573f2024-07-25 17:23:55 -0500261[7] https://trustedfirmware-a.readthedocs.io/en/latest/design/firmware-design.html#dynamic-configuration-during-cold-boot
Olivier Deprezf2dcf412021-06-21 09:47:13 +0200262
Olivier Deprezfcb13982020-04-02 15:38:02 +0200263--------------
264
Govindraj Raja0a33adc2023-12-21 13:57:49 -0600265*Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.*