Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1 | Secure Partition Manager |
| 2 | ************************ |
| 3 | |
| 4 | .. contents:: |
| 5 | |
| 6 | Acronyms |
| 7 | ======== |
| 8 | |
Olivier Deprez | 2b0be75 | 2021-09-01 10:25:21 +0200 | [diff] [blame] | 9 | +--------+--------------------------------------+ |
| 10 | | CoT | Chain of Trust | |
| 11 | +--------+--------------------------------------+ |
| 12 | | DMA | Direct Memory Access | |
| 13 | +--------+--------------------------------------+ |
| 14 | | DTB | Device Tree Blob | |
| 15 | +--------+--------------------------------------+ |
| 16 | | DTS | Device Tree Source | |
| 17 | +--------+--------------------------------------+ |
| 18 | | EC | Execution Context | |
| 19 | +--------+--------------------------------------+ |
| 20 | | FIP | Firmware Image Package | |
| 21 | +--------+--------------------------------------+ |
| 22 | | FF-A | Firmware Framework for Arm A-profile | |
| 23 | +--------+--------------------------------------+ |
| 24 | | IPA | Intermediate Physical Address | |
| 25 | +--------+--------------------------------------+ |
| 26 | | NWd | Normal World | |
| 27 | +--------+--------------------------------------+ |
| 28 | | ODM | Original Design Manufacturer | |
| 29 | +--------+--------------------------------------+ |
| 30 | | OEM | Original Equipment Manufacturer | |
| 31 | +--------+--------------------------------------+ |
| 32 | | PA | Physical Address | |
| 33 | +--------+--------------------------------------+ |
| 34 | | PE | Processing Element | |
| 35 | +--------+--------------------------------------+ |
| 36 | | PM | Power Management | |
| 37 | +--------+--------------------------------------+ |
| 38 | | PVM | Primary VM | |
| 39 | +--------+--------------------------------------+ |
| 40 | | SMMU | System Memory Management Unit | |
| 41 | +--------+--------------------------------------+ |
| 42 | | SP | Secure Partition | |
| 43 | +--------+--------------------------------------+ |
| 44 | | SPD | Secure Payload Dispatcher | |
| 45 | +--------+--------------------------------------+ |
| 46 | | SPM | Secure Partition Manager | |
| 47 | +--------+--------------------------------------+ |
| 48 | | SPMC | SPM Core | |
| 49 | +--------+--------------------------------------+ |
| 50 | | SPMD | SPM Dispatcher | |
| 51 | +--------+--------------------------------------+ |
| 52 | | SiP | Silicon Provider | |
| 53 | +--------+--------------------------------------+ |
| 54 | | SWd | Secure World | |
| 55 | +--------+--------------------------------------+ |
| 56 | | TLV | Tag-Length-Value | |
| 57 | +--------+--------------------------------------+ |
| 58 | | TOS | Trusted Operating System | |
| 59 | +--------+--------------------------------------+ |
| 60 | | VM | Virtual Machine | |
| 61 | +--------+--------------------------------------+ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 62 | |
| 63 | Foreword |
| 64 | ======== |
| 65 | |
| 66 | Two implementations of a Secure Partition Manager co-exist in the TF-A codebase: |
| 67 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 68 | - SPM based on the FF-A specification `[1]`_. |
| 69 | - SPM based on the MM interface to communicate with an S-EL0 partition `[2]`_. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 70 | |
| 71 | Both implementations differ in their architectures and only one can be selected |
| 72 | at build time. |
| 73 | |
| 74 | This document: |
| 75 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 76 | - describes the FF-A implementation where the Secure Partition Manager |
| 77 | resides at EL3 and S-EL2 (or EL3 and S-EL1). |
| 78 | - is not an architecture specification and it might provide assumptions |
| 79 | on sections mandated as implementation-defined in the specification. |
| 80 | - covers the implications to TF-A used as a bootloader, and Hafnium |
| 81 | used as a reference code base for an S-EL2 secure firmware on |
| 82 | platforms implementing the FEAT_SEL2 (formerly Armv8.4 Secure EL2) |
| 83 | architecture extension. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 84 | |
| 85 | Terminology |
| 86 | ----------- |
| 87 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 88 | - The term Hypervisor refers to the NS-EL2 component managing Virtual Machines |
| 89 | (or partitions) in the normal world. |
| 90 | - The term SPMC refers to the S-EL2 component managing secure partitions in |
| 91 | the secure world when the FEAT_SEL2 architecture extension is implemented. |
| 92 | - Alternatively, SPMC can refer to an S-EL1 component, itself being a secure |
| 93 | partition and implementing the FF-A ABI on platforms not implementing the |
| 94 | FEAT_SEL2 architecture extension. |
| 95 | - The term VM refers to a normal world Virtual Machine managed by an Hypervisor. |
| 96 | - The term SP refers to a secure world "Virtual Machine" managed by an SPMC. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 97 | |
| 98 | Support for legacy platforms |
| 99 | ---------------------------- |
| 100 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 101 | In the implementation, the SPM is split into SPMD and SPMC components. |
| 102 | The SPMD is located at EL3 and mainly relays FF-A messages from |
| 103 | NWd (Hypervisor or OS kernel) to SPMC located either at S-EL1 or S-EL2. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 104 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 105 | Hence TF-A supports both cases where the SPMC is located either at: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 106 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 107 | - S-EL1 supporting platforms not implementing the FEAT_SEL2 architecture |
| 108 | extension. The SPMD relays the FF-A protocol from EL3 to S-EL1. |
| 109 | - or S-EL2 supporting platforms implementing the FEAT_SEL2 architecture |
| 110 | extension. The SPMD relays the FF-A protocol from EL3 to S-EL2. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 111 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 112 | The same TF-A SPMD component is used to support both configurations. |
| 113 | The SPMC exception level is a build time choice. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 114 | |
| 115 | Sample reference stack |
| 116 | ====================== |
| 117 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 118 | The following diagram illustrates a possible configuration when the |
| 119 | FEAT_SEL2 architecture extension is implemented, showing the SPMD |
| 120 | and SPMC, one or multiple secure partitions, with an optional |
| 121 | Hypervisor: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 122 | |
| 123 | .. image:: ../resources/diagrams/ff-a-spm-sel2.png |
| 124 | |
| 125 | TF-A build options |
| 126 | ================== |
| 127 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 128 | This section explains the TF-A build options involved in building with |
| 129 | support for an FF-A based SPM where the SPMD is located at EL3 and the |
Marc Bonnici | abaac16 | 2021-12-01 18:00:40 +0000 | [diff] [blame] | 130 | SPMC located at S-EL1, S-EL2 or EL3: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 131 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 132 | - **SPD=spmd**: this option selects the SPMD component to relay the FF-A |
| 133 | protocol from NWd to SWd back and forth. It is not possible to |
| 134 | enable another Secure Payload Dispatcher when this option is chosen. |
| 135 | - **SPMD_SPM_AT_SEL2**: this option adjusts the SPMC exception |
Marc Bonnici | abaac16 | 2021-12-01 18:00:40 +0000 | [diff] [blame] | 136 | level to being at S-EL2. It defaults to enabled (value 1) when |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 137 | SPD=spmd is chosen. |
Marc Bonnici | abaac16 | 2021-12-01 18:00:40 +0000 | [diff] [blame] | 138 | - **SPMC_AT_EL3**: this option adjusts the SPMC exception level to being |
| 139 | at EL3. |
| 140 | - If neither **SPMD_SPM_AT_SEL2** or **SPMC_AT_EL3** are enabled the SPMC |
| 141 | exception level is set to S-EL1. |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 142 | - **CTX_INCLUDE_EL2_REGS**: this option permits saving (resp. |
| 143 | restoring) the EL2 system register context before entering (resp. |
| 144 | after leaving) the SPMC. It is mandatorily enabled when |
| 145 | ``SPMD_SPM_AT_SEL2`` is enabled. The context save/restore routine |
| 146 | and exhaustive list of registers is visible at `[4]`_. |
| 147 | - **SP_LAYOUT_FILE**: this option specifies a text description file |
| 148 | providing paths to SP binary images and manifests in DTS format |
| 149 | (see `Describing secure partitions`_). It |
| 150 | is required when ``SPMD_SPM_AT_SEL2`` is enabled hence when multiple |
| 151 | secure partitions are to be loaded on behalf of the SPMC. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 152 | |
Marc Bonnici | abaac16 | 2021-12-01 18:00:40 +0000 | [diff] [blame] | 153 | +---------------+----------------------+------------------+-------------+ |
| 154 | | | CTX_INCLUDE_EL2_REGS | SPMD_SPM_AT_SEL2 | SPMC_AT_EL3 | |
| 155 | +---------------+----------------------+------------------+-------------+ |
| 156 | | SPMC at S-EL1 | 0 | 0 | 0 | |
| 157 | +---------------+----------------------+------------------+-------------+ |
| 158 | | SPMC at S-EL2 | 1 | 1 (default when | 0 | |
| 159 | | | | SPD=spmd) | | |
| 160 | +---------------+----------------------+------------------+-------------+ |
| 161 | | SPMC at EL3 | 0 | 0 | 1 | |
| 162 | +---------------+----------------------+------------------+-------------+ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 163 | |
| 164 | Other combinations of such build options either break the build or are not |
| 165 | supported. |
| 166 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 167 | Notes: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 168 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 169 | - Only Arm's FVP platform is supported to use with the TF-A reference software |
| 170 | stack. |
| 171 | - The reference software stack uses FEAT_PAuth (formerly Armv8.3-PAuth) and |
| 172 | FEAT_BTI (formerly Armv8.5-BTI) architecture extensions by default at EL3 |
| 173 | and S-EL2. |
| 174 | - The ``CTX_INCLUDE_EL2_REGS`` option provides the generic support for |
| 175 | barely saving/restoring EL2 registers from an Arm arch perspective. As such |
| 176 | it is decoupled from the ``SPD=spmd`` option. |
| 177 | - BL32 option is re-purposed to specify the SPMC image. It can specify either |
| 178 | the Hafnium binary path (built for the secure world) or the path to a TEE |
| 179 | binary implementing FF-A interfaces. |
| 180 | - BL33 option can specify the TFTF binary or a normal world loader |
| 181 | such as U-Boot or the UEFI framework. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 182 | |
| 183 | Sample TF-A build command line when SPMC is located at S-EL1 |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 184 | (e.g. when the FEAT_EL2 architecture extension is not implemented): |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 185 | |
| 186 | .. code:: shell |
| 187 | |
| 188 | make \ |
| 189 | CROSS_COMPILE=aarch64-none-elf- \ |
| 190 | SPD=spmd \ |
| 191 | SPMD_SPM_AT_SEL2=0 \ |
| 192 | BL32=<path-to-tee-binary> \ |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 193 | BL33=<path-to-bl33-binary> \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 194 | PLAT=fvp \ |
| 195 | all fip |
| 196 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 197 | Sample TF-A build command line for a FEAT_SEL2 enabled system where the SPMC is |
| 198 | located at S-EL2: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 199 | |
| 200 | .. code:: shell |
| 201 | |
| 202 | make \ |
| 203 | CROSS_COMPILE=aarch64-none-elf- \ |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 204 | PLAT=fvp \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 205 | SPD=spmd \ |
| 206 | CTX_INCLUDE_EL2_REGS=1 \ |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 207 | ARM_ARCH_MINOR=5 \ |
| 208 | BRANCH_PROTECTION=1 \ |
| 209 | CTX_INCLUDE_PAUTH_REGS=1 \ |
| 210 | BL32=<path-to-hafnium-binary> \ |
| 211 | BL33=<path-to-bl33-binary> \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 212 | SP_LAYOUT_FILE=sp_layout.json \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 213 | all fip |
| 214 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 215 | Same as above with enabling secure boot in addition: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 216 | |
| 217 | .. code:: shell |
| 218 | |
| 219 | make \ |
| 220 | CROSS_COMPILE=aarch64-none-elf- \ |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 221 | PLAT=fvp \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 222 | SPD=spmd \ |
| 223 | CTX_INCLUDE_EL2_REGS=1 \ |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 224 | ARM_ARCH_MINOR=5 \ |
| 225 | BRANCH_PROTECTION=1 \ |
| 226 | CTX_INCLUDE_PAUTH_REGS=1 \ |
| 227 | BL32=<path-to-hafnium-binary> \ |
| 228 | BL33=<path-to-bl33-binary> \ |
| 229 | SP_LAYOUT_FILE=sp_layout.json \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 230 | MBEDTLS_DIR=<path-to-mbedtls-lib> \ |
| 231 | TRUSTED_BOARD_BOOT=1 \ |
| 232 | COT=dualroot \ |
| 233 | ARM_ROTPK_LOCATION=devel_rsa \ |
| 234 | ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \ |
| 235 | GENERATE_COT=1 \ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 236 | all fip |
| 237 | |
Marc Bonnici | abaac16 | 2021-12-01 18:00:40 +0000 | [diff] [blame] | 238 | Sample TF-A build command line when SPMC is located at EL3: |
| 239 | |
| 240 | .. code:: shell |
| 241 | |
| 242 | make \ |
| 243 | CROSS_COMPILE=aarch64-none-elf- \ |
| 244 | SPD=spmd \ |
| 245 | SPMD_SPM_AT_SEL2=0 \ |
| 246 | SPMC_AT_EL3=1 \ |
| 247 | BL32=<path-to-tee-binary> \ |
| 248 | BL33=<path-to-bl33-binary> \ |
| 249 | PLAT=fvp \ |
| 250 | all fip |
| 251 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 252 | FVP model invocation |
| 253 | ==================== |
| 254 | |
| 255 | The FVP command line needs the following options to exercise the S-EL2 SPMC: |
| 256 | |
| 257 | +---------------------------------------------------+------------------------------------+ |
| 258 | | - cluster0.has_arm_v8-5=1 | Implements FEAT_SEL2, FEAT_PAuth, | |
| 259 | | - cluster1.has_arm_v8-5=1 | and FEAT_BTI. | |
| 260 | +---------------------------------------------------+------------------------------------+ |
| 261 | | - pci.pci_smmuv3.mmu.SMMU_AIDR=2 | Parameters required for the | |
| 262 | | - pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B | SMMUv3.2 modeling. | |
| 263 | | - pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002 | | |
| 264 | | - pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714 | | |
| 265 | | - pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0472 | | |
| 266 | | - pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002 | | |
| 267 | | - pci.pci_smmuv3.mmu.SMMU_S_IDR2=0 | | |
| 268 | | - pci.pci_smmuv3.mmu.SMMU_S_IDR3=0 | | |
| 269 | +---------------------------------------------------+------------------------------------+ |
| 270 | | - cluster0.has_branch_target_exception=1 | Implements FEAT_BTI. | |
| 271 | | - cluster1.has_branch_target_exception=1 | | |
| 272 | +---------------------------------------------------+------------------------------------+ |
| 273 | | - cluster0.restriction_on_speculative_execution=2 | Required by the EL2 context | |
| 274 | | - cluster1.restriction_on_speculative_execution=2 | save/restore routine. | |
| 275 | +---------------------------------------------------+------------------------------------+ |
| 276 | |
| 277 | Sample FVP command line invocation: |
| 278 | |
| 279 | .. code:: shell |
| 280 | |
| 281 | <path-to-fvp-model>/FVP_Base_RevC-2xAEMv8A -C pctl.startup=0.0.0.0 |
| 282 | -C cluster0.NUM_CORES=4 -C cluster1.NUM_CORES=4 -C bp.secure_memory=1 \ |
| 283 | -C bp.secureflashloader.fname=trusted-firmware-a/build/fvp/debug/bl1.bin \ |
| 284 | -C bp.flashloader0.fname=trusted-firmware-a/build/fvp/debug/fip.bin \ |
| 285 | -C bp.pl011_uart0.out_file=fvp-uart0.log -C bp.pl011_uart1.out_file=fvp-uart1.log \ |
| 286 | -C bp.pl011_uart2.out_file=fvp-uart2.log \ |
| 287 | -C cluster0.has_arm_v8-5=1 -C cluster1.has_arm_v8-5=1 -C pci.pci_smmuv3.mmu.SMMU_AIDR=2 \ |
| 288 | -C pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B -C pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002 \ |
| 289 | -C pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714 -C pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0472 \ |
| 290 | -C pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002 -C pci.pci_smmuv3.mmu.SMMU_S_IDR2=0 \ |
| 291 | -C pci.pci_smmuv3.mmu.SMMU_S_IDR3=0 \ |
| 292 | -C cluster0.has_branch_target_exception=1 \ |
| 293 | -C cluster1.has_branch_target_exception=1 \ |
| 294 | -C cluster0.restriction_on_speculative_execution=2 \ |
| 295 | -C cluster1.restriction_on_speculative_execution=2 |
| 296 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 297 | Boot process |
| 298 | ============ |
| 299 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 300 | Loading Hafnium and secure partitions in the secure world |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 301 | --------------------------------------------------------- |
| 302 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 303 | TF-A BL2 is the bootlader for the SPMC and SPs in the secure world. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 304 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 305 | SPs may be signed by different parties (SiP, OEM/ODM, TOS vendor, etc.). |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 306 | Thus they are supplied as distinct signed entities within the FIP flash |
| 307 | image. The FIP image itself is not signed hence this provides the ability |
| 308 | to upgrade SPs in the field. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 309 | |
| 310 | Booting through TF-A |
| 311 | -------------------- |
| 312 | |
| 313 | SP manifests |
| 314 | ~~~~~~~~~~~~ |
| 315 | |
| 316 | An SP manifest describes SP attributes as defined in `[1]`_ |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 317 | (partition manifest at virtual FF-A instance) in DTS format. It is |
| 318 | represented as a single file associated with the SP. A sample is |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 319 | provided by `[5]`_. A binding document is provided by `[6]`_. |
| 320 | |
| 321 | Secure Partition packages |
| 322 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 323 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 324 | Secure partitions are bundled as independent package files consisting |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 325 | of: |
| 326 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 327 | - a header |
| 328 | - a DTB |
| 329 | - an image payload |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 330 | |
| 331 | The header starts with a magic value and offset values to SP DTB and |
| 332 | image payload. Each SP package is loaded independently by BL2 loader |
| 333 | and verified for authenticity and integrity. |
| 334 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 335 | The SP package identified by its UUID (matching FF-A uuid property) is |
| 336 | inserted as a single entry into the FIP at end of the TF-A build flow |
| 337 | as shown: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 338 | |
| 339 | .. code:: shell |
| 340 | |
| 341 | Trusted Boot Firmware BL2: offset=0x1F0, size=0x8AE1, cmdline="--tb-fw" |
| 342 | EL3 Runtime Firmware BL31: offset=0x8CD1, size=0x13000, cmdline="--soc-fw" |
| 343 | Secure Payload BL32 (Trusted OS): offset=0x1BCD1, size=0x15270, cmdline="--tos-fw" |
| 344 | Non-Trusted Firmware BL33: offset=0x30F41, size=0x92E0, cmdline="--nt-fw" |
| 345 | HW_CONFIG: offset=0x3A221, size=0x2348, cmdline="--hw-config" |
| 346 | TB_FW_CONFIG: offset=0x3C569, size=0x37A, cmdline="--tb-fw-config" |
| 347 | SOC_FW_CONFIG: offset=0x3C8E3, size=0x48, cmdline="--soc-fw-config" |
| 348 | TOS_FW_CONFIG: offset=0x3C92B, size=0x427, cmdline="--tos-fw-config" |
| 349 | NT_FW_CONFIG: offset=0x3CD52, size=0x48, cmdline="--nt-fw-config" |
| 350 | B4B5671E-4A90-4FE1-B81F-FB13DAE1DACB: offset=0x3CD9A, size=0xC168, cmdline="--blob" |
| 351 | D1582309-F023-47B9-827C-4464F5578FC8: offset=0x48F02, size=0xC168, cmdline="--blob" |
| 352 | |
| 353 | .. uml:: ../resources/diagrams/plantuml/fip-secure-partitions.puml |
| 354 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 355 | Describing secure partitions |
| 356 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 357 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 358 | A json-formatted description file is passed to the build flow specifying paths |
| 359 | to the SP binary image and associated DTS partition manifest file. The latter |
| 360 | is processed by the dtc compiler to generate a DTB fed into the SP package. |
| 361 | This file also specifies the SP owner (as an optional field) identifying the |
| 362 | signing domain in case of dual root CoT. |
| 363 | The SP owner can either be the silicon or the platform provider. The |
| 364 | corresponding "owner" field value can either take the value of "SiP" or "Plat". |
| 365 | In absence of "owner" field, it defaults to "SiP" owner. |
Imre Kis | 3f370fd | 2022-02-08 18:06:18 +0100 | [diff] [blame] | 366 | The UUID of the partition can be specified as a field in the description file or |
| 367 | if it does not exist there the UUID is extracted from the DTS partition |
| 368 | manifest. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 369 | |
| 370 | .. code:: shell |
| 371 | |
| 372 | { |
| 373 | "tee1" : { |
| 374 | "image": "tee1.bin", |
Manish Pandey | 7787096 | 2020-08-12 17:06:25 +0100 | [diff] [blame] | 375 | "pm": "tee1.dts", |
Imre Kis | 3f370fd | 2022-02-08 18:06:18 +0100 | [diff] [blame] | 376 | "owner": "SiP", |
| 377 | "uuid": "1b1820fe-48f7-4175-8999-d51da00b7c9f" |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 378 | }, |
| 379 | |
| 380 | "tee2" : { |
| 381 | "image": "tee2.bin", |
Manish Pandey | 7787096 | 2020-08-12 17:06:25 +0100 | [diff] [blame] | 382 | "pm": "tee2.dts", |
| 383 | "owner": "Plat" |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 384 | } |
| 385 | } |
| 386 | |
| 387 | SPMC manifest |
| 388 | ~~~~~~~~~~~~~ |
| 389 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 390 | This manifest contains the SPMC *attribute* node consumed by the SPMD at boot |
| 391 | time. It implements `[1]`_ (SP manifest at physical FF-A instance) and serves |
| 392 | two different cases: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 393 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 394 | - The SPMC resides at S-EL1: the SPMC manifest is used by the SPMD to setup a |
| 395 | SP that co-resides with the SPMC and executes at S-EL1 or Secure Supervisor |
| 396 | mode. |
| 397 | - The SPMC resides at S-EL2: the SPMC manifest is used by the SPMD to setup |
| 398 | the environment required by the SPMC to run at S-EL2. SPs run at S-EL1 or |
| 399 | S-EL0. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 400 | |
| 401 | .. code:: shell |
| 402 | |
| 403 | attribute { |
| 404 | spmc_id = <0x8000>; |
| 405 | maj_ver = <0x1>; |
| 406 | min_ver = <0x0>; |
| 407 | exec_state = <0x0>; |
| 408 | load_address = <0x0 0x6000000>; |
| 409 | entrypoint = <0x0 0x6000000>; |
| 410 | binary_size = <0x60000>; |
| 411 | }; |
| 412 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 413 | - *spmc_id* defines the endpoint ID value that SPMC can query through |
| 414 | ``FFA_ID_GET``. |
| 415 | - *maj_ver/min_ver*. SPMD checks provided version versus its internal |
| 416 | version and aborts if not matching. |
| 417 | - *exec_state* defines the SPMC execution state (AArch64 or AArch32). |
| 418 | Notice Hafnium used as a SPMC only supports AArch64. |
| 419 | - *load_address* and *binary_size* are mostly used to verify secondary |
| 420 | entry points fit into the loaded binary image. |
| 421 | - *entrypoint* defines the cold boot primary core entry point used by |
| 422 | SPMD (currently matches ``BL32_BASE``) to enter the SPMC. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 423 | |
| 424 | Other nodes in the manifest are consumed by Hafnium in the secure world. |
| 425 | A sample can be found at [7]: |
| 426 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 427 | - The *hypervisor* node describes SPs. *is_ffa_partition* boolean attribute |
| 428 | indicates a FF-A compliant SP. The *load_address* field specifies the load |
| 429 | address at which TF-A loaded the SP package. |
| 430 | - *cpus* node provide the platform topology and allows MPIDR to VMPIDR mapping. |
| 431 | Note the primary core is declared first, then secondary core are declared |
| 432 | in reverse order. |
| 433 | - The *memory* node provides platform information on the ranges of memory |
| 434 | available to the SPMC. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 435 | |
| 436 | SPMC boot |
| 437 | ~~~~~~~~~ |
| 438 | |
| 439 | The SPMC is loaded by BL2 as the BL32 image. |
| 440 | |
Olivier Deprez | 4ab7a4a | 2021-06-21 09:47:13 +0200 | [diff] [blame] | 441 | The SPMC manifest is loaded by BL2 as the ``TOS_FW_CONFIG`` image `[9]`_. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 442 | |
| 443 | BL2 passes the SPMC manifest address to BL31 through a register. |
| 444 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 445 | At boot time, the SPMD in BL31 runs from the primary core, initializes the core |
Olivier Deprez | 4ab7a4a | 2021-06-21 09:47:13 +0200 | [diff] [blame] | 446 | contexts and launches the SPMC (BL32) passing the following information through |
| 447 | registers: |
| 448 | |
| 449 | - X0 holds the ``TOS_FW_CONFIG`` physical address (or SPMC manifest blob). |
| 450 | - X1 holds the ``HW_CONFIG`` physical address. |
| 451 | - X4 holds the currently running core linear id. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 452 | |
| 453 | Loading of SPs |
| 454 | ~~~~~~~~~~~~~~ |
| 455 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 456 | At boot time, BL2 loads SPs sequentially in addition to the SPMC as depicted |
| 457 | below: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 458 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 459 | .. uml:: ../resources/diagrams/plantuml/bl2-loading-sp.puml |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 460 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 461 | Note this boot flow is an implementation sample on Arm's FVP platform. |
| 462 | Platforms not using TF-A's *Firmware CONFiguration* framework would adjust to a |
| 463 | different implementation. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 464 | |
| 465 | Secure boot |
| 466 | ~~~~~~~~~~~ |
| 467 | |
| 468 | The SP content certificate is inserted as a separate FIP item so that BL2 loads SPMC, |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 469 | SPMC manifest, secure partitions and verifies them for authenticity and integrity. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 470 | Refer to TBBR specification `[3]`_. |
| 471 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 472 | The multiple-signing domain feature (in current state dual signing domain `[8]`_) allows |
| 473 | the use of two root keys namely S-ROTPK and NS-ROTPK: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 474 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 475 | - SPMC (BL32) and SPMC manifest are signed by the SiP using the S-ROTPK. |
| 476 | - BL33 may be signed by the OEM using NS-ROTPK. |
| 477 | - An SP may be signed either by SiP (using S-ROTPK) or by OEM (using NS-ROTPK). |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 478 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 479 | Also refer to `Describing secure partitions`_ and `TF-A build options`_ sections. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 480 | |
| 481 | Hafnium in the secure world |
| 482 | =========================== |
| 483 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 484 | General considerations |
| 485 | ---------------------- |
| 486 | |
| 487 | Build platform for the secure world |
| 488 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 489 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 490 | In the Hafnium reference implementation specific code parts are only relevant to |
| 491 | the secure world. Such portions are isolated in architecture specific files |
| 492 | and/or enclosed by a ``SECURE_WORLD`` macro. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 493 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 494 | Secure partitions CPU scheduling |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 495 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 496 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 497 | The FF-A v1.0 specification `[1]`_ provides two ways to relinquinsh CPU time to |
| 498 | secure partitions. For this a VM (Hypervisor or OS kernel), or SP invokes one of: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 499 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 500 | - the FFA_MSG_SEND_DIRECT_REQ interface. |
| 501 | - the FFA_RUN interface. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 502 | |
| 503 | Platform topology |
| 504 | ~~~~~~~~~~~~~~~~~ |
| 505 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 506 | The *execution-ctx-count* SP manifest field can take the value of one or the |
| 507 | total number of PEs. The FF-A v1.0 specification `[1]`_ recommends the |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 508 | following SP types: |
| 509 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 510 | - Pinned MP SPs: an execution context matches a physical PE. MP SPs must |
| 511 | implement the same number of ECs as the number of PEs in the platform. |
| 512 | - Migratable UP SPs: a single execution context can run and be migrated on any |
| 513 | physical PE. Such SP declares a single EC in its SP manifest. An UP SP can |
| 514 | receive a direct message request originating from any physical core targeting |
| 515 | the single execution context. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 516 | |
| 517 | Parsing SP partition manifests |
| 518 | ------------------------------ |
| 519 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 520 | Hafnium consumes SP manifests as defined in `[1]`_ and `SP manifests`_. |
| 521 | Note the current implementation may not implement all optional fields. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 522 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 523 | The SP manifest may contain memory and device regions nodes. In case of |
| 524 | an S-EL2 SPMC: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 525 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 526 | - Memory regions are mapped in the SP EL1&0 Stage-2 translation regime at |
| 527 | load time (or EL1&0 Stage-1 for an S-EL1 SPMC). A memory region node can |
| 528 | specify RX/TX buffer regions in which case it is not necessary for an SP |
| 529 | to explicitly invoke the ``FFA_RXTX_MAP`` interface. |
| 530 | - Device regions are mapped in the SP EL1&0 Stage-2 translation regime (or |
| 531 | EL1&0 Stage-1 for an S-EL1 SPMC) as peripherals and possibly allocate |
| 532 | additional resources (e.g. interrupts). |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 533 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 534 | For the S-EL2 SPMC, base addresses for memory and device region nodes are IPAs |
| 535 | provided the SPMC identity maps IPAs to PAs within SP EL1&0 Stage-2 translation |
| 536 | regime. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 537 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 538 | Note: in the current implementation both VTTBR_EL2 and VSTTBR_EL2 point to the |
| 539 | same set of page tables. It is still open whether two sets of page tables shall |
| 540 | be provided per SP. The memory region node as defined in the specification |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 541 | provides a memory security attribute hinting to map either to the secure or |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 542 | non-secure EL1&0 Stage-2 table if it exists. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 543 | |
| 544 | Passing boot data to the SP |
| 545 | --------------------------- |
| 546 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 547 | In `[1]`_ , the "Protocol for passing data" section defines a method for passing |
| 548 | boot data to SPs (not currently implemented). |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 549 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 550 | Provided that the whole secure partition package image (see |
| 551 | `Secure Partition packages`_) is mapped to the SP secure EL1&0 Stage-2 |
| 552 | translation regime, an SP can access its own manifest DTB blob and extract its |
| 553 | partition manifest properties. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 554 | |
| 555 | SP Boot order |
| 556 | ------------- |
| 557 | |
| 558 | SP manifests provide an optional boot order attribute meant to resolve |
| 559 | dependencies such as an SP providing a service required to properly boot |
J-Alves | 855fc88 | 2021-12-14 16:02:27 +0000 | [diff] [blame] | 560 | another SP. SPMC boots the SPs in accordance to the boot order attribute, |
| 561 | lowest to the highest value. If the boot order attribute is absent from the FF-A |
| 562 | manifest, the SP is treated as if it had the highest boot order value |
| 563 | (i.e. lowest booting priority). |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 564 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 565 | It is possible for an SP to call into another SP through a direct request |
| 566 | provided the latter SP has already been booted. |
| 567 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 568 | Boot phases |
| 569 | ----------- |
| 570 | |
| 571 | Primary core boot-up |
| 572 | ~~~~~~~~~~~~~~~~~~~~ |
| 573 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 574 | Upon boot-up, BL31 hands over to the SPMC (BL32) on the primary boot physical |
| 575 | core. The SPMC performs its platform initializations and registers the SPMC |
| 576 | secondary physical core entry point physical address by the use of the |
J-Alves | c9ca31c | 2021-10-04 14:33:51 +0100 | [diff] [blame] | 577 | `FFA_SECONDARY_EP_REGISTER`_ interface (SMC invocation from the SPMC to the SPMD |
| 578 | at secure physical FF-A instance). |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 579 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 580 | The SPMC then creates secure partitions based on SP packages and manifests. Each |
| 581 | secure partition is launched in sequence (`SP Boot order`_) on their "primary" |
| 582 | execution context. If the primary boot physical core linear id is N, an MP SP is |
| 583 | started using EC[N] on PE[N] (see `Platform topology`_). If the partition is a |
| 584 | UP SP, it is started using its unique EC0 on PE[N]. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 585 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 586 | The SP primary EC (or the EC used when the partition is booted as described |
| 587 | above): |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 588 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 589 | - Performs the overall SP boot time initialization, and in case of a MP SP, |
| 590 | prepares the SP environment for other execution contexts. |
| 591 | - In the case of a MP SP, it invokes the FFA_SECONDARY_EP_REGISTER at secure |
| 592 | virtual FF-A instance (SMC invocation from SP to SPMC) to provide the IPA |
| 593 | entry point for other execution contexts. |
| 594 | - Exits through ``FFA_MSG_WAIT`` to indicate successful initialization or |
| 595 | ``FFA_ERROR`` in case of failure. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 596 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 597 | Secondary cores boot-up |
| 598 | ~~~~~~~~~~~~~~~~~~~~~~~ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 599 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 600 | Once the system is started and NWd brought up, a secondary physical core is |
| 601 | woken up by the ``PSCI_CPU_ON`` service invocation. The TF-A SPD hook mechanism |
| 602 | calls into the SPMD on the newly woken up physical core. Then the SPMC is |
| 603 | entered at the secondary physical core entry point. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 604 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 605 | In the current implementation, the first SP is resumed on the coresponding EC |
| 606 | (the virtual CPU which matches the physical core). The implication is that the |
| 607 | first SP must be a MP SP. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 608 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 609 | In a linux based system, once secure and normal worlds are booted but prior to |
| 610 | a NWd FF-A driver has been loaded: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 611 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 612 | - The first SP has initialized all its ECs in response to primary core boot up |
| 613 | (at system initialization) and secondary core boot up (as a result of linux |
| 614 | invoking PSCI_CPU_ON for all secondary cores). |
| 615 | - Other SPs have their first execution context initialized as a result of secure |
| 616 | world initialization on the primary boot core. Other ECs for those SPs have to |
| 617 | be run first through ffa_run to complete their initialization (which results |
| 618 | in the EC completing with FFA_MSG_WAIT). |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 619 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 620 | Refer to `Power management`_ for further details. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 621 | |
J-Alves | c9ca31c | 2021-10-04 14:33:51 +0100 | [diff] [blame] | 622 | Notifications |
| 623 | ------------- |
| 624 | |
| 625 | The FF-A v1.1 specification `[1]`_ defines notifications as an asynchronous |
| 626 | communication mechanism with non-blocking semantics. It allows for one FF-A |
| 627 | endpoint to signal another for service provision, without hindering its current |
| 628 | progress. |
| 629 | |
| 630 | Hafnium currently supports 64 notifications. The IDs of each notification define |
| 631 | a position in a 64-bit bitmap. |
| 632 | |
| 633 | The signaling of notifications can interchangeably happen between NWd and SWd |
| 634 | FF-A endpoints. |
| 635 | |
| 636 | The SPMC is in charge of managing notifications from SPs to SPs, from SPs to |
| 637 | VMs, and from VMs to SPs. An hypervisor component would only manage |
| 638 | notifications from VMs to VMs. Given the SPMC has no visibility of the endpoints |
| 639 | deployed in NWd, the Hypervisor or OS kernel must invoke the interface |
| 640 | FFA_NOTIFICATION_BITMAP_CREATE to allocate the notifications bitmap per FF-A |
| 641 | endpoint in the NWd that supports it. |
| 642 | |
| 643 | A sender can signal notifications once the receiver has provided it with |
| 644 | permissions. Permissions are provided by invoking the interface |
| 645 | FFA_NOTIFICATION_BIND. |
| 646 | |
| 647 | Notifications are signaled by invoking FFA_NOTIFICATION_SET. Henceforth |
| 648 | they are considered to be in a pending sate. The receiver can retrieve its |
| 649 | pending notifications invoking FFA_NOTIFICATION_GET, which, from that moment, |
| 650 | are considered to be handled. |
| 651 | |
| 652 | Per the FF-A v1.1 spec, each FF-A endpoint must be associated with a scheduler |
| 653 | that is in charge of donating CPU cycles for notifications handling. The |
| 654 | FF-A driver calls FFA_NOTIFICATION_INFO_GET to retrieve the information about |
| 655 | which FF-A endpoints have pending notifications. The receiver scheduler is |
| 656 | called and informed by the FF-A driver, and it should allocate CPU cycles to the |
| 657 | receiver. |
| 658 | |
| 659 | There are two types of notifications supported: |
| 660 | - Global, which are targeted to a FF-A endpoint and can be handled within any of |
| 661 | its execution contexts, as determined by the scheduler of the system. |
| 662 | - Per-vCPU, which are targeted to a FF-A endpoint and to be handled within a |
| 663 | a specific execution context, as determined by the sender. |
| 664 | |
| 665 | The type of a notification is set when invoking FFA_NOTIFICATION_BIND to give |
| 666 | permissions to the sender. |
| 667 | |
| 668 | Notification signaling resorts to two interrupts: |
| 669 | - Schedule Receiver Interrupt: Non-secure physical interrupt to be handled by |
| 670 | the FF-A 'transport' driver within the receiver scheduler. At initialization |
| 671 | the SPMC (as suggested by the spec) configures a secure SGI, as non-secure, and |
| 672 | triggers it when there are pending notifications, and the respective receivers |
| 673 | need CPU cycles to handle them. |
| 674 | - Notifications Pending Interrupt: Virtual Interrupt to be handled by the |
| 675 | receiver of the notification. Set when there are pending notifications. For |
| 676 | per-vCPU the NPI is pended at the handling of FFA_NOTIFICATION_SET interface. |
| 677 | |
| 678 | The notifications receipt support is enabled in the partition FF-A manifest. |
| 679 | |
| 680 | The subsequent section provides more details about the each one of the |
| 681 | FF-A interfaces for notifications support. |
| 682 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 683 | Mandatory interfaces |
| 684 | -------------------- |
| 685 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 686 | The following interfaces are exposed to SPs: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 687 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 688 | - ``FFA_VERSION`` |
| 689 | - ``FFA_FEATURES`` |
| 690 | - ``FFA_RX_RELEASE`` |
| 691 | - ``FFA_RXTX_MAP`` |
J-Alves | c9ca31c | 2021-10-04 14:33:51 +0100 | [diff] [blame] | 692 | - ``FFA_RXTX_UNMAP`` |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 693 | - ``FFA_PARTITION_INFO_GET`` |
| 694 | - ``FFA_ID_GET`` |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 695 | - ``FFA_MSG_WAIT`` |
| 696 | - ``FFA_MSG_SEND_DIRECT_REQ`` |
| 697 | - ``FFA_MSG_SEND_DIRECT_RESP`` |
| 698 | - ``FFA_MEM_DONATE`` |
| 699 | - ``FFA_MEM_LEND`` |
| 700 | - ``FFA_MEM_SHARE`` |
| 701 | - ``FFA_MEM_RETRIEVE_REQ`` |
| 702 | - ``FFA_MEM_RETRIEVE_RESP`` |
| 703 | - ``FFA_MEM_RELINQUISH`` |
| 704 | - ``FFA_MEM_RECLAIM`` |
J-Alves | c9ca31c | 2021-10-04 14:33:51 +0100 | [diff] [blame] | 705 | |
| 706 | As part of the support of FF-A v1.1, the following interfaces were added: |
| 707 | |
| 708 | - ``FFA_NOTIFICATION_BITMAP_CREATE`` |
| 709 | - ``FFA_NOTIFICATION_BITMAP_DESTROY`` |
| 710 | - ``FFA_NOTIFICATION_BIND`` |
| 711 | - ``FFA_NOTIFICATION_UNBIND`` |
| 712 | - ``FFA_NOTIFICATION_SET`` |
| 713 | - ``FFA_NOTIFICATION_GET`` |
| 714 | - ``FFA_NOTIFICATION_INFO_GET`` |
| 715 | - ``FFA_SPM_ID_GET`` |
| 716 | - ``FFA_SECONDARY_EP_REGISTER`` |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 717 | |
| 718 | FFA_VERSION |
| 719 | ~~~~~~~~~~~ |
| 720 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 721 | ``FFA_VERSION`` requires a *requested_version* parameter from the caller. |
| 722 | The returned value depends on the caller: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 723 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 724 | - Hypervisor or OS kernel in NS-EL1/EL2: the SPMD returns the SPMC version |
| 725 | specified in the SPMC manifest. |
| 726 | - SP: the SPMC returns its own implemented version. |
| 727 | - SPMC at S-EL1/S-EL2: the SPMD returns its own implemented version. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 728 | |
| 729 | FFA_FEATURES |
| 730 | ~~~~~~~~~~~~ |
| 731 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 732 | FF-A features supported by the SPMC may be discovered by secure partitions at |
| 733 | boot (that is prior to NWd is booted) or run-time. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 734 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 735 | The SPMC calling FFA_FEATURES at secure physical FF-A instance always get |
| 736 | FFA_SUCCESS from the SPMD. |
| 737 | |
| 738 | The request made by an Hypervisor or OS kernel is forwarded to the SPMC and |
| 739 | the response relayed back to the NWd. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 740 | |
| 741 | FFA_RXTX_MAP/FFA_RXTX_UNMAP |
| 742 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 743 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 744 | When invoked from a secure partition FFA_RXTX_MAP maps the provided send and |
| 745 | receive buffers described by their IPAs to the SP EL1&0 Stage-2 translation |
| 746 | regime as secure buffers in the MMU descriptors. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 747 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 748 | When invoked from the Hypervisor or OS kernel, the buffers are mapped into the |
| 749 | SPMC EL2 Stage-1 translation regime and marked as NS buffers in the MMU |
| 750 | descriptors. |
| 751 | |
J-Alves | c9ca31c | 2021-10-04 14:33:51 +0100 | [diff] [blame] | 752 | The FFA_RXTX_UNMAP unmaps the RX/TX pair from the translation regime of the |
| 753 | caller, either it being the Hypervisor or OS kernel, as well as a secure |
| 754 | partition. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 755 | |
| 756 | FFA_PARTITION_INFO_GET |
| 757 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 758 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 759 | Partition info get call can originate: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 760 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 761 | - from SP to SPMC |
| 762 | - from Hypervisor or OS kernel to SPMC. The request is relayed by the SPMD. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 763 | |
| 764 | FFA_ID_GET |
| 765 | ~~~~~~~~~~ |
| 766 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 767 | The FF-A id space is split into a non-secure space and secure space: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 768 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 769 | - FF-A ID with bit 15 clear relates to VMs. |
| 770 | - FF-A ID with bit 15 set related to SPs. |
| 771 | - FF-A IDs 0, 0xffff, 0x8000 are assigned respectively to the Hypervisor, SPMD |
| 772 | and SPMC. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 773 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 774 | The SPMD returns: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 775 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 776 | - The default zero value on invocation from the Hypervisor. |
| 777 | - The ``spmc_id`` value specified in the SPMC manifest on invocation from |
| 778 | the SPMC (see `SPMC manifest`_) |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 779 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 780 | This convention helps the SPMC to determine the origin and destination worlds in |
| 781 | an FF-A ABI invocation. In particular the SPMC shall filter unauthorized |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 782 | transactions in its world switch routine. It must not be permitted for a VM to |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 783 | use a secure FF-A ID as origin world by spoofing: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 784 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 785 | - A VM-to-SP direct request/response shall set the origin world to be non-secure |
| 786 | (FF-A ID bit 15 clear) and destination world to be secure (FF-A ID bit 15 |
| 787 | set). |
| 788 | - Similarly, an SP-to-SP direct request/response shall set the FF-A ID bit 15 |
| 789 | for both origin and destination IDs. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 790 | |
| 791 | An incoming direct message request arriving at SPMD from NWd is forwarded to |
| 792 | SPMC without a specific check. The SPMC is resumed through eret and "knows" the |
| 793 | message is coming from normal world in this specific code path. Thus the origin |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 794 | endpoint ID must be checked by SPMC for being a normal world ID. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 795 | |
| 796 | An SP sending a direct message request must have bit 15 set in its origin |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 797 | endpoint ID and this can be checked by the SPMC when the SP invokes the ABI. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 798 | |
| 799 | The SPMC shall reject the direct message if the claimed world in origin endpoint |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 800 | ID is not consistent: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 801 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 802 | - It is either forwarded by SPMD and thus origin endpoint ID must be a "normal |
| 803 | world ID", |
| 804 | - or initiated by an SP and thus origin endpoint ID must be a "secure world ID". |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 805 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 806 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 807 | FFA_MSG_SEND_DIRECT_REQ/FFA_MSG_SEND_DIRECT_RESP |
| 808 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 809 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 810 | This is a mandatory interface for secure partitions consisting in direct request |
| 811 | and responses with the following rules: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 812 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 813 | - An SP can send a direct request to another SP. |
| 814 | - An SP can receive a direct request from another SP. |
| 815 | - An SP can send a direct response to another SP. |
| 816 | - An SP cannot send a direct request to an Hypervisor or OS kernel. |
| 817 | - An Hypervisor or OS kernel can send a direct request to an SP. |
| 818 | - An SP can send a direct response to an Hypervisor or OS kernel. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 819 | |
J-Alves | c9ca31c | 2021-10-04 14:33:51 +0100 | [diff] [blame] | 820 | FFA_NOTIFICATION_BITMAP_CREATE/FFA_NOTIFICATION_BITMAP_DESTROY |
| 821 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 822 | |
| 823 | The secure partitions notifications bitmap are statically allocated by the SPMC. |
| 824 | Hence, this interface is not to be issued by secure partitions. |
| 825 | |
| 826 | At initialization, the SPMC is not aware of VMs/partitions deployed in the |
| 827 | normal world. Hence, the Hypervisor or OS kernel must use both ABIs for SPMC |
| 828 | to be prepared to handle notifications for the provided VM ID. |
| 829 | |
| 830 | FFA_NOTIFICATION_BIND/FFA_NOTIFICATION_UNBIND |
| 831 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 832 | |
| 833 | Pair of interfaces to manage permissions to signal notifications. Prior to |
| 834 | handling notifications, an FF-A endpoint must allow a given sender to signal a |
| 835 | bitmap of notifications. |
| 836 | |
| 837 | If the receiver doesn't have notification support enabled in its FF-A manifest, |
| 838 | it won't be able to bind notifications, hence forbidding it to receive any |
| 839 | notifications. |
| 840 | |
| 841 | FFA_NOTIFICATION_SET/FFA_NOTIFICATION_GET |
| 842 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 843 | |
| 844 | If the notifications set are per-vCPU, the NPI interrupt is set as pending |
| 845 | for a given receiver partition. |
| 846 | |
| 847 | The FFA_NOTIFICATION_GET will retrieve all pending global notifications and all |
| 848 | pending per-vCPU notifications targeted to the current vCPU. |
| 849 | |
| 850 | Hafnium keeps the global counting of the pending notifications, which is |
| 851 | incremented and decremented at the handling of FFA_NOTIFICATION_SET and |
| 852 | FFA_NOTIFICATION_GET, respectively. If the counter reaches zero, prior to SPMC |
| 853 | triggering the SRI, it won't be triggered. |
| 854 | |
| 855 | FFA_NOTIFICATION_INFO_GET |
| 856 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 857 | |
| 858 | Hafnium keeps the global counting of pending notifications whose info has been |
| 859 | retrieved by this interface. The counting is incremented and decremented at the |
| 860 | handling of FFA_NOTIFICATION_INFO_GET and FFA_NOTIFICATION_GET, respectively. |
| 861 | It also tracks the notifications whose info has been retrieved individually, |
| 862 | such that it avoids duplicating returned information for subsequent calls to |
| 863 | FFA_NOTIFICATION_INFO_GET. For each notification, this state information is |
| 864 | reset when receiver called FFA_NOTIFICATION_GET to retrieve them. |
| 865 | |
| 866 | FFA_SPM_ID_GET |
| 867 | ~~~~~~~~~~~~~~ |
| 868 | |
| 869 | Returns the FF-A ID allocated to the SPM component (which includes SPMC + SPMD). |
| 870 | At initialization, the SPMC queries the SPMD for the SPM ID, using this |
| 871 | same interface, and saves it. |
| 872 | |
| 873 | The call emitted at NS and secure physical FF-A instances returns the SPM ID |
| 874 | specified in the SPMC manifest. |
| 875 | |
| 876 | Secure partitions call this interface at the virtual instance, to which the SPMC |
| 877 | shall return the priorly retrieved SPM ID. |
| 878 | |
| 879 | The Hypervisor or OS kernel can issue an FFA_SPM_ID_GET call handled by the |
| 880 | SPMD, which returns the SPM ID. |
| 881 | |
| 882 | FFA_SECONDARY_EP_REGISTER |
| 883 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 884 | |
| 885 | When the SPMC boots, all secure partitions are initialized on their primary |
| 886 | Execution Context. |
| 887 | |
| 888 | The interface FFA_SECONDARY_EP_REGISTER is to be used by a secure partitions |
| 889 | from its first execution context, to provide the entry point address for |
| 890 | secondary execution contexts. |
| 891 | |
| 892 | A secondary EC is first resumed either upon invocation of PSCI_CPU_ON from |
| 893 | the NWd or by invocation of FFA_RUN. |
| 894 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 895 | SPMC-SPMD direct requests/responses |
| 896 | ----------------------------------- |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 897 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 898 | Implementation-defined FF-A IDs are allocated to the SPMC and SPMD. |
| 899 | Using those IDs in source/destination fields of a direct request/response |
| 900 | permits SPMD to SPMC communication and either way. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 901 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 902 | - SPMC to SPMD direct request/response uses SMC conduit. |
| 903 | - SPMD to SPMC direct request/response uses ERET conduit. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 904 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 905 | PE MMU configuration |
| 906 | -------------------- |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 907 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 908 | With secure virtualization enabled, two IPA spaces are output from the secure |
| 909 | EL1&0 Stage-1 translation (secure and non-secure). The EL1&0 Stage-2 translation |
| 910 | hardware is fed by: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 911 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 912 | - A single secure IPA space when the SP EL1&0 Stage-1 MMU is disabled. |
| 913 | - Two IPA spaces (secure and non-secure) when the SP EL1&0 Stage-1 MMU is |
| 914 | enabled. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 915 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 916 | ``VTCR_EL2`` and ``VSTCR_EL2`` provide configuration bits for controlling the |
| 917 | NS/S IPA translations. |
| 918 | ``VSTCR_EL2.SW`` = 0, ``VSTCR_EL2.SA`` = 0,``VTCR_EL2.NSW`` = 0, ``VTCR_EL2.NSA`` = 1: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 919 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 920 | - Stage-2 translations for the NS IPA space access the NS PA space. |
| 921 | - Stage-2 translation table walks for the NS IPA space are to the secure PA space. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 922 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 923 | Secure and non-secure IPA regions use the same set of Stage-2 page tables within |
| 924 | a SP. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 925 | |
| 926 | Interrupt management |
| 927 | -------------------- |
| 928 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 929 | GIC ownership |
| 930 | ~~~~~~~~~~~~~ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 931 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 932 | The SPMC owns the GIC configuration. Secure and non-secure interrupts are |
| 933 | trapped at S-EL2. The SPMC manages interrupt resources and allocates interrupt |
| 934 | IDs based on SP manifests. The SPMC acknowledges physical interrupts and injects |
| 935 | virtual interrupts by setting the use of vIRQ/vFIQ bits before resuming a SP. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 936 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 937 | Non-secure interrupt handling |
| 938 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 939 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 940 | The following illustrate the scenarios of non secure physical interrupts trapped |
| 941 | by the SPMC: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 942 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 943 | - The SP handles a managed exit operation: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 944 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 945 | .. image:: ../resources/diagrams/ffa-ns-interrupt-handling-managed-exit.png |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 946 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 947 | - The SP is pre-empted without managed exit: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 948 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 949 | .. image:: ../resources/diagrams/ffa-ns-interrupt-handling-sp-preemption.png |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 950 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 951 | Secure interrupt handling |
Madhukar Pappireddy | b3d37b1 | 2021-09-23 14:29:05 -0500 | [diff] [blame] | 952 | ------------------------- |
| 953 | |
| 954 | This section documents the support implemented for secure interrupt handling in |
| 955 | SPMC as per the guidance provided by FF-A v1.1 Beta0 specification. |
| 956 | The following assumptions are made about the system configuration: |
| 957 | |
| 958 | - In the current implementation, S-EL1 SPs are expected to use the para |
| 959 | virtualized ABIs for interrupt management rather than accessing virtual GIC |
| 960 | interface. |
| 961 | - Unless explicitly stated otherwise, this support is applicable only for |
| 962 | S-EL1 SPs managed by SPMC. |
| 963 | - Secure interrupts are configured as G1S or G0 interrupts. |
| 964 | - All physical interrupts are routed to SPMC when running a secure partition |
| 965 | execution context. |
| 966 | |
| 967 | A physical secure interrupt could preempt normal world execution. Moreover, when |
| 968 | the execution is in secure world, it is highly likely that the target of a |
| 969 | secure interrupt is not the currently running execution context of an SP. It |
| 970 | could be targeted to another FF-A component. Consequently, secure interrupt |
| 971 | management depends on the state of the target execution context of the SP that |
| 972 | is responsible for handling the interrupt. Hence, the spec provides guidance on |
| 973 | how to signal start and completion of secure interrupt handling as discussed in |
| 974 | further sections. |
| 975 | |
| 976 | Secure interrupt signaling mechanisms |
| 977 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 978 | |
| 979 | Signaling refers to the mechanisms used by SPMC to indicate to the SP execution |
| 980 | context that it has a pending virtual interrupt and to further run the SP |
| 981 | execution context, such that it can handle the virtual interrupt. SPMC uses |
| 982 | either the FFA_INTERRUPT interface with ERET conduit or vIRQ signal for signaling |
| 983 | to S-EL1 SPs. When normal world execution is preempted by a secure interrupt, |
| 984 | the SPMD uses the FFA_INTERRUPT ABI with ERET conduit to signal interrupt to SPMC |
| 985 | running in S-EL2. |
| 986 | |
| 987 | +-----------+---------+---------------+---------------------------------------+ |
| 988 | | SP State | Conduit | Interface and | Description | |
| 989 | | | | parameters | | |
| 990 | +-----------+---------+---------------+---------------------------------------+ |
| 991 | | WAITING | ERET, | FFA_INTERRUPT,| SPMC signals to SP the ID of pending | |
| 992 | | | vIRQ | Interrupt ID | interrupt. It pends vIRQ signal and | |
| 993 | | | | | resumes execution context of SP | |
| 994 | | | | | through ERET. | |
| 995 | +-----------+---------+---------------+---------------------------------------+ |
| 996 | | BLOCKED | ERET, | FFA_INTERRUPT | SPMC signals to SP that an interrupt | |
| 997 | | | vIRQ | | is pending. It pends vIRQ signal and | |
| 998 | | | | | resumes execution context of SP | |
| 999 | | | | | through ERET. | |
| 1000 | +-----------+---------+---------------+---------------------------------------+ |
| 1001 | | PREEMPTED | vIRQ | NA | SPMC pends the vIRQ signal but does | |
| 1002 | | | | | not resume execution context of SP. | |
| 1003 | +-----------+---------+---------------+---------------------------------------+ |
| 1004 | | RUNNING | ERET, | NA | SPMC pends the vIRQ signal and resumes| |
| 1005 | | | vIRQ | | execution context of SP through ERET. | |
| 1006 | +-----------+---------+---------------+---------------------------------------+ |
| 1007 | |
| 1008 | Secure interrupt completion mechanisms |
| 1009 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1010 | |
| 1011 | A SP signals secure interrupt handling completion to the SPMC through the |
| 1012 | following mechanisms: |
| 1013 | |
| 1014 | - ``FFA_MSG_WAIT`` ABI if it was in WAITING state. |
| 1015 | - ``FFA_RUN`` ABI if its was in BLOCKED state. |
| 1016 | |
| 1017 | In the current implementation, S-EL1 SPs use para-virtualized HVC interface |
| 1018 | implemented by SPMC to perform priority drop and interrupt deactivation (we |
| 1019 | assume EOImode = 0, i.e. priority drop and deactivation are done together). |
| 1020 | |
| 1021 | If normal world execution was preempted by secure interrupt, SPMC uses |
| 1022 | FFA_NORMAL_WORLD_RESUME ABI to indicate completion of secure interrupt handling |
| 1023 | and further return execution to normal world. If the current SP execution |
| 1024 | context was preempted by a secure interrupt to be handled by execution context |
| 1025 | of target SP, SPMC resumes current SP after signal completion by target SP |
| 1026 | execution context. |
| 1027 | |
| 1028 | An action is broadly a set of steps taken by the SPMC in response to a physical |
| 1029 | interrupt. In order to simplify the design, the current version of secure |
| 1030 | interrupt management support in SPMC (Hafnium) does not fully implement the |
| 1031 | Scheduling models and Partition runtime models. However, the current |
| 1032 | implementation loosely maps to the following actions that are legally allowed |
| 1033 | by the specification. Please refer to the Table 8.4 in the spec for further |
| 1034 | description of actions. The action specified for a type of interrupt when the |
| 1035 | SP is in the message processing running state cannot be less permissive than the |
| 1036 | action specified for the same type of interrupt when the SP is in the interrupt |
| 1037 | handling running state. |
| 1038 | |
| 1039 | +--------------------+--------------------+------------+-------------+ |
| 1040 | | Runtime Model | NS-Int | Self S-Int | Other S-Int | |
| 1041 | +--------------------+--------------------+------------+-------------+ |
| 1042 | | Message Processing | Signalable with ME | Signalable | Signalable | |
| 1043 | +--------------------+--------------------+------------+-------------+ |
| 1044 | | Interrupt Handling | Queued | Queued | Queued | |
| 1045 | +--------------------+--------------------+------------+-------------+ |
| 1046 | |
| 1047 | Abbreviations: |
| 1048 | |
| 1049 | - NS-Int: A Non-secure physical interrupt. It requires a switch to the Normal |
| 1050 | world to be handled. |
| 1051 | - Other S-Int: A secure physical interrupt targeted to an SP different from |
| 1052 | the one that is currently running. |
| 1053 | - Self S-Int: A secure physical interrupt targeted to the SP that is currently |
| 1054 | running. |
| 1055 | |
| 1056 | The following figure describes interrupt handling flow when secure interrupt |
| 1057 | triggers while in normal world: |
| 1058 | |
| 1059 | .. image:: ../resources/diagrams/ffa-secure-interrupt-handling-nwd.png |
| 1060 | |
| 1061 | A brief description of the events: |
| 1062 | |
| 1063 | - 1) Secure interrupt triggers while normal world is running. |
| 1064 | - 2) FIQ gets trapped to EL3. |
| 1065 | - 3) SPMD signals secure interrupt to SPMC at S-EL2 using FFA_INTERRUPT ABI. |
| 1066 | - 4) SPMC identifies target vCPU of SP and injects virtual interrupt (pends |
| 1067 | vIRQ). |
| 1068 | - 5) Since SP1 vCPU is in WAITING state, SPMC signals using FFA_INTERRUPT with |
| 1069 | interrupt id as argument and resume it using ERET. |
| 1070 | - 6) Execution traps to vIRQ handler in SP1 provided that interrupt is not |
| 1071 | masked i.e., PSTATE.I = 0 |
| 1072 | - 7) SP1 services the interrupt and invokes the de-activation HVC call. |
| 1073 | - 8) SPMC does internal state management and further de-activates the physical |
| 1074 | interrupt and resumes SP vCPU. |
| 1075 | - 9) SP performs secure interrupt completion through FFA_MSG_WAIT ABI. |
| 1076 | - 10) SPMC returns control to EL3 using FFA_NORMAL_WORLD_RESUME. |
| 1077 | - 11) EL3 resumes normal world execution. |
| 1078 | |
| 1079 | The following figure describes interrupt handling flow when secure interrupt |
| 1080 | triggers while in secure world: |
| 1081 | |
| 1082 | .. image:: ../resources/diagrams/ffa-secure-interrupt-handling-swd.png |
| 1083 | |
| 1084 | A brief description of the events: |
| 1085 | |
| 1086 | - 1) Secure interrupt triggers while SP2 is running and SP1 is blocked. |
| 1087 | - 2) Gets trapped to SPMC as IRQ. |
| 1088 | - 3) SPMC finds the target vCPU of secure partition responsible for handling |
| 1089 | this secure interrupt. In this scenario, it is SP1. |
| 1090 | - 4) SPMC pends vIRQ for SP1 and signals through FFA_INTERRUPT interface. |
| 1091 | SPMC further resumes SP1 through ERET conduit. |
| 1092 | - 5) Execution traps to vIRQ handler in SP1 provided that interrupt is not |
| 1093 | masked i.e., PSTATE.I = 0 |
| 1094 | - 6) SP1 services the secure interrupt and invokes the de-activation HVC call. |
| 1095 | - 7) SPMC does internal state management, de-activates the physical interrupt |
| 1096 | and resumes SP1 vCPU. |
| 1097 | - 8) Assuming SP1 is in BLOCKED state, SP1 performs secure interrupt completion |
| 1098 | through FFA_RUN ABI. |
| 1099 | - 9) SPMC resumes the pre-empted vCPU of SP2. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1100 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1101 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1102 | Power management |
| 1103 | ---------------- |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1104 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1105 | In platforms with or without secure virtualization: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1106 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1107 | - The NWd owns the platform PM policy. |
| 1108 | - The Hypervisor or OS kernel is the component initiating PSCI service calls. |
| 1109 | - The EL3 PSCI library is in charge of the PM coordination and control |
| 1110 | (eventually writing to platform registers). |
| 1111 | - While coordinating PM events, the PSCI library calls backs into the Secure |
| 1112 | Payload Dispatcher for events the latter has statically registered to. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1113 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1114 | When using the SPMD as a Secure Payload Dispatcher: |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1115 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1116 | - A power management event is relayed through the SPD hook to the SPMC. |
| 1117 | - In the current implementation only cpu on (svc_on_finish) and cpu off |
| 1118 | (svc_off) hooks are registered. |
| 1119 | - The behavior for the cpu on event is described in `Secondary cores boot-up`_. |
| 1120 | The SPMC is entered through its secondary physical core entry point. |
| 1121 | - The cpu off event occurs when the NWd calls PSCI_CPU_OFF. The method by which |
| 1122 | the PM event is conveyed to the SPMC is implementation-defined in context of |
| 1123 | FF-A v1.0 (`SPMC-SPMD direct requests/responses`_). It consists in a SPMD-to-SPMC |
| 1124 | direct request/response conveying the PM event details and SPMC response. |
| 1125 | The SPMD performs a synchronous entry into the SPMC. The SPMC is entered and |
| 1126 | updates its internal state to reflect the physical core is being turned off. |
| 1127 | In the current implementation no SP is resumed as a consequence. This behavior |
| 1128 | ensures a minimal support for CPU hotplug e.g. when initiated by the NWd linux |
| 1129 | userspace. |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1130 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1131 | SMMUv3 support in Hafnium |
| 1132 | ========================= |
Madhukar Pappireddy | a985906 | 2021-02-28 14:01:34 -0600 | [diff] [blame] | 1133 | |
| 1134 | An SMMU is analogous to an MMU in a CPU. It performs address translations for |
| 1135 | Direct Memory Access (DMA) requests from system I/O devices. |
| 1136 | The responsibilities of an SMMU include: |
| 1137 | |
| 1138 | - Translation: Incoming DMA requests are translated from bus address space to |
| 1139 | system physical address space using translation tables compliant to |
| 1140 | Armv8/Armv7 VMSA descriptor format. |
| 1141 | - Protection: An I/O device can be prohibited from read, write access to a |
| 1142 | memory region or allowed. |
| 1143 | - Isolation: Traffic from each individial device can be independently managed. |
| 1144 | The devices are differentiated from each other using unique translation |
| 1145 | tables. |
| 1146 | |
| 1147 | The following diagram illustrates a typical SMMU IP integrated in a SoC with |
| 1148 | several I/O devices along with Interconnect and Memory system. |
| 1149 | |
| 1150 | .. image:: ../resources/diagrams/MMU-600.png |
| 1151 | |
| 1152 | SMMU has several versions including SMMUv1, SMMUv2 and SMMUv3. Hafnium provides |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1153 | support for SMMUv3 driver in both normal and secure world. A brief introduction |
Madhukar Pappireddy | a985906 | 2021-02-28 14:01:34 -0600 | [diff] [blame] | 1154 | of SMMUv3 functionality and the corresponding software support in Hafnium is |
| 1155 | provided here. |
| 1156 | |
| 1157 | SMMUv3 features |
| 1158 | --------------- |
| 1159 | |
| 1160 | - SMMUv3 provides Stage1, Stage2 translation as well as nested (Stage1 + Stage2) |
| 1161 | translation support. It can either bypass or abort incoming translations as |
| 1162 | well. |
| 1163 | - Traffic (memory transactions) from each upstream I/O peripheral device, |
| 1164 | referred to as Stream, can be independently managed using a combination of |
| 1165 | several memory based configuration structures. This allows the SMMUv3 to |
| 1166 | support a large number of streams with each stream assigned to a unique |
| 1167 | translation context. |
| 1168 | - Support for Armv8.1 VMSA where the SMMU shares the translation tables with |
| 1169 | a Processing Element. AArch32(LPAE) and AArch64 translation table format |
| 1170 | are supported by SMMUv3. |
| 1171 | - SMMUv3 offers non-secure stream support with secure stream support being |
| 1172 | optional. Logically, SMMUv3 behaves as if there is an indepdendent SMMU |
| 1173 | instance for secure and non-secure stream support. |
| 1174 | - It also supports sub-streams to differentiate traffic from a virtualized |
| 1175 | peripheral associated with a VM/SP. |
| 1176 | - Additionally, SMMUv3.2 provides support for PEs implementing Armv8.4-A |
| 1177 | extensions. Consequently, SPM depends on Secure EL2 support in SMMUv3.2 |
| 1178 | for providing Secure Stage2 translation support to upstream peripheral |
| 1179 | devices. |
| 1180 | |
| 1181 | SMMUv3 Programming Interfaces |
| 1182 | ----------------------------- |
| 1183 | |
| 1184 | SMMUv3 has three software interfaces that are used by the Hafnium driver to |
| 1185 | configure the behaviour of SMMUv3 and manage the streams. |
| 1186 | |
| 1187 | - Memory based data strutures that provide unique translation context for |
| 1188 | each stream. |
| 1189 | - Memory based circular buffers for command queue and event queue. |
| 1190 | - A large number of SMMU configuration registers that are memory mapped during |
| 1191 | boot time by Hafnium driver. Except a few registers, all configuration |
| 1192 | registers have independent secure and non-secure versions to configure the |
| 1193 | behaviour of SMMUv3 for translation of secure and non-secure streams |
| 1194 | respectively. |
| 1195 | |
| 1196 | Peripheral device manifest |
| 1197 | -------------------------- |
| 1198 | |
| 1199 | Currently, SMMUv3 driver in Hafnium only supports dependent peripheral devices. |
| 1200 | These devices are dependent on PE endpoint to initiate and receive memory |
| 1201 | management transactions on their behalf. The acccess to the MMIO regions of |
| 1202 | any such device is assigned to the endpoint during boot. Moreover, SMMUv3 driver |
| 1203 | uses the same stage 2 translations for the device as those used by partition |
| 1204 | manager on behalf of the PE endpoint. This ensures that the peripheral device |
| 1205 | has the same visibility of the physical address space as the endpoint. The |
| 1206 | device node of the corresponding partition manifest (refer to `[1]`_ section 3.2 |
| 1207 | ) must specify these additional properties for each peripheral device in the |
| 1208 | system : |
| 1209 | |
| 1210 | - smmu-id: This field helps to identify the SMMU instance that this device is |
| 1211 | upstream of. |
| 1212 | - stream-ids: List of stream IDs assigned to this device. |
| 1213 | |
| 1214 | .. code:: shell |
| 1215 | |
| 1216 | smmuv3-testengine { |
| 1217 | base-address = <0x00000000 0x2bfe0000>; |
| 1218 | pages-count = <32>; |
| 1219 | attributes = <0x3>; |
| 1220 | smmu-id = <0>; |
| 1221 | stream-ids = <0x0 0x1>; |
| 1222 | interrupts = <0x2 0x3>, <0x4 0x5>; |
| 1223 | exclusive-access; |
| 1224 | }; |
| 1225 | |
| 1226 | SMMUv3 driver limitations |
| 1227 | ------------------------- |
| 1228 | |
| 1229 | The primary design goal for the Hafnium SMMU driver is to support secure |
| 1230 | streams. |
| 1231 | |
| 1232 | - Currently, the driver only supports Stage2 translations. No support for |
| 1233 | Stage1 or nested translations. |
| 1234 | - Supports only AArch64 translation format. |
| 1235 | - No support for features such as PCI Express (PASIDs, ATS, PRI), MSI, RAS, |
| 1236 | Fault handling, Performance Monitor Extensions, Event Handling, MPAM. |
| 1237 | - No support for independent peripheral devices. |
| 1238 | |
Raghu Krishnamurthy | 7f3f7ce | 2021-10-17 16:48:29 -0700 | [diff] [blame] | 1239 | S-EL0 Partition support |
| 1240 | ========================= |
| 1241 | The SPMC (Hafnium) has limited capability to run S-EL0 FF-A partitions using |
| 1242 | FEAT_VHE (mandatory with ARMv8.1 in non-secure state, and in secure world |
| 1243 | with ARMv8.4 and FEAT_SEL2). |
| 1244 | |
| 1245 | S-EL0 partitions are useful for simple partitions that don't require full |
| 1246 | Trusted OS functionality. It is also useful to reduce jitter and cycle |
| 1247 | stealing from normal world since they are more lightweight than VMs. |
| 1248 | |
| 1249 | S-EL0 partitions are presented, loaded and initialized the same as S-EL1 VMs by |
| 1250 | the SPMC. They are differentiated primarily by the 'exception-level' property |
| 1251 | and the 'execution-ctx-count' property in the SP manifest. They are host apps |
| 1252 | under the single EL2&0 Stage-1 translation regime controlled by the SPMC and |
| 1253 | call into the SPMC through SVCs as opposed to HVCs and SMCs. These partitions |
| 1254 | can use FF-A defined services (FFA_MEM_PERM_*) to update or change permissions |
| 1255 | for memory regions. |
| 1256 | |
| 1257 | S-EL0 partitions are required by the FF-A specification to be UP endpoints, |
| 1258 | capable of migrating, and the SPMC enforces this requirement. The SPMC allows |
| 1259 | a S-EL0 partition to accept a direct message from secure world and normal world, |
| 1260 | and generate direct responses to them. |
| 1261 | |
| 1262 | Memory sharing between and with S-EL0 partitions is supported. |
| 1263 | Indirect messaging, Interrupt handling and Notifications are not supported with |
| 1264 | S-EL0 partitions and is work in progress, planned for future releases. |
| 1265 | All S-EL0 partitions must use AArch64. AArch32 S-EL0 partitions are not |
| 1266 | supported. |
| 1267 | |
| 1268 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1269 | References |
| 1270 | ========== |
| 1271 | |
| 1272 | .. _[1]: |
| 1273 | |
Olivier Deprez | 2b0be75 | 2021-09-01 10:25:21 +0200 | [diff] [blame] | 1274 | [1] `Arm Firmware Framework for Arm A-profile <https://developer.arm.com/docs/den0077/latest>`__ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1275 | |
| 1276 | .. _[2]: |
| 1277 | |
Madhukar Pappireddy | 86350ae | 2020-07-29 09:37:25 -0500 | [diff] [blame] | 1278 | [2] :ref:`Secure Partition Manager using MM interface<Secure Partition Manager (MM)>` |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1279 | |
| 1280 | .. _[3]: |
| 1281 | |
| 1282 | [3] `Trusted Boot Board Requirements |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1283 | Client <https://developer.arm.com/documentation/den0006/d/>`__ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1284 | |
| 1285 | .. _[4]: |
| 1286 | |
| 1287 | [4] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime/aarch64/context.S#n45 |
| 1288 | |
| 1289 | .. _[5]: |
| 1290 | |
Olivier Deprez | 5e0a73f | 2021-04-30 14:42:24 +0200 | [diff] [blame] | 1291 | [5] https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus.dts |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1292 | |
| 1293 | .. _[6]: |
| 1294 | |
Olivier Deprez | 9938c13 | 2021-04-21 11:22:23 +0200 | [diff] [blame] | 1295 | [6] https://trustedfirmware-a.readthedocs.io/en/latest/components/ffa-manifest-binding.html |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1296 | |
| 1297 | .. _[7]: |
| 1298 | |
| 1299 | [7] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/plat/arm/board/fvp/fdts/fvp_spmc_manifest.dts |
| 1300 | |
| 1301 | .. _[8]: |
| 1302 | |
Sandrine Bailleux | 1a4efb1 | 2022-04-21 10:17:22 +0200 | [diff] [blame] | 1303 | [8] https://lists.trustedfirmware.org/archives/list/tf-a@lists.trustedfirmware.org/thread/CFQFGU6H2D5GZYMUYGTGUSXIU3OYZP6U/ |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1304 | |
Olivier Deprez | 4ab7a4a | 2021-06-21 09:47:13 +0200 | [diff] [blame] | 1305 | .. _[9]: |
| 1306 | |
| 1307 | [9] https://trustedfirmware-a.readthedocs.io/en/latest/design/firmware-design.html#dynamic-configuration-during-cold-boot |
| 1308 | |
Olivier Deprez | ecb2fe5 | 2020-04-02 15:38:02 +0200 | [diff] [blame] | 1309 | -------------- |
| 1310 | |
Imre Kis | 3f370fd | 2022-02-08 18:06:18 +0100 | [diff] [blame] | 1311 | *Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.* |