secure-partition-manager.rst 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. Secure Partition Manager
  2. ************************
  3. .. contents::
  4. .. toctree::
  5. ffa-manifest-binding
  6. Acronyms
  7. ========
  8. +--------+--------------------------------------+
  9. | DTS | Device Tree Source |
  10. +--------+--------------------------------------+
  11. | FF-A | Firmware Framework for Arm A-profile |
  12. +--------+--------------------------------------+
  13. | NWd | Normal World |
  14. +--------+--------------------------------------+
  15. | SP | Secure Partition |
  16. +--------+--------------------------------------+
  17. | SPD | Secure Payload Dispatcher |
  18. +--------+--------------------------------------+
  19. | SPM | Secure Partition Manager |
  20. +--------+--------------------------------------+
  21. | SPMC | SPM Core |
  22. +--------+--------------------------------------+
  23. | SPMD | SPM Dispatcher |
  24. +--------+--------------------------------------+
  25. | SWd | Secure World |
  26. +--------+--------------------------------------+
  27. Foreword
  28. ========
  29. Three implementations of a Secure Partition Manager co-exist in the TF-A
  30. codebase:
  31. #. S-EL2 SPMC based on the FF-A specification `[1]`_, enabling virtualization in
  32. the secure world, managing multiple S-EL1 or S-EL0 partitions `[5]`_.
  33. #. EL3 SPMC based on the FF-A specification, managing a single S-EL1 partition
  34. without virtualization in the secure world `[6]`_.
  35. #. EL3 SPM based on the MM specification, legacy implementation managing a
  36. single S-EL0 partition `[2]`_.
  37. These implementations differ in their respective SW architecture and only one
  38. can be selected at build time.
  39. Support for legacy platforms
  40. ----------------------------
  41. The SPM is split into a dispatcher and a core component (respectively SPMD and
  42. SPMC) residing at different exception levels. To permit the FF-A specification
  43. adoption and a smooth migration, the SPMD supports an SPMC residing either at
  44. S-EL1 or S-EL2:
  45. - The SPMD is located at EL3 and mainly relays the FF-A protocol from NWd
  46. (Hypervisor or OS kernel) to the SPMC.
  47. - The same SPMD component is used for both S-EL1 and S-EL2 SPMC configurations.
  48. - The SPMC exception level is a build time choice.
  49. TF-A supports both cases:
  50. - S-EL1 SPMC for platforms not supporting the FEAT_SEL2 architecture
  51. extension. The SPMD relays the FF-A protocol from EL3 to S-EL1.
  52. - S-EL2 SPMC for platforms implementing the FEAT_SEL2 architecture
  53. extension. The SPMD relays the FF-A protocol from EL3 to S-EL2.
  54. TF-A build options
  55. ==================
  56. This section explains the TF-A build options involved in building with
  57. support for an FF-A based SPM where the SPMD is located at EL3 and the
  58. SPMC located at S-EL1, S-EL2 or EL3:
  59. - **SPD=spmd**: this option selects the SPMD component to relay the FF-A
  60. protocol from NWd to SWd back and forth. It is not possible to
  61. enable another Secure Payload Dispatcher when this option is chosen.
  62. - **SPMD_SPM_AT_SEL2**: this option adjusts the SPMC exception
  63. level to being at S-EL2. It defaults to enabled (value 1) when
  64. SPD=spmd is chosen.
  65. - **SPMC_AT_EL3**: this option adjusts the SPMC exception level to being
  66. at EL3. If neither ``SPMD_SPM_AT_SEL2`` or ``SPMC_AT_EL3`` are enabled the
  67. SPMC exception level is set to S-EL1.
  68. ``SPMD_SPM_AT_SEL2`` is enabled. The context save/restore routine
  69. and exhaustive list of registers is visible at `[4]`_.
  70. - **SPMC_AT_EL3_SEL0_SP**: this option enables the support to load SEL0 SP
  71. when SPMC at EL3 support is enabled.
  72. - **SP_LAYOUT_FILE**: this option specifies a text description file
  73. providing paths to SP binary images and manifests in DTS format
  74. (see `[3]`_). It
  75. is required when ``SPMD_SPM_AT_SEL2`` is enabled hence when multiple
  76. secure partitions are to be loaded by BL2 on behalf of the SPMC.
  77. +---------------+------------------+-------------+-------------------------+
  78. | | SPMD_SPM_AT_SEL2 | SPMC_AT_EL3 | CTX_INCLUDE_EL2_REGS(*) |
  79. +---------------+------------------+-------------+-------------------------+
  80. | SPMC at S-EL1 | 0 | 0 | 0 |
  81. +---------------+------------------+-------------+-------------------------+
  82. | SPMC at S-EL2 | 1 (default when | 0 | 1 |
  83. | | SPD=spmd) | | |
  84. +---------------+------------------+-------------+-------------------------+
  85. | SPMC at EL3 | 0 | 1 | 0 |
  86. +---------------+------------------+-------------+-------------------------+
  87. Other combinations of such build options either break the build or are not
  88. supported.
  89. Notes:
  90. - Only Arm's FVP platform is supported to use with the TF-A reference software
  91. stack.
  92. - When ``SPMD_SPM_AT_SEL2=1``, the reference software stack assumes enablement
  93. of FEAT_PAuth, FEAT_BTI and FEAT_MTE2 architecture extensions.
  94. - ``(*) CTX_INCLUDE_EL2_REGS``, this flag is |TF-A| internal and informational
  95. in this table. When set, it provides the generic support for saving/restoring
  96. EL2 registers required when S-EL2 firmware is present.
  97. - BL32 option is re-purposed to specify the SPMC image. It can specify either
  98. the Hafnium binary path (built for the secure world) or the path to a TEE
  99. binary implementing FF-A interfaces.
  100. - BL33 option can specify the TFTF binary or a normal world loader
  101. such as U-Boot or the UEFI framework payload.
  102. Sample TF-A build command line when the SPMC is located at S-EL1
  103. (e.g. when the FEAT_SEL2 architecture extension is not implemented):
  104. .. code:: shell
  105. make \
  106. CROSS_COMPILE=aarch64-none-elf- \
  107. SPD=spmd \
  108. SPMD_SPM_AT_SEL2=0 \
  109. BL32=<path-to-tee-binary> \
  110. BL33=<path-to-bl33-binary> \
  111. PLAT=fvp \
  112. all fip
  113. Sample TF-A build command line when FEAT_SEL2 architecture extension is
  114. implemented and the SPMC is located at S-EL2:
  115. .. code:: shell
  116. make \
  117. CROSS_COMPILE=aarch64-none-elf- \
  118. PLAT=fvp \
  119. SPD=spmd \
  120. ARM_ARCH_MINOR=5 \
  121. BRANCH_PROTECTION=1 \
  122. CTX_INCLUDE_PAUTH_REGS=1 \
  123. ENABLE_FEAT_MTE2=1 \
  124. BL32=<path-to-hafnium-binary> \
  125. BL33=<path-to-bl33-binary> \
  126. SP_LAYOUT_FILE=sp_layout.json \
  127. all fip
  128. Sample TF-A build command line when FEAT_SEL2 architecture extension is
  129. implemented, the SPMC is located at S-EL2, and enabling secure boot:
  130. .. code:: shell
  131. make \
  132. CROSS_COMPILE=aarch64-none-elf- \
  133. PLAT=fvp \
  134. SPD=spmd \
  135. ARM_ARCH_MINOR=5 \
  136. BRANCH_PROTECTION=1 \
  137. CTX_INCLUDE_PAUTH_REGS=1 \
  138. ENABLE_FEAT_MTE2=1 \
  139. BL32=<path-to-hafnium-binary> \
  140. BL33=<path-to-bl33-binary> \
  141. SP_LAYOUT_FILE=sp_layout.json \
  142. MBEDTLS_DIR=<path-to-mbedtls-lib> \
  143. TRUSTED_BOARD_BOOT=1 \
  144. COT=dualroot \
  145. ARM_ROTPK_LOCATION=devel_rsa \
  146. ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \
  147. GENERATE_COT=1 \
  148. all fip
  149. Sample TF-A build command line when the SPMC is located at EL3:
  150. .. code:: shell
  151. make \
  152. CROSS_COMPILE=aarch64-none-elf- \
  153. SPD=spmd \
  154. SPMD_SPM_AT_SEL2=0 \
  155. SPMC_AT_EL3=1 \
  156. BL32=<path-to-tee-binary> \
  157. BL33=<path-to-bl33-binary> \
  158. PLAT=fvp \
  159. all fip
  160. Sample TF-A build command line when the SPMC is located at EL3 and SEL0 SP is
  161. enabled:
  162. .. code:: shell
  163. make \
  164. CROSS_COMPILE=aarch64-none-elf- \
  165. SPD=spmd \
  166. SPMD_SPM_AT_SEL2=0 \
  167. SPMC_AT_EL3=1 \
  168. SPMC_AT_EL3_SEL0_SP=1 \
  169. BL32=<path-to-tee-binary> \
  170. BL33=<path-to-bl33-binary> \
  171. PLAT=fvp \
  172. all fip
  173. Boot process
  174. ============
  175. The boot process involving SPMC is highly dependent on the SPMC implementation.
  176. It is recommended to refer to corresponding SPMC documentation for further
  177. details. Some aspects of boot process are described here in the greater interest
  178. of the project.
  179. SPMC boot
  180. ---------
  181. When SPMC resides at a lower EL i.e., S-EL1 or S-EL2, it is loaded by BL2 as the
  182. BL32 image. The SPMC manifest is loaded by BL2 as the ``TOS_FW_CONFIG`` image `[7]`_.
  183. BL2 passes the SPMC manifest address to BL31 through a register. At boot time,
  184. the SPMD in BL31 runs from the primary core, initializes the core contexts and
  185. launches the SPMC (BL32) passing the following information through registers:
  186. - X0 holds the ``TOS_FW_CONFIG`` physical address (or SPMC manifest blob).
  187. - X1 holds the ``HW_CONFIG`` physical address.
  188. - X4 holds the currently running core linear id.
  189. References
  190. ==========
  191. .. _[1]:
  192. [1] `Arm Firmware Framework for Arm A-profile <https://developer.arm.com/docs/den0077/latest>`__
  193. .. _[2]:
  194. [2] :ref:`Secure Partition Manager using MM interface<Secure Partition Manager (MM)>`
  195. .. _[3]:
  196. [3] https://hafnium.readthedocs.io/en/latest/secure-partition-manager/secure-partition-manager.html#secure-partitions-layout-file
  197. .. _[4]:
  198. [4] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime/aarch64/context.S#n45
  199. .. _[5]:
  200. [5] https://hafnium.readthedocs.io/en/latest/secure-partition-manager/index.html
  201. .. _[6]:
  202. [6] :ref:`EL3 Secure Partition Manager<EL3 Secure Partition Manager>`
  203. .. _[7]:
  204. [7] https://trustedfirmware-a.readthedocs.io/en/latest/design/firmware-design.html#dynamic-configuration-during-cold-boot
  205. --------------
  206. *Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.*