blob: ee9fa7bd6a0f9139ef9d831bebdec3a87fcb11ad [file] [log] [blame]
Olivier Deprezcbf7d5b2023-05-22 12:12:24 +02001Secure Partition Manager
2************************
3
4.. contents::
5
6Acronyms
7========
8
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| JOP | Jump-Oriented Programming |
27+--------+--------------------------------------+
28| NWd | Normal World |
29+--------+--------------------------------------+
30| ODM | Original Design Manufacturer |
31+--------+--------------------------------------+
32| OEM | Original Equipment Manufacturer |
33+--------+--------------------------------------+
34| PA | Physical Address |
35+--------+--------------------------------------+
36| PE | Processing Element |
37+--------+--------------------------------------+
38| PM | Power Management |
39+--------+--------------------------------------+
40| PVM | Primary VM |
41+--------+--------------------------------------+
42| ROP | Return-Oriented Programming |
43+--------+--------------------------------------+
44| SMMU | System Memory Management Unit |
45+--------+--------------------------------------+
46| SP | Secure Partition |
47+--------+--------------------------------------+
48| SPD | Secure Payload Dispatcher |
49+--------+--------------------------------------+
50| SPM | Secure Partition Manager |
51+--------+--------------------------------------+
52| SPMC | SPM Core |
53+--------+--------------------------------------+
54| SPMD | SPM Dispatcher |
55+--------+--------------------------------------+
56| SiP | Silicon Provider |
57+--------+--------------------------------------+
58| SWd | Secure World |
59+--------+--------------------------------------+
60| TLV | Tag-Length-Value |
61+--------+--------------------------------------+
62| TOS | Trusted Operating System |
63+--------+--------------------------------------+
64| VM | Virtual Machine |
65+--------+--------------------------------------+
66
67Foreword
68========
69
70Three implementations of a Secure Partition Manager co-exist in the TF-A
71codebase:
72
73#. S-EL2 SPMC based on the FF-A specification `[1]`_, enabling virtualization in
74 the secure world, managing multiple S-EL1 or S-EL0 partitions.
75#. EL3 SPMC based on the FF-A specification, managing a single S-EL1 partition
76 without virtualization in the secure world.
77#. EL3 SPM based on the MM specification, legacy implementation managing a
78 single S-EL0 partition `[2]`_.
79
80These implementations differ in their respective SW architecture and only one
81can be selected at build time. This document:
82
83- describes the implementation from bullet 1. when the SPMC resides at S-EL2.
84- is not an architecture specification and it might provide assumptions
85 on sections mandated as implementation-defined in the specification.
86- covers the implications to TF-A used as a bootloader, and Hafnium used as a
87 reference code base for an S-EL2/SPMC secure firmware on platforms
88 implementing the FEAT_SEL2 architecture extension.
89
90Terminology
91-----------
92
93- The term Hypervisor refers to the NS-EL2 component managing Virtual Machines
94 (or partitions) in the normal world.
95- The term SPMC refers to the S-EL2 component managing secure partitions in
96 the secure world when the FEAT_SEL2 architecture extension is implemented.
97- Alternatively, SPMC can refer to an S-EL1 component, itself being a secure
98 partition and implementing the FF-A ABI on platforms not implementing the
99 FEAT_SEL2 architecture extension.
100- The term VM refers to a normal world Virtual Machine managed by an Hypervisor.
101- The term SP refers to a secure world "Virtual Machine" managed by an SPMC.
102
103Support for legacy platforms
104----------------------------
105
106The SPM is split into a dispatcher and a core component (respectively SPMD and
107SPMC) residing at different exception levels. To permit the FF-A specification
108adoption and a smooth migration, the SPMD supports an SPMC residing either at
109S-EL1 or S-EL2:
110
111- The SPMD is located at EL3 and mainly relays the FF-A protocol from NWd
112 (Hypervisor or OS kernel) to the SPMC.
113- The same SPMD component is used for both S-EL1 and S-EL2 SPMC configurations.
114- The SPMC exception level is a build time choice.
115
116TF-A supports both cases:
117
118- S-EL1 SPMC for platforms not supporting the FEAT_SEL2 architecture
119 extension. The SPMD relays the FF-A protocol from EL3 to S-EL1.
120- S-EL2 SPMC for platforms implementing the FEAT_SEL2 architecture
121 extension. The SPMD relays the FF-A protocol from EL3 to S-EL2.
122
123Sample reference stack
124======================
125
126The following diagram illustrates a possible configuration when the
127FEAT_SEL2 architecture extension is implemented, showing the SPMD
128and SPMC, one or multiple secure partitions, with an optional
129Hypervisor:
130
131.. image:: ../resources/diagrams/ff-a-spm-sel2.png
132
133TF-A build options
134==================
135
136This section explains the TF-A build options involved in building with
137support for an FF-A based SPM where the SPMD is located at EL3 and the
138SPMC located at S-EL1, S-EL2 or EL3:
139
140- **SPD=spmd**: this option selects the SPMD component to relay the FF-A
141 protocol from NWd to SWd back and forth. It is not possible to
142 enable another Secure Payload Dispatcher when this option is chosen.
143- **SPMD_SPM_AT_SEL2**: this option adjusts the SPMC exception
144 level to being at S-EL2. It defaults to enabled (value 1) when
145 SPD=spmd is chosen.
146- **SPMC_AT_EL3**: this option adjusts the SPMC exception level to being
147 at EL3.
148- If neither ``SPMD_SPM_AT_SEL2`` or ``SPMC_AT_EL3`` are enabled the SPMC
149 exception level is set to S-EL1.
150 ``SPMD_SPM_AT_SEL2`` is enabled. The context save/restore routine
151 and exhaustive list of registers is visible at `[4]`_.
152- **SP_LAYOUT_FILE**: this option specifies a text description file
153 providing paths to SP binary images and manifests in DTS format
154 (see `Describing secure partitions`_). It
155 is required when ``SPMD_SPM_AT_SEL2`` is enabled hence when multiple
156 secure partitions are to be loaded by BL2 on behalf of the SPMC.
157
158+---------------+------------------+-------------+-------------------------+
159| | SPMD_SPM_AT_SEL2 | SPMC_AT_EL3 | CTX_INCLUDE_EL2_REGS(*) |
160+---------------+------------------+-------------+-------------------------+
161| SPMC at S-EL1 | 0 | 0 | 0 |
162+---------------+------------------+-------------+-------------------------+
163| SPMC at S-EL2 | 1 (default when | 0 | 1 |
164| | SPD=spmd) | | |
165+---------------+------------------+-------------+-------------------------+
166| SPMC at EL3 | 0 | 1 | 0 |
167+---------------+------------------+-------------+-------------------------+
168
169Other combinations of such build options either break the build or are not
170supported.
171
172Notes:
173
174- Only Arm's FVP platform is supported to use with the TF-A reference software
175 stack.
176- When ``SPMD_SPM_AT_SEL2=1``, the reference software stack assumes enablement
177 of FEAT_PAuth, FEAT_BTI and FEAT_MTE architecture extensions.
178- ``(*) CTX_INCLUDE_EL2_REGS``, this flag is TF-A internal and informational
179 in this table. When set, it provides the generic support for saving/restoring
180 EL2 registers required when S-EL2 firmware is present.
181- BL32 option is re-purposed to specify the SPMC image. It can specify either
182 the Hafnium binary path (built for the secure world) or the path to a TEE
183 binary implementing FF-A interfaces.
184- BL33 option can specify the TFTF binary or a normal world loader
185 such as U-Boot or the UEFI framework payload.
186
187Sample TF-A build command line when the SPMC is located at S-EL1
188(e.g. when the FEAT_SEL2 architecture extension is not implemented):
189
190.. code:: shell
191
192 make \
193 CROSS_COMPILE=aarch64-none-elf- \
194 SPD=spmd \
195 SPMD_SPM_AT_SEL2=0 \
196 BL32=<path-to-tee-binary> \
197 BL33=<path-to-bl33-binary> \
198 PLAT=fvp \
199 all fip
200
201Sample TF-A build command line when FEAT_SEL2 architecture extension is
202implemented and the SPMC is located at S-EL2:
203
204.. code:: shell
205
206 make \
207 CROSS_COMPILE=aarch64-none-elf- \
208 PLAT=fvp \
209 SPD=spmd \
210 ARM_ARCH_MINOR=5 \
211 BRANCH_PROTECTION=1 \
212 CTX_INCLUDE_PAUTH_REGS=1 \
213 CTX_INCLUDE_MTE_REGS=1 \
214 BL32=<path-to-hafnium-binary> \
215 BL33=<path-to-bl33-binary> \
216 SP_LAYOUT_FILE=sp_layout.json \
217 all fip
218
219Sample TF-A build command line when FEAT_SEL2 architecture extension is
220implemented, the SPMC is located at S-EL2, and enabling secure boot:
221
222.. code:: shell
223
224 make \
225 CROSS_COMPILE=aarch64-none-elf- \
226 PLAT=fvp \
227 SPD=spmd \
228 ARM_ARCH_MINOR=5 \
229 BRANCH_PROTECTION=1 \
230 CTX_INCLUDE_PAUTH_REGS=1 \
231 CTX_INCLUDE_MTE_REGS=1 \
232 BL32=<path-to-hafnium-binary> \
233 BL33=<path-to-bl33-binary> \
234 SP_LAYOUT_FILE=sp_layout.json \
235 MBEDTLS_DIR=<path-to-mbedtls-lib> \
236 TRUSTED_BOARD_BOOT=1 \
237 COT=dualroot \
238 ARM_ROTPK_LOCATION=devel_rsa \
239 ROT_KEY=plat/arm/board/common/rotpk/arm_rotprivk_rsa.pem \
240 GENERATE_COT=1 \
241 all fip
242
243Sample TF-A build command line when the SPMC is located at EL3:
244
245.. code:: shell
246
247 make \
248 CROSS_COMPILE=aarch64-none-elf- \
249 SPD=spmd \
250 SPMD_SPM_AT_SEL2=0 \
251 SPMC_AT_EL3=1 \
252 BL32=<path-to-tee-binary> \
253 BL33=<path-to-bl33-binary> \
254 PLAT=fvp \
255 all fip
256
257FVP model invocation
258====================
259
260The FVP command line needs the following options to exercise the S-EL2 SPMC:
261
262+---------------------------------------------------+------------------------------------+
263| - cluster0.has_arm_v8-5=1 | Implements FEAT_SEL2, FEAT_PAuth, |
264| - cluster1.has_arm_v8-5=1 | and FEAT_BTI. |
265+---------------------------------------------------+------------------------------------+
266| - pci.pci_smmuv3.mmu.SMMU_AIDR=2 | Parameters required for the |
267| - pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B | SMMUv3.2 modeling. |
268| - pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002 | |
269| - pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714 | |
270| - pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0472 | |
271| - pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002 | |
272| - pci.pci_smmuv3.mmu.SMMU_S_IDR2=0 | |
273| - pci.pci_smmuv3.mmu.SMMU_S_IDR3=0 | |
274+---------------------------------------------------+------------------------------------+
275| - cluster0.has_branch_target_exception=1 | Implements FEAT_BTI. |
276| - cluster1.has_branch_target_exception=1 | |
277+---------------------------------------------------+------------------------------------+
278| - cluster0.has_pointer_authentication=2 | Implements FEAT_PAuth |
279| - cluster1.has_pointer_authentication=2 | |
280+---------------------------------------------------+------------------------------------+
281| - cluster0.memory_tagging_support_level=2 | Implements FEAT_MTE2 |
282| - cluster1.memory_tagging_support_level=2 | |
283| - bp.dram_metadata.is_enabled=1 | |
284+---------------------------------------------------+------------------------------------+
285
286Sample FVP command line invocation:
287
288.. code:: shell
289
290 <path-to-fvp-model>/FVP_Base_RevC-2xAEMvA -C pctl.startup=0.0.0.0 \
291 -C cluster0.NUM_CORES=4 -C cluster1.NUM_CORES=4 -C bp.secure_memory=1 \
292 -C bp.secureflashloader.fname=trusted-firmware-a/build/fvp/debug/bl1.bin \
293 -C bp.flashloader0.fname=trusted-firmware-a/build/fvp/debug/fip.bin \
294 -C bp.pl011_uart0.out_file=fvp-uart0.log -C bp.pl011_uart1.out_file=fvp-uart1.log \
295 -C bp.pl011_uart2.out_file=fvp-uart2.log \
296 -C cluster0.has_arm_v8-5=1 -C cluster1.has_arm_v8-5=1 \
297 -C cluster0.has_pointer_authentication=2 -C cluster1.has_pointer_authentication=2 \
298 -C cluster0.has_branch_target_exception=1 -C cluster1.has_branch_target_exception=1 \
299 -C cluster0.memory_tagging_support_level=2 -C cluster1.memory_tagging_support_level=2 \
300 -C bp.dram_metadata.is_enabled=1 \
301 -C pci.pci_smmuv3.mmu.SMMU_AIDR=2 -C pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B \
302 -C pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002 -C pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714 \
303 -C pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0472 -C pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002 \
304 -C pci.pci_smmuv3.mmu.SMMU_S_IDR2=0 -C pci.pci_smmuv3.mmu.SMMU_S_IDR3=0
305
306Boot process
307============
308
309Loading Hafnium and secure partitions in the secure world
310---------------------------------------------------------
311
312TF-A BL2 is the bootlader for the SPMC and SPs in the secure world.
313
314SPs may be signed by different parties (SiP, OEM/ODM, TOS vendor, etc.).
315Thus they are supplied as distinct signed entities within the FIP flash
316image. The FIP image itself is not signed hence this provides the ability
317to upgrade SPs in the field.
318
319Booting through TF-A
320--------------------
321
322SP manifests
323~~~~~~~~~~~~
324
325An SP manifest describes SP attributes as defined in `[1]`_
326(partition manifest at virtual FF-A instance) in DTS format. It is
327represented as a single file associated with the SP. A sample is
328provided by `[5]`_. A binding document is provided by `[6]`_.
329
330Secure Partition packages
331~~~~~~~~~~~~~~~~~~~~~~~~~
332
333Secure partitions are bundled as independent package files consisting
334of:
335
336- a header
337- a DTB
338- an image payload
339
340The header starts with a magic value and offset values to SP DTB and
341image payload. Each SP package is loaded independently by BL2 loader
342and verified for authenticity and integrity.
343
344The SP package identified by its UUID (matching FF-A uuid property) is
345inserted as a single entry into the FIP at end of the TF-A build flow
346as shown:
347
348.. code:: shell
349
350 Trusted Boot Firmware BL2: offset=0x1F0, size=0x8AE1, cmdline="--tb-fw"
351 EL3 Runtime Firmware BL31: offset=0x8CD1, size=0x13000, cmdline="--soc-fw"
352 Secure Payload BL32 (Trusted OS): offset=0x1BCD1, size=0x15270, cmdline="--tos-fw"
353 Non-Trusted Firmware BL33: offset=0x30F41, size=0x92E0, cmdline="--nt-fw"
354 HW_CONFIG: offset=0x3A221, size=0x2348, cmdline="--hw-config"
355 TB_FW_CONFIG: offset=0x3C569, size=0x37A, cmdline="--tb-fw-config"
356 SOC_FW_CONFIG: offset=0x3C8E3, size=0x48, cmdline="--soc-fw-config"
357 TOS_FW_CONFIG: offset=0x3C92B, size=0x427, cmdline="--tos-fw-config"
358 NT_FW_CONFIG: offset=0x3CD52, size=0x48, cmdline="--nt-fw-config"
359 B4B5671E-4A90-4FE1-B81F-FB13DAE1DACB: offset=0x3CD9A, size=0xC168, cmdline="--blob"
360 D1582309-F023-47B9-827C-4464F5578FC8: offset=0x48F02, size=0xC168, cmdline="--blob"
361
362.. uml:: ../resources/diagrams/plantuml/fip-secure-partitions.puml
363
364Describing secure partitions
365~~~~~~~~~~~~~~~~~~~~~~~~~~~~
366
367A json-formatted description file is passed to the build flow specifying paths
368to the SP binary image and associated DTS partition manifest file. The latter
369is processed by the dtc compiler to generate a DTB fed into the SP package.
370Optionally, the partition's json description can contain offsets for both
371the image and partition manifest within the SP package. Both offsets need to be
3724KB aligned, because it is the translation granule supported by Hafnium SPMC.
373These fields can be leveraged to support SPs with S1 translation granules that
374differ from 4KB, and to configure the regions allocated within the SP package,
375as well as to comply with the requirements for the implementation of the boot
376information protocol (see `Passing boot data to the SP`_ for more details). In
377case the offsets are absent in their json node, they default to 0x1000 and
3780x4000 for the manifest offset and image offset respectively.
379This file also specifies the SP owner (as an optional field) identifying the
380signing domain in case of dual root CoT.
381The SP owner can either be the silicon or the platform provider. The
382corresponding "owner" field value can either take the value of "SiP" or "Plat".
383In absence of "owner" field, it defaults to "SiP" owner.
384The UUID of the partition can be specified as a field in the description file or
385if it does not exist there the UUID is extracted from the DTS partition
386manifest.
387
388.. code:: shell
389
390 {
391 "tee1" : {
392 "image": "tee1.bin",
393 "pm": "tee1.dts",
394 "owner": "SiP",
395 "uuid": "1b1820fe-48f7-4175-8999-d51da00b7c9f"
396 },
397
398 "tee2" : {
399 "image": "tee2.bin",
400 "pm": "tee2.dts",
401 "owner": "Plat"
402 },
403
404 "tee3" : {
405 "image": {
406 "file": "tee3.bin",
407 "offset":"0x2000"
408 },
409 "pm": {
410 "file": "tee3.dts",
411 "offset":"0x6000"
412 },
413 "owner": "Plat"
414 },
415 }
416
417SPMC manifest
418~~~~~~~~~~~~~
419
420This manifest contains the SPMC *attribute* node consumed by the SPMD at boot
421time. It implements `[1]`_ (SP manifest at physical FF-A instance) and serves
422two different cases:
423
424- The SPMC resides at S-EL1: the SPMC manifest is used by the SPMD to setup a
425 SP that co-resides with the SPMC and executes at S-EL1 or Secure Supervisor
426 mode.
427- The SPMC resides at S-EL2: the SPMC manifest is used by the SPMD to setup
428 the environment required by the SPMC to run at S-EL2. SPs run at S-EL1 or
429 S-EL0.
430
431.. code:: shell
432
433 attribute {
434 spmc_id = <0x8000>;
435 maj_ver = <0x1>;
436 min_ver = <0x1>;
437 exec_state = <0x0>;
438 load_address = <0x0 0x6000000>;
439 entrypoint = <0x0 0x6000000>;
440 binary_size = <0x60000>;
441 };
442
443- *spmc_id* defines the endpoint ID value that SPMC can query through
444 ``FFA_ID_GET``.
445- *maj_ver/min_ver*. SPMD checks provided version versus its internal
446 version and aborts if not matching.
447- *exec_state* defines the SPMC execution state (AArch64 or AArch32).
448 Notice Hafnium used as a SPMC only supports AArch64.
449- *load_address* and *binary_size* are mostly used to verify secondary
450 entry points fit into the loaded binary image.
451- *entrypoint* defines the cold boot primary core entry point used by
452 SPMD (currently matches ``BL32_BASE``) to enter the SPMC.
453
454Other nodes in the manifest are consumed by Hafnium in the secure world.
455A sample can be found at `[7]`_:
456
457- The *hypervisor* node describes SPs. *is_ffa_partition* boolean attribute
458 indicates a FF-A compliant SP. The *load_address* field specifies the load
459 address at which BL2 loaded the SP package.
460- *cpus* node provide the platform topology and allows MPIDR to VMPIDR mapping.
461 Note the primary core is declared first, then secondary cores are declared
462 in reverse order.
463- The *memory* nodes provide platform information on the ranges of memory
464 available for use by SPs at runtime. These ranges relate to either
465 secure or non-secure memory, depending on the *device_type* field.
466 If the field specifies "memory" the range is secure, else if it specifies
467 "ns-memory" the memory is non-secure. The system integrator must exclude
468 the memory used by other components that are not SPs, such as the monitor,
469 or the SPMC itself, the OS Kernel/Hypervisor, or other NWd VMs. The SPMC
470 limits the SP's address space such that they do not access memory outside
471 of those ranges.
472
473SPMC boot
474~~~~~~~~~
475
476The SPMC is loaded by BL2 as the BL32 image.
477
478The SPMC manifest is loaded by BL2 as the ``TOS_FW_CONFIG`` image `[9]`_.
479
480BL2 passes the SPMC manifest address to BL31 through a register.
481
482At boot time, the SPMD in BL31 runs from the primary core, initializes the core
483contexts and launches the SPMC (BL32) passing the following information through
484registers:
485
486- X0 holds the ``TOS_FW_CONFIG`` physical address (or SPMC manifest blob).
487- X1 holds the ``HW_CONFIG`` physical address.
488- X4 holds the currently running core linear id.
489
490Loading of SPs
491~~~~~~~~~~~~~~
492
493At boot time, BL2 loads SPs sequentially in addition to the SPMC as depicted
494below:
495
496.. uml:: ../resources/diagrams/plantuml/bl2-loading-sp.puml
497
498Note this boot flow is an implementation sample on Arm's FVP platform.
499Platforms not using TF-A's *Firmware CONFiguration* framework would adjust to a
500different boot flow. The flow restricts to a maximum of 8 secure partitions.
501
502Secure boot
503~~~~~~~~~~~
504
505The SP content certificate is inserted as a separate FIP item so that BL2 loads SPMC,
506SPMC manifest, secure partitions and verifies them for authenticity and integrity.
507Refer to TBBR specification `[3]`_.
508
509The multiple-signing domain feature (in current state dual signing domain `[8]`_) allows
510the use of two root keys namely S-ROTPK and NS-ROTPK:
511
512- SPMC (BL32) and SPMC manifest are signed by the SiP using the S-ROTPK.
513- BL33 may be signed by the OEM using NS-ROTPK.
514- An SP may be signed either by SiP (using S-ROTPK) or by OEM (using NS-ROTPK).
515- A maximum of 4 partitions can be signed with the S-ROTPK key and 4 partitions
516 signed with the NS-ROTPK key.
517
518Also refer to `Describing secure partitions`_ and `TF-A build options`_ sections.
519
520Hafnium in the secure world
521===========================
522
523General considerations
524----------------------
525
526Build platform for the secure world
527~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
528
529In the Hafnium reference implementation specific code parts are only relevant to
530the secure world. Such portions are isolated in architecture specific files
531and/or enclosed by a ``SECURE_WORLD`` macro.
532
533Secure partitions scheduling
534~~~~~~~~~~~~~~~~~~~~~~~~~~~~
535
536The FF-A specification `[1]`_ provides two ways to relinquinsh CPU time to
537secure partitions. For this a VM (Hypervisor or OS kernel), or SP invokes one of:
538
539- the FFA_MSG_SEND_DIRECT_REQ interface.
540- the FFA_RUN interface.
541
542Additionally a secure interrupt can pre-empt the normal world execution and give
543CPU cycles by transitioning to EL3 and S-EL2.
544
545Platform topology
546~~~~~~~~~~~~~~~~~
547
548The *execution-ctx-count* SP manifest field can take the value of one or the
549total number of PEs. The FF-A specification `[1]`_ recommends the
550following SP types:
551
552- Pinned MP SPs: an execution context matches a physical PE. MP SPs must
553 implement the same number of ECs as the number of PEs in the platform.
554- Migratable UP SPs: a single execution context can run and be migrated on any
555 physical PE. Such SP declares a single EC in its SP manifest. An UP SP can
556 receive a direct message request originating from any physical core targeting
557 the single execution context.
558
559Parsing SP partition manifests
560------------------------------
561
562Hafnium consumes SP manifests as defined in `[1]`_ and `SP manifests`_.
563Note the current implementation may not implement all optional fields.
564
565The SP manifest may contain memory and device regions nodes. In case of
566an S-EL2 SPMC:
567
568- Memory regions are mapped in the SP EL1&0 Stage-2 translation regime at
569 load time (or EL1&0 Stage-1 for an S-EL1 SPMC). A memory region node can
570 specify RX/TX buffer regions in which case it is not necessary for an SP
571 to explicitly invoke the ``FFA_RXTX_MAP`` interface. The memory referred
572 shall be contained within the memory ranges defined in SPMC manifest. The
573 NS bit in the attributes field should be consistent with the security
574 state of the range that it relates to. I.e. non-secure memory shall be
575 part of a non-secure memory range, and secure memory shall be contained
576 in a secure memory range of a given platform.
577- Device regions are mapped in the SP EL1&0 Stage-2 translation regime (or
578 EL1&0 Stage-1 for an S-EL1 SPMC) as peripherals and possibly allocate
579 additional resources (e.g. interrupts).
580
581For the S-EL2 SPMC, base addresses for memory and device region nodes are IPAs
582provided the SPMC identity maps IPAs to PAs within SP EL1&0 Stage-2 translation
583regime.
584
585Note: in the current implementation both VTTBR_EL2 and VSTTBR_EL2 point to the
586same set of page tables. It is still open whether two sets of page tables shall
587be provided per SP. The memory region node as defined in the specification
588provides a memory security attribute hinting to map either to the secure or
589non-secure EL1&0 Stage-2 table if it exists.
590
591Passing boot data to the SP
592---------------------------
593
594In `[1]`_ , the section "Boot information protocol" defines a method for passing
595data to the SPs at boot time. It specifies the format for the boot information
596descriptor and boot information header structures, which describe the data to be
597exchanged between SPMC and SP.
598The specification also defines the types of data that can be passed.
599The aggregate of both the boot info structures and the data itself is designated
600the boot information blob, and is passed to a Partition as a contiguous memory
601region.
602
603Currently, the SPM implementation supports the FDT type which is used to pass the
604partition's DTB manifest.
605
606The region for the boot information blob is allocated through the SP package.
607
608.. image:: ../resources/diagrams/partition-package.png
609
610To adjust the space allocated for the boot information blob, the json description
611of the SP (see section `Describing secure partitions`_) shall be updated to contain
612the manifest offset. If no offset is provided the manifest offset defaults to 0x1000,
613which is the page size in the Hafnium SPMC.
614
615The configuration of the boot protocol is done in the SPs manifest. As defined by
616the specification, the manifest field 'gp-register-num' configures the GP register
617which shall be used to pass the address to the partitions boot information blob when
618booting the partition.
619In addition, the Hafnium SPMC implementation requires the boot information arguments
620to be listed in a designated DT node:
621
622.. code:: shell
623
624 boot-info {
625 compatible = "arm,ffa-manifest-boot-info";
626 ffa_manifest;
627 };
628
629The whole secure partition package image (see `Secure Partition packages`_) is
630mapped to the SP secure EL1&0 Stage-2 translation regime. As such, the SP can
631retrieve the address for the boot information blob in the designated GP register,
632process the boot information header and descriptors, access its own manifest
633DTB blob and extract its partition manifest properties.
634
635SP Boot order
636-------------
637
638SP manifests provide an optional boot order attribute meant to resolve
639dependencies such as an SP providing a service required to properly boot
640another SP. SPMC boots the SPs in accordance to the boot order attribute,
641lowest to the highest value. If the boot order attribute is absent from the FF-A
642manifest, the SP is treated as if it had the highest boot order value
643(i.e. lowest booting priority).
644
645It is possible for an SP to call into another SP through a direct request
646provided the latter SP has already been booted.
647
648Boot phases
649-----------
650
651Primary core boot-up
652~~~~~~~~~~~~~~~~~~~~
653
654Upon boot-up, BL31 hands over to the SPMC (BL32) on the primary boot physical
655core. The SPMC performs its platform initializations and registers the SPMC
656secondary physical core entry point physical address by the use of the
657`FFA_SECONDARY_EP_REGISTER`_ interface (SMC invocation from the SPMC to the SPMD
658at secure physical FF-A instance).
659
660The SPMC then creates secure partitions based on SP packages and manifests. Each
661secure partition is launched in sequence (`SP Boot order`_) on their "primary"
662execution context. If the primary boot physical core linear id is N, an MP SP is
663started using EC[N] on PE[N] (see `Platform topology`_). If the partition is a
664UP SP, it is started using its unique EC0 on PE[N].
665
666The SP primary EC (or the EC used when the partition is booted as described
667above):
668
669- Performs the overall SP boot time initialization, and in case of a MP SP,
670 prepares the SP environment for other execution contexts.
671- In the case of a MP SP, it invokes the FFA_SECONDARY_EP_REGISTER at secure
672 virtual FF-A instance (SMC invocation from SP to SPMC) to provide the IPA
673 entry point for other execution contexts.
674- Exits through ``FFA_MSG_WAIT`` to indicate successful initialization or
675 ``FFA_ERROR`` in case of failure.
676
677Secondary cores boot-up
678~~~~~~~~~~~~~~~~~~~~~~~
679
680Once the system is started and NWd brought up, a secondary physical core is
681woken up by the ``PSCI_CPU_ON`` service invocation. The TF-A SPD hook mechanism
682calls into the SPMD on the newly woken up physical core. Then the SPMC is
683entered at the secondary physical core entry point.
684
685In the current implementation, the first SP is resumed on the coresponding EC
686(the virtual CPU which matches the physical core). The implication is that the
687first SP must be a MP SP.
688
689In a linux based system, once secure and normal worlds are booted but prior to
690a NWd FF-A driver has been loaded:
691
692- The first SP has initialized all its ECs in response to primary core boot up
693 (at system initialization) and secondary core boot up (as a result of linux
694 invoking PSCI_CPU_ON for all secondary cores).
695- Other SPs have their first execution context initialized as a result of secure
696 world initialization on the primary boot core. Other ECs for those SPs have to
697 be run first through ffa_run to complete their initialization (which results
698 in the EC completing with FFA_MSG_WAIT).
699
700Refer to `Power management`_ for further details.
701
702Notifications
703-------------
704
705The FF-A v1.1 specification `[1]`_ defines notifications as an asynchronous
706communication mechanism with non-blocking semantics. It allows for one FF-A
707endpoint to signal another for service provision, without hindering its current
708progress.
709
710Hafnium currently supports 64 notifications. The IDs of each notification define
711a position in a 64-bit bitmap.
712
713The signaling of notifications can interchangeably happen between NWd and SWd
714FF-A endpoints.
715
716The SPMC is in charge of managing notifications from SPs to SPs, from SPs to
717VMs, and from VMs to SPs. An hypervisor component would only manage
718notifications from VMs to VMs. Given the SPMC has no visibility of the endpoints
719deployed in NWd, the Hypervisor or OS kernel must invoke the interface
720FFA_NOTIFICATION_BITMAP_CREATE to allocate the notifications bitmap per FF-A
721endpoint in the NWd that supports it.
722
723A sender can signal notifications once the receiver has provided it with
724permissions. Permissions are provided by invoking the interface
725FFA_NOTIFICATION_BIND.
726
727Notifications are signaled by invoking FFA_NOTIFICATION_SET. Henceforth
728they are considered to be in a pending sate. The receiver can retrieve its
729pending notifications invoking FFA_NOTIFICATION_GET, which, from that moment,
730are considered to be handled.
731
732Per the FF-A v1.1 spec, each FF-A endpoint must be associated with a scheduler
733that is in charge of donating CPU cycles for notifications handling. The
734FF-A driver calls FFA_NOTIFICATION_INFO_GET to retrieve the information about
735which FF-A endpoints have pending notifications. The receiver scheduler is
736called and informed by the FF-A driver, and it should allocate CPU cycles to the
737receiver.
738
739There are two types of notifications supported:
740
741- Global, which are targeted to a FF-A endpoint and can be handled within any of
742 its execution contexts, as determined by the scheduler of the system.
743- Per-vCPU, which are targeted to a FF-A endpoint and to be handled within a
744 a specific execution context, as determined by the sender.
745
746The type of a notification is set when invoking FFA_NOTIFICATION_BIND to give
747permissions to the sender.
748
749Notification signaling resorts to two interrupts:
750
751- Schedule Receiver Interrupt: non-secure physical interrupt to be handled by
752 the FF-A driver within the receiver scheduler. At initialization the SPMC
753 donates a SGI ID chosen from the secure SGI IDs range and configures it as
754 non-secure. The SPMC triggers this SGI on the currently running core when
755 there are pending notifications, and the respective receivers need CPU cycles
756 to handle them.
757- Notifications Pending Interrupt: virtual interrupt to be handled by the
758 receiver of the notification. Set when there are pending notifications for the
759 given secure partition. The NPI is pended when the NWd relinquishes CPU cycles
760 to an SP.
761
762The notifications receipt support is enabled in the partition FF-A manifest.
763
764Mandatory interfaces
765--------------------
766
767The following interfaces are exposed to SPs:
768
769- ``FFA_VERSION``
770- ``FFA_FEATURES``
771- ``FFA_RX_RELEASE``
772- ``FFA_RXTX_MAP``
773- ``FFA_RXTX_UNMAP``
774- ``FFA_PARTITION_INFO_GET``
775- ``FFA_ID_GET``
776- ``FFA_MSG_WAIT``
777- ``FFA_MSG_SEND_DIRECT_REQ``
778- ``FFA_MSG_SEND_DIRECT_RESP``
779- ``FFA_MEM_DONATE``
780- ``FFA_MEM_LEND``
781- ``FFA_MEM_SHARE``
782- ``FFA_MEM_RETRIEVE_REQ``
783- ``FFA_MEM_RETRIEVE_RESP``
784- ``FFA_MEM_RELINQUISH``
785- ``FFA_MEM_FRAG_RX``
786- ``FFA_MEM_FRAG_TX``
787- ``FFA_MEM_RECLAIM``
788- ``FFA_RUN``
789
790As part of the FF-A v1.1 support, the following interfaces were added:
791
792 - ``FFA_NOTIFICATION_BITMAP_CREATE``
793 - ``FFA_NOTIFICATION_BITMAP_DESTROY``
794 - ``FFA_NOTIFICATION_BIND``
795 - ``FFA_NOTIFICATION_UNBIND``
796 - ``FFA_NOTIFICATION_SET``
797 - ``FFA_NOTIFICATION_GET``
798 - ``FFA_NOTIFICATION_INFO_GET``
799 - ``FFA_SPM_ID_GET``
800 - ``FFA_SECONDARY_EP_REGISTER``
801 - ``FFA_MEM_PERM_GET``
802 - ``FFA_MEM_PERM_SET``
803 - ``FFA_MSG_SEND2``
804 - ``FFA_RX_ACQUIRE``
805
Raghu Krishnamurthy4a793e92023-08-09 10:10:23 -0700806As part of the FF-A v1.2 support, the following interfaces were added:
807- ``FFA_PARTITION_INFO_GET_REGS``
808
Olivier Deprezcbf7d5b2023-05-22 12:12:24 +0200809FFA_VERSION
810~~~~~~~~~~~
811
812``FFA_VERSION`` requires a *requested_version* parameter from the caller.
813The returned value depends on the caller:
814
815- Hypervisor or OS kernel in NS-EL1/EL2: the SPMD returns the SPMC version
816 specified in the SPMC manifest.
817- SP: the SPMC returns its own implemented version.
818- SPMC at S-EL1/S-EL2: the SPMD returns its own implemented version.
819
820FFA_FEATURES
821~~~~~~~~~~~~
822
823FF-A features supported by the SPMC may be discovered by secure partitions at
824boot (that is prior to NWd is booted) or run-time.
825
826The SPMC calling FFA_FEATURES at secure physical FF-A instance always get
827FFA_SUCCESS from the SPMD.
828
829The request made by an Hypervisor or OS kernel is forwarded to the SPMC and
830the response relayed back to the NWd.
831
832FFA_RXTX_MAP/FFA_RXTX_UNMAP
833~~~~~~~~~~~~~~~~~~~~~~~~~~~
834
835When invoked from a secure partition FFA_RXTX_MAP maps the provided send and
836receive buffers described by their IPAs to the SP EL1&0 Stage-2 translation
837regime as secure buffers in the MMU descriptors.
838
839When invoked from the Hypervisor or OS kernel, the buffers are mapped into the
840SPMC EL2 Stage-1 translation regime and marked as NS buffers in the MMU
841descriptors. The provided addresses may be owned by a VM in the normal world,
842which is expected to receive messages from the secure world. The SPMC will in
843this case allocate internal state structures to facilitate RX buffer access
844synchronization (through FFA_RX_ACQUIRE interface), and to permit SPs to send
845messages.
846
847The FFA_RXTX_UNMAP unmaps the RX/TX pair from the translation regime of the
848caller, either it being the Hypervisor or OS kernel, as well as a secure
849partition.
850
851FFA_PARTITION_INFO_GET
852~~~~~~~~~~~~~~~~~~~~~~
853
854Partition info get call can originate:
855
856- from SP to SPMC
857- from Hypervisor or OS kernel to SPMC. The request is relayed by the SPMD.
858
Raghu Krishnamurthy4a793e92023-08-09 10:10:23 -0700859FFA_PARTITION_INFO_GET_REGS
860~~~~~~~~~~~~~~~~~~~~~~~~~~~
861
862This call can originate:
863
864- from SP to SPMC
865- from SPMC to SPMD
866- from Hypervsior or OS kernel to SPMC. The request is relayed by the SPMD.
867
868The primary use of this ABI is to return partition information via registers
869as opposed to via RX/TX buffers and is useful in cases where sharing memory is
870difficult.
871
Olivier Deprezcbf7d5b2023-05-22 12:12:24 +0200872FFA_ID_GET
873~~~~~~~~~~
874
875The FF-A id space is split into a non-secure space and secure space:
876
877- FF-A ID with bit 15 clear relates to VMs.
878- FF-A ID with bit 15 set related to SPs.
879- FF-A IDs 0, 0xffff, 0x8000 are assigned respectively to the Hypervisor, SPMD
880 and SPMC.
881
882The SPMD returns:
883
884- The default zero value on invocation from the Hypervisor.
885- The ``spmc_id`` value specified in the SPMC manifest on invocation from
886 the SPMC (see `SPMC manifest`_)
887
888This convention helps the SPMC to determine the origin and destination worlds in
889an FF-A ABI invocation. In particular the SPMC shall filter unauthorized
890transactions in its world switch routine. It must not be permitted for a VM to
891use a secure FF-A ID as origin world by spoofing:
892
893- A VM-to-SP direct request/response shall set the origin world to be non-secure
894 (FF-A ID bit 15 clear) and destination world to be secure (FF-A ID bit 15
895 set).
896- Similarly, an SP-to-SP direct request/response shall set the FF-A ID bit 15
897 for both origin and destination IDs.
898
899An incoming direct message request arriving at SPMD from NWd is forwarded to
900SPMC without a specific check. The SPMC is resumed through eret and "knows" the
901message is coming from normal world in this specific code path. Thus the origin
902endpoint ID must be checked by SPMC for being a normal world ID.
903
904An SP sending a direct message request must have bit 15 set in its origin
905endpoint ID and this can be checked by the SPMC when the SP invokes the ABI.
906
907The SPMC shall reject the direct message if the claimed world in origin endpoint
908ID is not consistent:
909
910- It is either forwarded by SPMD and thus origin endpoint ID must be a "normal
911 world ID",
912- or initiated by an SP and thus origin endpoint ID must be a "secure world ID".
913
914
915FFA_MSG_SEND_DIRECT_REQ/FFA_MSG_SEND_DIRECT_RESP
916~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
917
918This is a mandatory interface for secure partitions consisting in direct request
919and responses with the following rules:
920
921- An SP can send a direct request to another SP.
922- An SP can receive a direct request from another SP.
923- An SP can send a direct response to another SP.
924- An SP cannot send a direct request to an Hypervisor or OS kernel.
925- An Hypervisor or OS kernel can send a direct request to an SP.
926- An SP can send a direct response to an Hypervisor or OS kernel.
927
928FFA_NOTIFICATION_BITMAP_CREATE/FFA_NOTIFICATION_BITMAP_DESTROY
929~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
930
931The secure partitions notifications bitmap are statically allocated by the SPMC.
932Hence, this interface is not to be issued by secure partitions.
933
934At initialization, the SPMC is not aware of VMs/partitions deployed in the
935normal world. Hence, the Hypervisor or OS kernel must use both ABIs for SPMC
936to be prepared to handle notifications for the provided VM ID.
937
938FFA_NOTIFICATION_BIND/FFA_NOTIFICATION_UNBIND
939~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
940
941Pair of interfaces to manage permissions to signal notifications. Prior to
942handling notifications, an FF-A endpoint must allow a given sender to signal a
943bitmap of notifications.
944
945If the receiver doesn't have notification support enabled in its FF-A manifest,
946it won't be able to bind notifications, hence forbidding it to receive any
947notifications.
948
949FFA_NOTIFICATION_SET/FFA_NOTIFICATION_GET
950~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
951
952FFA_NOTIFICATION_GET retrieves all pending global notifications and
953per-vCPU notifications targeted to the current vCPU.
954
955Hafnium maintains a global count of pending notifications which gets incremented
956and decremented when handling FFA_NOTIFICATION_SET and FFA_NOTIFICATION_GET
957respectively. A delayed SRI is triggered if the counter is non-zero when the
958SPMC returns to normal world.
959
960FFA_NOTIFICATION_INFO_GET
961~~~~~~~~~~~~~~~~~~~~~~~~~
962
963Hafnium maintains a global count of pending notifications whose information
964has been retrieved by this interface. The count is incremented and decremented
965when handling FFA_NOTIFICATION_INFO_GET and FFA_NOTIFICATION_GET respectively.
966It also tracks notifications whose information has been retrieved individually,
967such that it avoids duplicating returned information for subsequent calls to
968FFA_NOTIFICATION_INFO_GET. For each notification, this state information is
969reset when receiver called FFA_NOTIFICATION_GET to retrieve them.
970
971FFA_SPM_ID_GET
972~~~~~~~~~~~~~~
973
974Returns the FF-A ID allocated to an SPM component which can be one of SPMD
975or SPMC.
976
977At initialization, the SPMC queries the SPMD for the SPMC ID, using the
978FFA_ID_GET interface, and records it. The SPMC can also query the SPMD ID using
979the FFA_SPM_ID_GET interface at the secure physical FF-A instance.
980
981Secure partitions call this interface at the virtual FF-A instance, to which
982the SPMC returns the priorly retrieved SPMC ID.
983
984The Hypervisor or OS kernel can issue the FFA_SPM_ID_GET call handled by the
985SPMD, which returns the SPMC ID.
986
987FFA_SECONDARY_EP_REGISTER
988~~~~~~~~~~~~~~~~~~~~~~~~~
989
990When the SPMC boots, all secure partitions are initialized on their primary
991Execution Context.
992
993The FFA_SECONDARY_EP_REGISTER interface is to be used by a secure partition
994from its first execution context, to provide the entry point address for
995secondary execution contexts.
996
997A secondary EC is first resumed either upon invocation of PSCI_CPU_ON from
998the NWd or by invocation of FFA_RUN.
999
1000FFA_RX_ACQUIRE/FFA_RX_RELEASE
1001~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1002
1003The RX buffers can be used to pass information to an FF-A endpoint in the
1004following scenarios:
1005
1006 - When it was targetted by a FFA_MSG_SEND2 invokation from another endpoint.
1007 - Return the result of calling ``FFA_PARTITION_INFO_GET``.
1008 - In a memory share operation, as part of the ``FFA_MEM_RETRIEVE_RESP``,
1009 with the memory descriptor of the shared memory.
1010
1011If a normal world VM is expected to exchange messages with secure world,
1012its RX/TX buffer addresses are forwarded to the SPMC via FFA_RXTX_MAP ABI,
1013and are from this moment owned by the SPMC.
1014The hypervisor must call the FFA_RX_ACQUIRE interface before attempting
1015to use the RX buffer, in any of the aforementioned scenarios. A successful
1016call to FFA_RX_ACQUIRE transfers ownership of RX buffer to hypervisor, such
1017that it can be safely used.
1018
1019The FFA_RX_RELEASE interface is used after the FF-A endpoint is done with
1020processing the data received in its RX buffer. If the RX buffer has been
1021acquired by the hypervisor, the FFA_RX_RELEASE call must be forwarded to
1022the SPMC to reestablish SPMC's RX ownership.
1023
1024An attempt from an SP to send a message to a normal world VM whose RX buffer
1025was acquired by the hypervisor fails with error code FFA_BUSY, to preserve
1026the RX buffer integrity.
1027The operation could then be conducted after FFA_RX_RELEASE.
1028
1029FFA_MSG_SEND2
1030~~~~~~~~~~~~~
1031
1032Hafnium copies a message from the sender TX buffer into receiver's RX buffer.
1033For messages from SPs to VMs, operation is only possible if the SPMC owns
1034the receiver's RX buffer.
1035
1036Both receiver and sender need to enable support for indirect messaging,
1037in their respective partition manifest. The discovery of support
1038of such feature can be done via FFA_PARTITION_INFO_GET.
1039
1040On a successful message send, Hafnium pends an RX buffer full framework
1041notification for the receiver, to inform it about a message in the RX buffer.
1042
1043The handling of framework notifications is similar to that of
1044global notifications. Binding of these is not necessary, as these are
1045reserved to be used by the hypervisor or SPMC.
1046
1047SPMC-SPMD direct requests/responses
1048-----------------------------------
1049
1050Implementation-defined FF-A IDs are allocated to the SPMC and SPMD.
1051Using those IDs in source/destination fields of a direct request/response
1052permits SPMD to SPMC communication and either way.
1053
1054- SPMC to SPMD direct request/response uses SMC conduit.
1055- SPMD to SPMC direct request/response uses ERET conduit.
1056
1057This is used in particular to convey power management messages.
1058
1059Memory Sharing
1060--------------
1061
1062Hafnium implements the following memory sharing interfaces:
1063
1064 - ``FFA_MEM_SHARE`` - for shared access between lender and borrower.
1065 - ``FFA_MEM_LEND`` - borrower to obtain exclusive access, though lender
1066 retains ownership of the memory.
1067 - ``FFA_MEM_DONATE`` - lender permanently relinquishes ownership of memory
1068 to the borrower.
1069
1070The ``FFA_MEM_RETRIEVE_REQ`` interface is for the borrower to request the
1071memory to be mapped into its address space: for S-EL1 partitions the SPM updates
1072their stage 2 translation regime; for S-EL0 partitions the SPM updates their
1073stage 1 translation regime. On a successful call, the SPMC responds back with
1074``FFA_MEM_RETRIEVE_RESP``.
1075
1076The ``FFA_MEM_RELINQUISH`` interface is for when the borrower is done with using
1077a memory region.
1078
1079The ``FFA_MEM_RECLAIM`` interface is for the owner of the memory to reestablish
1080its ownership and exclusive access to the memory shared.
1081
1082The memory transaction descriptors are transmitted via RX/TX buffers. In
1083situations where the size of the memory transaction descriptor exceeds the
1084size of the RX/TX buffers, Hafnium provides support for fragmented transmission
1085of the full transaction descriptor. The ``FFA_MEM_FRAG_RX`` and ``FFA_MEM_FRAG_TX``
1086interfaces are for receiving and transmitting the next fragment, respectively.
1087
1088If lender and borrower(s) are SPs, all memory sharing operations are supported.
1089
1090Hafnium also supports memory sharing operations between the normal world and the
1091secure world. If there is an SP involved, the SPMC allocates data to track the
1092state of the operation.
1093
1094The SPMC is also the designated allocator for the memory handle. The hypervisor
1095or OS kernel has the possibility to rely on the SPMC to maintain the state
1096of the operation, thus saving memory.
1097A lender SP can only donate NS memory to a borrower from the normal world.
1098
1099The SPMC supports the hypervisor retrieve request, as defined by the FF-A
1100v1.1 EAC0 specification, in section 16.4.3. The intent is to aid with operations
1101that the hypervisor must do for a VM retriever. For example, when handling
1102an FFA_MEM_RECLAIM, if the hypervisor relies on SPMC to keep the state
1103of the operation, the hypervisor retrieve request can be used to obtain
1104that state information, do the necessary validations, and update stage 2
1105memory translation.
1106
1107Hafnium also supports memory lend and share targetting multiple borrowers.
1108This is the case for a lender SP to multiple SPs, and for a lender VM to
1109multiple endpoints (from both secure world and normal world). If there is
1110at least one borrower VM, the hypervisor is in charge of managing its
1111stage 2 translation on a successful memory retrieve.
1112The semantics of ``FFA_MEM_DONATE`` implies ownership transmission,
1113which should target only one partition.
1114
1115The memory share interfaces are backwards compatible with memory transaction
1116descriptors from FF-A v1.0. These get translated to FF-A v1.1 descriptors for
1117Hafnium's internal processing of the operation. If the FF-A version of a
1118borrower is v1.0, Hafnium provides FF-A v1.0 compliant memory transaction
1119descriptors on memory retrieve response.
1120
1121PE MMU configuration
1122--------------------
1123
1124With secure virtualization enabled (``HCR_EL2.VM = 1``) and for S-EL1
1125partitions, two IPA spaces (secure and non-secure) are output from the
1126secure EL1&0 Stage-1 translation.
1127The EL1&0 Stage-2 translation hardware is fed by:
1128
1129- A secure IPA when the SP EL1&0 Stage-1 MMU is disabled.
1130- One of secure or non-secure IPA when the secure EL1&0 Stage-1 MMU is enabled.
1131
1132``VTCR_EL2`` and ``VSTCR_EL2`` provide configuration bits for controlling the
1133NS/S IPA translations. The following controls are set up:
1134``VSTCR_EL2.SW = 0`` , ``VSTCR_EL2.SA = 0``, ``VTCR_EL2.NSW = 0``,
1135``VTCR_EL2.NSA = 1``:
1136
1137- Stage-2 translations for the NS IPA space access the NS PA space.
1138- Stage-2 translation table walks for the NS IPA space are to the secure PA space.
1139
1140Secure and non-secure IPA regions (rooted to by ``VTTBR_EL2`` and ``VSTTBR_EL2``)
1141use the same set of Stage-2 page tables within a SP.
1142
1143The ``VTCR_EL2/VSTCR_EL2/VTTBR_EL2/VSTTBR_EL2`` virtual address space
1144configuration is made part of a vCPU context.
1145
1146For S-EL0 partitions with VHE enabled, a single secure EL2&0 Stage-1 translation
1147regime is used for both Hafnium and the partition.
1148
1149Schedule modes and SP Call chains
1150---------------------------------
1151
1152An SP execution context is said to be in SPMC scheduled mode if CPU cycles are
1153allocated to it by SPMC. Correspondingly, an SP execution context is said to be
1154in Normal world scheduled mode if CPU cycles are allocated by the normal world.
1155
1156A call chain represents all SPs in a sequence of invocations of a direct message
1157request. When execution on a PE is in the secure state, only a single call chain
1158that runs in the Normal World scheduled mode can exist. FF-A v1.1 spec allows
1159any number of call chains to run in the SPMC scheduled mode but the Hafnium
1160SPMC restricts the number of call chains in SPMC scheduled mode to only one for
1161keeping the implementation simple.
1162
1163Partition runtime models
1164------------------------
1165
1166The runtime model of an endpoint describes the transitions permitted for an
1167execution context between various states. These are the four partition runtime
1168models supported (refer to `[1]`_ section 7):
1169
1170 - RTM_FFA_RUN: runtime model presented to an execution context that is
1171 allocated CPU cycles through FFA_RUN interface.
1172 - RTM_FFA_DIR_REQ: runtime model presented to an execution context that is
1173 allocated CPU cycles through FFA_MSG_SEND_DIRECT_REQ interface.
1174 - RTM_SEC_INTERRUPT: runtime model presented to an execution context that is
1175 allocated CPU cycles by SPMC to handle a secure interrupt.
1176 - RTM_SP_INIT: runtime model presented to an execution context that is
1177 allocated CPU cycles by SPMC to initialize its state.
1178
1179If an endpoint execution context attempts to make an invalid transition or a
1180valid transition that could lead to a loop in the call chain, SPMC denies the
1181transition with the help of above runtime models.
1182
1183Interrupt management
1184--------------------
1185
1186GIC ownership
1187~~~~~~~~~~~~~
1188
1189The SPMC owns the GIC configuration. Secure and non-secure interrupts are
1190trapped at S-EL2. The SPMC manages interrupt resources and allocates interrupt
1191IDs based on SP manifests. The SPMC acknowledges physical interrupts and injects
1192virtual interrupts by setting the use of vIRQ/vFIQ bits before resuming a SP.
1193
1194Abbreviations:
1195
1196 - NS-Int: A non-secure physical interrupt. It requires a switch to the normal
1197 world to be handled if it triggers while execution is in secure world.
1198 - Other S-Int: A secure physical interrupt targeted to an SP different from
1199 the one that is currently running.
1200 - Self S-Int: A secure physical interrupt targeted to the SP that is currently
1201 running.
1202
1203Non-secure interrupt handling
1204~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1205
1206This section documents the actions supported in SPMC in response to a non-secure
1207interrupt as per the guidance provided by FF-A v1.1 EAC0 specification.
1208An SP specifies one of the following actions in its partition manifest:
1209
1210 - Non-secure interrupt is signaled.
1211 - Non-secure interrupt is signaled after a managed exit.
1212 - Non-secure interrupt is queued.
1213
1214An SP execution context in a call chain could specify a less permissive action
1215than subsequent SP execution contexts in the same call chain. The less
1216permissive action takes precedence over the more permissive actions specified
1217by the subsequent execution contexts. Please refer to FF-A v1.1 EAC0 section
12188.3.1 for further explanation.
1219
1220Secure interrupt handling
1221~~~~~~~~~~~~~~~~~~~~~~~~~
1222
1223This section documents the support implemented for secure interrupt handling in
1224SPMC as per the guidance provided by FF-A v1.1 EAC0 specification.
1225The following assumptions are made about the system configuration:
1226
1227 - In the current implementation, S-EL1 SPs are expected to use the para
1228 virtualized ABIs for interrupt management rather than accessing the virtual
1229 GIC interface.
1230 - Unless explicitly stated otherwise, this support is applicable only for
1231 S-EL1 SPs managed by SPMC.
1232 - Secure interrupts are configured as G1S or G0 interrupts.
1233 - All physical interrupts are routed to SPMC when running a secure partition
1234 execution context.
1235 - All endpoints with multiple execution contexts have their contexts pinned
1236 to corresponding CPUs. Hence, a secure virtual interrupt cannot be signaled
1237 to a target vCPU that is currently running or blocked on a different
1238 physical CPU.
1239
1240A physical secure interrupt could trigger while CPU is executing in normal world
1241or secure world.
1242The action of SPMC for a secure interrupt depends on: the state of the target
1243execution context of the SP that is responsible for handling the interrupt;
1244whether the interrupt triggered while execution was in normal world or secure
1245world.
1246
1247Secure interrupt signaling mechanisms
1248~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1249
1250Signaling refers to the mechanisms used by SPMC to indicate to the SP execution
1251context that it has a pending virtual interrupt and to further run the SP
1252execution context, such that it can handle the virtual interrupt. SPMC uses
1253either the FFA_INTERRUPT interface with ERET conduit or vIRQ signal for signaling
1254to S-EL1 SPs. When normal world execution is preempted by a secure interrupt,
1255the SPMD uses the FFA_INTERRUPT ABI with ERET conduit to signal interrupt to SPMC
1256running in S-EL2.
1257
1258+-----------+---------+---------------+---------------------------------------+
1259| SP State | Conduit | Interface and | Description |
1260| | | parameters | |
1261+-----------+---------+---------------+---------------------------------------+
1262| WAITING | ERET, | FFA_INTERRUPT,| SPMC signals to SP the ID of pending |
1263| | vIRQ | Interrupt ID | interrupt. It pends vIRQ signal and |
1264| | | | resumes execution context of SP |
1265| | | | through ERET. |
1266+-----------+---------+---------------+---------------------------------------+
1267| BLOCKED | ERET, | FFA_INTERRUPT | SPMC signals to SP that an interrupt |
1268| | vIRQ | | is pending. It pends vIRQ signal and |
1269| | | | resumes execution context of SP |
1270| | | | through ERET. |
1271+-----------+---------+---------------+---------------------------------------+
1272| PREEMPTED | vIRQ | NA | SPMC pends the vIRQ signal but does |
1273| | | | not resume execution context of SP. |
1274+-----------+---------+---------------+---------------------------------------+
1275| RUNNING | ERET, | NA | SPMC pends the vIRQ signal and resumes|
1276| | vIRQ | | execution context of SP through ERET. |
1277+-----------+---------+---------------+---------------------------------------+
1278
1279Secure interrupt completion mechanisms
1280~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1281
1282A SP signals secure interrupt handling completion to the SPMC through the
1283following mechanisms:
1284
1285 - ``FFA_MSG_WAIT`` ABI if it was in WAITING state.
1286 - ``FFA_RUN`` ABI if its was in BLOCKED state.
1287
1288This is a remnant of SPMC implementation based on the FF-A v1.0 specification.
1289In the current implementation, S-EL1 SPs use the para-virtualized HVC interface
1290implemented by SPMC to perform priority drop and interrupt deactivation (SPMC
1291configures EOImode = 0, i.e. priority drop and deactivation are done together).
1292The SPMC performs checks to deny the state transition upon invocation of
1293either FFA_MSG_WAIT or FFA_RUN interface if the SP didn't perform the
1294deactivation of the secure virtual interrupt.
1295
1296If the current SP execution context was preempted by a secure interrupt to be
1297handled by execution context of target SP, SPMC resumes current SP after signal
1298completion by target SP execution context.
1299
1300Actions for a secure interrupt triggered while execution is in normal world
1301~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1302
1303+-------------------+----------+-----------------------------------------------+
1304| State of target | Action | Description |
1305| execution context | | |
1306+-------------------+----------+-----------------------------------------------+
1307| WAITING | Signaled | This starts a new call chain in SPMC scheduled|
1308| | | mode. |
1309+-------------------+----------+-----------------------------------------------+
1310| PREEMPTED | Queued | The target execution must have been preempted |
1311| | | by a non-secure interrupt. SPMC queues the |
1312| | | secure virtual interrupt now. It is signaled |
1313| | | when the target execution context next enters |
1314| | | the RUNNING state. |
1315+-------------------+----------+-----------------------------------------------+
1316| BLOCKED, RUNNING | NA | The target execution context is blocked or |
1317| | | running on a different CPU. This is not |
1318| | | supported by current SPMC implementation and |
1319| | | execution hits panic. |
1320+-------------------+----------+-----------------------------------------------+
1321
1322If normal world execution was preempted by a secure interrupt, SPMC uses
1323FFA_NORMAL_WORLD_RESUME ABI to indicate completion of secure interrupt handling
1324and further returns execution to normal world.
1325
1326The following figure describes interrupt handling flow when a secure interrupt
1327triggers while execution is in normal world:
1328
1329.. image:: ../resources/diagrams/ffa-secure-interrupt-handling-nwd.png
1330
1331A brief description of the events:
1332
1333 - 1) Secure interrupt triggers while normal world is running.
1334 - 2) FIQ gets trapped to EL3.
1335 - 3) SPMD signals secure interrupt to SPMC at S-EL2 using FFA_INTERRUPT ABI.
1336 - 4) SPMC identifies target vCPU of SP and injects virtual interrupt (pends
1337 vIRQ).
1338 - 5) Assuming SP1 vCPU is in WAITING state, SPMC signals virtual interrupt
1339 using FFA_INTERRUPT with interrupt id as an argument and resumes the SP1
1340 vCPU using ERET in SPMC scheduled mode.
1341 - 6) Execution traps to vIRQ handler in SP1 provided that the virtual
1342 interrupt is not masked i.e., PSTATE.I = 0
1343 - 7) SP1 queries for the pending virtual interrupt id using a paravirtualized
1344 HVC call. SPMC clears the pending virtual interrupt state management
1345 and returns the pending virtual interrupt id.
1346 - 8) SP1 services the virtual interrupt and invokes the paravirtualized
1347 de-activation HVC call. SPMC de-activates the physical interrupt,
1348 clears the fields tracking the secure interrupt and resumes SP1 vCPU.
1349 - 9) SP1 performs secure interrupt completion through FFA_MSG_WAIT ABI.
1350 - 10) SPMC returns control to EL3 using FFA_NORMAL_WORLD_RESUME.
1351 - 11) EL3 resumes normal world execution.
1352
1353Actions for a secure interrupt triggered while execution is in secure world
1354~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1355
1356+-------------------+----------+------------------------------------------------+
1357| State of target | Action | Description |
1358| execution context | | |
1359+-------------------+----------+------------------------------------------------+
1360| WAITING | Signaled | This starts a new call chain in SPMC scheduled |
1361| | | mode. |
1362+-------------------+----------+------------------------------------------------+
1363| PREEMPTED by Self | Signaled | The target execution context reenters the |
1364| S-Int | | RUNNING state to handle the secure virtual |
1365| | | interrupt. |
1366+-------------------+----------+------------------------------------------------+
1367| PREEMPTED by | Queued | SPMC queues the secure virtual interrupt now. |
1368| NS-Int | | It is signaled when the target execution |
1369| | | context next enters the RUNNING state. |
1370+-------------------+----------+------------------------------------------------+
1371| BLOCKED | Signaled | Both preempted and target execution contexts |
1372| | | must have been part of the Normal world |
1373| | | scheduled call chain. Refer scenario 1 of |
1374| | | Table 8.4 in the FF-A v1.1 EAC0 spec. |
1375+-------------------+----------+------------------------------------------------+
1376| RUNNING | NA | The target execution context is running on a |
1377| | | different CPU. This scenario is not supported |
1378| | | by current SPMC implementation and execution |
1379| | | hits panic. |
1380+-------------------+----------+------------------------------------------------+
1381
1382The following figure describes interrupt handling flow when a secure interrupt
1383triggers while execution is in secure world. We assume OS kernel sends a direct
1384request message to SP1. Further, SP1 sends a direct request message to SP2. SP1
1385enters BLOCKED state and SPMC resumes SP2.
1386
1387.. image:: ../resources/diagrams/ffa-secure-interrupt-handling-swd.png
1388
1389A brief description of the events:
1390
1391 - 1) Secure interrupt triggers while SP2 is running.
1392 - 2) SP2 gets preempted and execution traps to SPMC as IRQ.
1393 - 3) SPMC finds the target vCPU of secure partition responsible for handling
1394 this secure interrupt. In this scenario, it is SP1.
1395 - 4) SPMC pends vIRQ for SP1 and signals through FFA_INTERRUPT interface.
1396 SPMC further resumes SP1 through ERET conduit. Note that SP1 remains in
1397 Normal world schedule mode.
1398 - 6) Execution traps to vIRQ handler in SP1 provided that the virtual
1399 interrupt is not masked i.e., PSTATE.I = 0
1400 - 7) SP1 queries for the pending virtual interrupt id using a paravirtualized
1401 HVC call. SPMC clears the pending virtual interrupt state management
1402 and returns the pending virtual interrupt id.
1403 - 8) SP1 services the virtual interrupt and invokes the paravirtualized
1404 de-activation HVC call. SPMC de-activates the physical interrupt and
1405 clears the fields tracking the secure interrupt and resumes SP1 vCPU.
1406 - 9) Since SP1 direct request completed with FFA_INTERRUPT, it resumes the
1407 direct request to SP2 by invoking FFA_RUN.
1408 - 9) SPMC resumes the pre-empted vCPU of SP2.
1409
1410EL3 interrupt handling
1411~~~~~~~~~~~~~~~~~~~~~~
1412
1413In GICv3 based systems, EL3 interrupts are configured as Group0 secure
1414interrupts. Execution traps to SPMC when a Group0 interrupt triggers while an
1415SP is running. Further, SPMC running at S-EL2 uses FFA_EL3_INTR_HANDLE ABI to
1416request EL3 platform firmware to handle a pending Group0 interrupt.
1417Similarly, SPMD registers a handler with interrupt management framework to
1418delegate handling of Group0 interrupt to the platform if the interrupt triggers
1419in normal world.
1420
1421 - Platform hook
1422
1423 - plat_spmd_handle_group0_interrupt
1424
1425 SPMD provides platform hook to handle Group0 secure interrupts. In the
1426 current design, SPMD expects the platform not to delegate handling to the
1427 NWd (such as through SDEI) while processing Group0 interrupts.
1428
1429Power management
1430----------------
1431
1432In platforms with or without secure virtualization:
1433
1434- The NWd owns the platform PM policy.
1435- The Hypervisor or OS kernel is the component initiating PSCI service calls.
1436- The EL3 PSCI library is in charge of the PM coordination and control
1437 (eventually writing to platform registers).
1438- While coordinating PM events, the PSCI library calls backs into the Secure
1439 Payload Dispatcher for events the latter has statically registered to.
1440
1441When using the SPMD as a Secure Payload Dispatcher:
1442
1443- A power management event is relayed through the SPD hook to the SPMC.
1444- In the current implementation only cpu on (svc_on_finish) and cpu off
1445 (svc_off) hooks are registered.
1446- The behavior for the cpu on event is described in `Secondary cores boot-up`_.
1447 The SPMC is entered through its secondary physical core entry point.
1448- The cpu off event occurs when the NWd calls PSCI_CPU_OFF. The PM event is
1449 signaled to the SPMC through a power management framework message.
1450 It consists in a SPMD-to-SPMC direct request/response (`SPMC-SPMD direct
1451 requests/responses`_) conveying the event details and SPMC response.
1452 The SPMD performs a synchronous entry into the SPMC. The SPMC is entered and
1453 updates its internal state to reflect the physical core is being turned off.
1454 In the current implementation no SP is resumed as a consequence. This behavior
1455 ensures a minimal support for CPU hotplug e.g. when initiated by the NWd linux
1456 userspace.
1457
1458Arm architecture extensions for security hardening
1459==================================================
1460
1461Hafnium supports the following architecture extensions for security hardening:
1462
1463- Pointer authentication (FEAT_PAuth): the extension permits detection of forged
1464 pointers used by ROP type of attacks through the signing of the pointer
1465 value. Hafnium is built with the compiler branch protection option to permit
1466 generation of a pointer authentication code for return addresses (pointer
1467 authentication for instructions). The APIA key is used while Hafnium runs.
1468 A random key is generated at boot time and restored upon entry into Hafnium
1469 at run-time. APIA and other keys (APIB, APDA, APDB, APGA) are saved/restored
1470 in vCPU contexts permitting to enable pointer authentication in VMs/SPs.
1471- Branch Target Identification (FEAT_BTI): the extension permits detection of
1472 unexpected indirect branches used by JOP type of attacks. Hafnium is built
1473 with the compiler branch protection option, inserting land pads at function
1474 prologues that are reached by indirect branch instructions (BR/BLR).
1475 Hafnium code pages are marked as guarded in the EL2 Stage-1 MMU descriptors
1476 such that an indirect branch must always target a landpad. A fault is
1477 triggered otherwise. VMs/SPs can (independently) mark their code pages as
1478 guarded in the EL1&0 Stage-1 translation regime.
1479- Memory Tagging Extension (FEAT_MTE): the option permits detection of out of
1480 bound memory array accesses or re-use of an already freed memory region.
1481 Hafnium enables the compiler option permitting to leverage MTE stack tagging
1482 applied to core stacks. Core stacks are marked as normal tagged memory in the
1483 EL2 Stage-1 translation regime. A synchronous data abort is generated upon tag
1484 check failure on load/stores. A random seed is generated at boot time and
1485 restored upon entry into Hafnium. MTE system registers are saved/restored in
1486 vCPU contexts permitting MTE usage from VMs/SPs.
1487
1488SMMUv3 support in Hafnium
1489=========================
1490
1491An SMMU is analogous to an MMU in a CPU. It performs address translations for
1492Direct Memory Access (DMA) requests from system I/O devices.
1493The responsibilities of an SMMU include:
1494
1495- Translation: Incoming DMA requests are translated from bus address space to
1496 system physical address space using translation tables compliant to
1497 Armv8/Armv7 VMSA descriptor format.
1498- Protection: An I/O device can be prohibited from read, write access to a
1499 memory region or allowed.
1500- Isolation: Traffic from each individial device can be independently managed.
1501 The devices are differentiated from each other using unique translation
1502 tables.
1503
1504The following diagram illustrates a typical SMMU IP integrated in a SoC with
1505several I/O devices along with Interconnect and Memory system.
1506
1507.. image:: ../resources/diagrams/MMU-600.png
1508
1509SMMU has several versions including SMMUv1, SMMUv2 and SMMUv3. Hafnium provides
1510support for SMMUv3 driver in both normal and secure world. A brief introduction
1511of SMMUv3 functionality and the corresponding software support in Hafnium is
1512provided here.
1513
1514SMMUv3 features
1515---------------
1516
1517- SMMUv3 provides Stage1, Stage2 translation as well as nested (Stage1 + Stage2)
1518 translation support. It can either bypass or abort incoming translations as
1519 well.
1520- Traffic (memory transactions) from each upstream I/O peripheral device,
1521 referred to as Stream, can be independently managed using a combination of
1522 several memory based configuration structures. This allows the SMMUv3 to
1523 support a large number of streams with each stream assigned to a unique
1524 translation context.
1525- Support for Armv8.1 VMSA where the SMMU shares the translation tables with
1526 a Processing Element. AArch32(LPAE) and AArch64 translation table format
1527 are supported by SMMUv3.
1528- SMMUv3 offers non-secure stream support with secure stream support being
1529 optional. Logically, SMMUv3 behaves as if there is an indepdendent SMMU
1530 instance for secure and non-secure stream support.
1531- It also supports sub-streams to differentiate traffic from a virtualized
1532 peripheral associated with a VM/SP.
1533- Additionally, SMMUv3.2 provides support for PEs implementing Armv8.4-A
1534 extensions. Consequently, SPM depends on Secure EL2 support in SMMUv3.2
1535 for providing Secure Stage2 translation support to upstream peripheral
1536 devices.
1537
1538SMMUv3 Programming Interfaces
1539-----------------------------
1540
1541SMMUv3 has three software interfaces that are used by the Hafnium driver to
1542configure the behaviour of SMMUv3 and manage the streams.
1543
1544- Memory based data strutures that provide unique translation context for
1545 each stream.
1546- Memory based circular buffers for command queue and event queue.
1547- A large number of SMMU configuration registers that are memory mapped during
1548 boot time by Hafnium driver. Except a few registers, all configuration
1549 registers have independent secure and non-secure versions to configure the
1550 behaviour of SMMUv3 for translation of secure and non-secure streams
1551 respectively.
1552
1553Peripheral device manifest
1554--------------------------
1555
1556Currently, SMMUv3 driver in Hafnium only supports dependent peripheral devices.
1557These devices are dependent on PE endpoint to initiate and receive memory
1558management transactions on their behalf. The acccess to the MMIO regions of
1559any such device is assigned to the endpoint during boot. Moreover, SMMUv3 driver
1560uses the same stage 2 translations for the device as those used by partition
1561manager on behalf of the PE endpoint. This ensures that the peripheral device
1562has the same visibility of the physical address space as the endpoint. The
1563device node of the corresponding partition manifest (refer to `[1]`_ section 3.2
1564) must specify these additional properties for each peripheral device in the
1565system :
1566
1567- smmu-id: This field helps to identify the SMMU instance that this device is
1568 upstream of.
1569- stream-ids: List of stream IDs assigned to this device.
1570
1571.. code:: shell
1572
1573 smmuv3-testengine {
1574 base-address = <0x00000000 0x2bfe0000>;
1575 pages-count = <32>;
1576 attributes = <0x3>;
1577 smmu-id = <0>;
1578 stream-ids = <0x0 0x1>;
1579 interrupts = <0x2 0x3>, <0x4 0x5>;
1580 exclusive-access;
1581 };
1582
1583SMMUv3 driver limitations
1584-------------------------
1585
1586The primary design goal for the Hafnium SMMU driver is to support secure
1587streams.
1588
1589- Currently, the driver only supports Stage2 translations. No support for
1590 Stage1 or nested translations.
1591- Supports only AArch64 translation format.
1592- No support for features such as PCI Express (PASIDs, ATS, PRI), MSI, RAS,
1593 Fault handling, Performance Monitor Extensions, Event Handling, MPAM.
1594- No support for independent peripheral devices.
1595
1596S-EL0 Partition support
1597=======================
1598The SPMC (Hafnium) has limited capability to run S-EL0 FF-A partitions using
1599FEAT_VHE (mandatory with ARMv8.1 in non-secure state, and in secure world
1600with ARMv8.4 and FEAT_SEL2).
1601
1602S-EL0 partitions are useful for simple partitions that don't require full
1603Trusted OS functionality. It is also useful to reduce jitter and cycle
1604stealing from normal world since they are more lightweight than VMs.
1605
1606S-EL0 partitions are presented, loaded and initialized the same as S-EL1 VMs by
1607the SPMC. They are differentiated primarily by the 'exception-level' property
1608and the 'execution-ctx-count' property in the SP manifest. They are host apps
1609under the single EL2&0 Stage-1 translation regime controlled by the SPMC and
1610call into the SPMC through SVCs as opposed to HVCs and SMCs. These partitions
1611can use FF-A defined services (FFA_MEM_PERM_*) to update or change permissions
1612for memory regions.
1613
1614S-EL0 partitions are required by the FF-A specification to be UP endpoints,
1615capable of migrating, and the SPMC enforces this requirement. The SPMC allows
1616a S-EL0 partition to accept a direct message from secure world and normal world,
1617and generate direct responses to them.
1618All S-EL0 partitions must use AArch64. AArch32 S-EL0 partitions are not supported.
1619
1620Memory sharing, indirect messaging, and notifications functionality with S-EL0
1621partitions is supported.
1622
1623Interrupt handling is not supported with S-EL0 partitions and is work in
1624progress.
1625
1626References
1627==========
1628
1629.. _[1]:
1630
1631[1] `Arm Firmware Framework for Arm A-profile <https://developer.arm.com/docs/den0077/latest>`__
1632
1633.. _[2]:
1634
1635[2] `Secure Partition Manager using MM interface <https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html>`__
1636
1637.. _[3]:
1638
1639[3] `Trusted Boot Board Requirements
1640Client <https://developer.arm.com/documentation/den0006/d/>`__
1641
1642.. _[4]:
1643
1644[4] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime/aarch64/context.S#n45
1645
1646.. _[5]:
1647
1648[5] https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus.dts
1649
1650.. _[6]:
1651
1652[6] https://trustedfirmware-a.readthedocs.io/en/latest/components/ffa-manifest-binding.html
1653
1654.. _[7]:
1655
1656[7] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/plat/arm/board/fvp/fdts/fvp_spmc_manifest.dts
1657
1658.. _[8]:
1659
1660[8] https://lists.trustedfirmware.org/archives/list/tf-a@lists.trustedfirmware.org/thread/CFQFGU6H2D5GZYMUYGTGUSXIU3OYZP6U/
1661
1662.. _[9]:
1663
1664[9] https://trustedfirmware-a.readthedocs.io/en/latest/design/firmware-design.html#dynamic-configuration-during-cold-boot
1665
1666--------------
1667
1668*Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.*