blob: 40d69def7fac2152891f9cad2dd95fd6c0020fe3 [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
806FFA_VERSION
807~~~~~~~~~~~
808
809``FFA_VERSION`` requires a *requested_version* parameter from the caller.
810The returned value depends on the caller:
811
812- Hypervisor or OS kernel in NS-EL1/EL2: the SPMD returns the SPMC version
813 specified in the SPMC manifest.
814- SP: the SPMC returns its own implemented version.
815- SPMC at S-EL1/S-EL2: the SPMD returns its own implemented version.
816
817FFA_FEATURES
818~~~~~~~~~~~~
819
820FF-A features supported by the SPMC may be discovered by secure partitions at
821boot (that is prior to NWd is booted) or run-time.
822
823The SPMC calling FFA_FEATURES at secure physical FF-A instance always get
824FFA_SUCCESS from the SPMD.
825
826The request made by an Hypervisor or OS kernel is forwarded to the SPMC and
827the response relayed back to the NWd.
828
829FFA_RXTX_MAP/FFA_RXTX_UNMAP
830~~~~~~~~~~~~~~~~~~~~~~~~~~~
831
832When invoked from a secure partition FFA_RXTX_MAP maps the provided send and
833receive buffers described by their IPAs to the SP EL1&0 Stage-2 translation
834regime as secure buffers in the MMU descriptors.
835
836When invoked from the Hypervisor or OS kernel, the buffers are mapped into the
837SPMC EL2 Stage-1 translation regime and marked as NS buffers in the MMU
838descriptors. The provided addresses may be owned by a VM in the normal world,
839which is expected to receive messages from the secure world. The SPMC will in
840this case allocate internal state structures to facilitate RX buffer access
841synchronization (through FFA_RX_ACQUIRE interface), and to permit SPs to send
842messages.
843
844The FFA_RXTX_UNMAP unmaps the RX/TX pair from the translation regime of the
845caller, either it being the Hypervisor or OS kernel, as well as a secure
846partition.
847
848FFA_PARTITION_INFO_GET
849~~~~~~~~~~~~~~~~~~~~~~
850
851Partition info get call can originate:
852
853- from SP to SPMC
854- from Hypervisor or OS kernel to SPMC. The request is relayed by the SPMD.
855
856FFA_ID_GET
857~~~~~~~~~~
858
859The FF-A id space is split into a non-secure space and secure space:
860
861- FF-A ID with bit 15 clear relates to VMs.
862- FF-A ID with bit 15 set related to SPs.
863- FF-A IDs 0, 0xffff, 0x8000 are assigned respectively to the Hypervisor, SPMD
864 and SPMC.
865
866The SPMD returns:
867
868- The default zero value on invocation from the Hypervisor.
869- The ``spmc_id`` value specified in the SPMC manifest on invocation from
870 the SPMC (see `SPMC manifest`_)
871
872This convention helps the SPMC to determine the origin and destination worlds in
873an FF-A ABI invocation. In particular the SPMC shall filter unauthorized
874transactions in its world switch routine. It must not be permitted for a VM to
875use a secure FF-A ID as origin world by spoofing:
876
877- A VM-to-SP direct request/response shall set the origin world to be non-secure
878 (FF-A ID bit 15 clear) and destination world to be secure (FF-A ID bit 15
879 set).
880- Similarly, an SP-to-SP direct request/response shall set the FF-A ID bit 15
881 for both origin and destination IDs.
882
883An incoming direct message request arriving at SPMD from NWd is forwarded to
884SPMC without a specific check. The SPMC is resumed through eret and "knows" the
885message is coming from normal world in this specific code path. Thus the origin
886endpoint ID must be checked by SPMC for being a normal world ID.
887
888An SP sending a direct message request must have bit 15 set in its origin
889endpoint ID and this can be checked by the SPMC when the SP invokes the ABI.
890
891The SPMC shall reject the direct message if the claimed world in origin endpoint
892ID is not consistent:
893
894- It is either forwarded by SPMD and thus origin endpoint ID must be a "normal
895 world ID",
896- or initiated by an SP and thus origin endpoint ID must be a "secure world ID".
897
898
899FFA_MSG_SEND_DIRECT_REQ/FFA_MSG_SEND_DIRECT_RESP
900~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
901
902This is a mandatory interface for secure partitions consisting in direct request
903and responses with the following rules:
904
905- An SP can send a direct request to another SP.
906- An SP can receive a direct request from another SP.
907- An SP can send a direct response to another SP.
908- An SP cannot send a direct request to an Hypervisor or OS kernel.
909- An Hypervisor or OS kernel can send a direct request to an SP.
910- An SP can send a direct response to an Hypervisor or OS kernel.
911
912FFA_NOTIFICATION_BITMAP_CREATE/FFA_NOTIFICATION_BITMAP_DESTROY
913~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
914
915The secure partitions notifications bitmap are statically allocated by the SPMC.
916Hence, this interface is not to be issued by secure partitions.
917
918At initialization, the SPMC is not aware of VMs/partitions deployed in the
919normal world. Hence, the Hypervisor or OS kernel must use both ABIs for SPMC
920to be prepared to handle notifications for the provided VM ID.
921
922FFA_NOTIFICATION_BIND/FFA_NOTIFICATION_UNBIND
923~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
924
925Pair of interfaces to manage permissions to signal notifications. Prior to
926handling notifications, an FF-A endpoint must allow a given sender to signal a
927bitmap of notifications.
928
929If the receiver doesn't have notification support enabled in its FF-A manifest,
930it won't be able to bind notifications, hence forbidding it to receive any
931notifications.
932
933FFA_NOTIFICATION_SET/FFA_NOTIFICATION_GET
934~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
935
936FFA_NOTIFICATION_GET retrieves all pending global notifications and
937per-vCPU notifications targeted to the current vCPU.
938
939Hafnium maintains a global count of pending notifications which gets incremented
940and decremented when handling FFA_NOTIFICATION_SET and FFA_NOTIFICATION_GET
941respectively. A delayed SRI is triggered if the counter is non-zero when the
942SPMC returns to normal world.
943
944FFA_NOTIFICATION_INFO_GET
945~~~~~~~~~~~~~~~~~~~~~~~~~
946
947Hafnium maintains a global count of pending notifications whose information
948has been retrieved by this interface. The count is incremented and decremented
949when handling FFA_NOTIFICATION_INFO_GET and FFA_NOTIFICATION_GET respectively.
950It also tracks notifications whose information has been retrieved individually,
951such that it avoids duplicating returned information for subsequent calls to
952FFA_NOTIFICATION_INFO_GET. For each notification, this state information is
953reset when receiver called FFA_NOTIFICATION_GET to retrieve them.
954
955FFA_SPM_ID_GET
956~~~~~~~~~~~~~~
957
958Returns the FF-A ID allocated to an SPM component which can be one of SPMD
959or SPMC.
960
961At initialization, the SPMC queries the SPMD for the SPMC ID, using the
962FFA_ID_GET interface, and records it. The SPMC can also query the SPMD ID using
963the FFA_SPM_ID_GET interface at the secure physical FF-A instance.
964
965Secure partitions call this interface at the virtual FF-A instance, to which
966the SPMC returns the priorly retrieved SPMC ID.
967
968The Hypervisor or OS kernel can issue the FFA_SPM_ID_GET call handled by the
969SPMD, which returns the SPMC ID.
970
971FFA_SECONDARY_EP_REGISTER
972~~~~~~~~~~~~~~~~~~~~~~~~~
973
974When the SPMC boots, all secure partitions are initialized on their primary
975Execution Context.
976
977The FFA_SECONDARY_EP_REGISTER interface is to be used by a secure partition
978from its first execution context, to provide the entry point address for
979secondary execution contexts.
980
981A secondary EC is first resumed either upon invocation of PSCI_CPU_ON from
982the NWd or by invocation of FFA_RUN.
983
984FFA_RX_ACQUIRE/FFA_RX_RELEASE
985~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
986
987The RX buffers can be used to pass information to an FF-A endpoint in the
988following scenarios:
989
990 - When it was targetted by a FFA_MSG_SEND2 invokation from another endpoint.
991 - Return the result of calling ``FFA_PARTITION_INFO_GET``.
992 - In a memory share operation, as part of the ``FFA_MEM_RETRIEVE_RESP``,
993 with the memory descriptor of the shared memory.
994
995If a normal world VM is expected to exchange messages with secure world,
996its RX/TX buffer addresses are forwarded to the SPMC via FFA_RXTX_MAP ABI,
997and are from this moment owned by the SPMC.
998The hypervisor must call the FFA_RX_ACQUIRE interface before attempting
999to use the RX buffer, in any of the aforementioned scenarios. A successful
1000call to FFA_RX_ACQUIRE transfers ownership of RX buffer to hypervisor, such
1001that it can be safely used.
1002
1003The FFA_RX_RELEASE interface is used after the FF-A endpoint is done with
1004processing the data received in its RX buffer. If the RX buffer has been
1005acquired by the hypervisor, the FFA_RX_RELEASE call must be forwarded to
1006the SPMC to reestablish SPMC's RX ownership.
1007
1008An attempt from an SP to send a message to a normal world VM whose RX buffer
1009was acquired by the hypervisor fails with error code FFA_BUSY, to preserve
1010the RX buffer integrity.
1011The operation could then be conducted after FFA_RX_RELEASE.
1012
1013FFA_MSG_SEND2
1014~~~~~~~~~~~~~
1015
1016Hafnium copies a message from the sender TX buffer into receiver's RX buffer.
1017For messages from SPs to VMs, operation is only possible if the SPMC owns
1018the receiver's RX buffer.
1019
1020Both receiver and sender need to enable support for indirect messaging,
1021in their respective partition manifest. The discovery of support
1022of such feature can be done via FFA_PARTITION_INFO_GET.
1023
1024On a successful message send, Hafnium pends an RX buffer full framework
1025notification for the receiver, to inform it about a message in the RX buffer.
1026
1027The handling of framework notifications is similar to that of
1028global notifications. Binding of these is not necessary, as these are
1029reserved to be used by the hypervisor or SPMC.
1030
1031SPMC-SPMD direct requests/responses
1032-----------------------------------
1033
1034Implementation-defined FF-A IDs are allocated to the SPMC and SPMD.
1035Using those IDs in source/destination fields of a direct request/response
1036permits SPMD to SPMC communication and either way.
1037
1038- SPMC to SPMD direct request/response uses SMC conduit.
1039- SPMD to SPMC direct request/response uses ERET conduit.
1040
1041This is used in particular to convey power management messages.
1042
1043Memory Sharing
1044--------------
1045
1046Hafnium implements the following memory sharing interfaces:
1047
1048 - ``FFA_MEM_SHARE`` - for shared access between lender and borrower.
1049 - ``FFA_MEM_LEND`` - borrower to obtain exclusive access, though lender
1050 retains ownership of the memory.
1051 - ``FFA_MEM_DONATE`` - lender permanently relinquishes ownership of memory
1052 to the borrower.
1053
1054The ``FFA_MEM_RETRIEVE_REQ`` interface is for the borrower to request the
1055memory to be mapped into its address space: for S-EL1 partitions the SPM updates
1056their stage 2 translation regime; for S-EL0 partitions the SPM updates their
1057stage 1 translation regime. On a successful call, the SPMC responds back with
1058``FFA_MEM_RETRIEVE_RESP``.
1059
1060The ``FFA_MEM_RELINQUISH`` interface is for when the borrower is done with using
1061a memory region.
1062
1063The ``FFA_MEM_RECLAIM`` interface is for the owner of the memory to reestablish
1064its ownership and exclusive access to the memory shared.
1065
1066The memory transaction descriptors are transmitted via RX/TX buffers. In
1067situations where the size of the memory transaction descriptor exceeds the
1068size of the RX/TX buffers, Hafnium provides support for fragmented transmission
1069of the full transaction descriptor. The ``FFA_MEM_FRAG_RX`` and ``FFA_MEM_FRAG_TX``
1070interfaces are for receiving and transmitting the next fragment, respectively.
1071
1072If lender and borrower(s) are SPs, all memory sharing operations are supported.
1073
1074Hafnium also supports memory sharing operations between the normal world and the
1075secure world. If there is an SP involved, the SPMC allocates data to track the
1076state of the operation.
1077
1078The SPMC is also the designated allocator for the memory handle. The hypervisor
1079or OS kernel has the possibility to rely on the SPMC to maintain the state
1080of the operation, thus saving memory.
1081A lender SP can only donate NS memory to a borrower from the normal world.
1082
1083The SPMC supports the hypervisor retrieve request, as defined by the FF-A
1084v1.1 EAC0 specification, in section 16.4.3. The intent is to aid with operations
1085that the hypervisor must do for a VM retriever. For example, when handling
1086an FFA_MEM_RECLAIM, if the hypervisor relies on SPMC to keep the state
1087of the operation, the hypervisor retrieve request can be used to obtain
1088that state information, do the necessary validations, and update stage 2
1089memory translation.
1090
1091Hafnium also supports memory lend and share targetting multiple borrowers.
1092This is the case for a lender SP to multiple SPs, and for a lender VM to
1093multiple endpoints (from both secure world and normal world). If there is
1094at least one borrower VM, the hypervisor is in charge of managing its
1095stage 2 translation on a successful memory retrieve.
1096The semantics of ``FFA_MEM_DONATE`` implies ownership transmission,
1097which should target only one partition.
1098
1099The memory share interfaces are backwards compatible with memory transaction
1100descriptors from FF-A v1.0. These get translated to FF-A v1.1 descriptors for
1101Hafnium's internal processing of the operation. If the FF-A version of a
1102borrower is v1.0, Hafnium provides FF-A v1.0 compliant memory transaction
1103descriptors on memory retrieve response.
1104
1105PE MMU configuration
1106--------------------
1107
1108With secure virtualization enabled (``HCR_EL2.VM = 1``) and for S-EL1
1109partitions, two IPA spaces (secure and non-secure) are output from the
1110secure EL1&0 Stage-1 translation.
1111The EL1&0 Stage-2 translation hardware is fed by:
1112
1113- A secure IPA when the SP EL1&0 Stage-1 MMU is disabled.
1114- One of secure or non-secure IPA when the secure EL1&0 Stage-1 MMU is enabled.
1115
1116``VTCR_EL2`` and ``VSTCR_EL2`` provide configuration bits for controlling the
1117NS/S IPA translations. The following controls are set up:
1118``VSTCR_EL2.SW = 0`` , ``VSTCR_EL2.SA = 0``, ``VTCR_EL2.NSW = 0``,
1119``VTCR_EL2.NSA = 1``:
1120
1121- Stage-2 translations for the NS IPA space access the NS PA space.
1122- Stage-2 translation table walks for the NS IPA space are to the secure PA space.
1123
1124Secure and non-secure IPA regions (rooted to by ``VTTBR_EL2`` and ``VSTTBR_EL2``)
1125use the same set of Stage-2 page tables within a SP.
1126
1127The ``VTCR_EL2/VSTCR_EL2/VTTBR_EL2/VSTTBR_EL2`` virtual address space
1128configuration is made part of a vCPU context.
1129
1130For S-EL0 partitions with VHE enabled, a single secure EL2&0 Stage-1 translation
1131regime is used for both Hafnium and the partition.
1132
1133Schedule modes and SP Call chains
1134---------------------------------
1135
1136An SP execution context is said to be in SPMC scheduled mode if CPU cycles are
1137allocated to it by SPMC. Correspondingly, an SP execution context is said to be
1138in Normal world scheduled mode if CPU cycles are allocated by the normal world.
1139
1140A call chain represents all SPs in a sequence of invocations of a direct message
1141request. When execution on a PE is in the secure state, only a single call chain
1142that runs in the Normal World scheduled mode can exist. FF-A v1.1 spec allows
1143any number of call chains to run in the SPMC scheduled mode but the Hafnium
1144SPMC restricts the number of call chains in SPMC scheduled mode to only one for
1145keeping the implementation simple.
1146
1147Partition runtime models
1148------------------------
1149
1150The runtime model of an endpoint describes the transitions permitted for an
1151execution context between various states. These are the four partition runtime
1152models supported (refer to `[1]`_ section 7):
1153
1154 - RTM_FFA_RUN: runtime model presented to an execution context that is
1155 allocated CPU cycles through FFA_RUN interface.
1156 - RTM_FFA_DIR_REQ: runtime model presented to an execution context that is
1157 allocated CPU cycles through FFA_MSG_SEND_DIRECT_REQ interface.
1158 - RTM_SEC_INTERRUPT: runtime model presented to an execution context that is
1159 allocated CPU cycles by SPMC to handle a secure interrupt.
1160 - RTM_SP_INIT: runtime model presented to an execution context that is
1161 allocated CPU cycles by SPMC to initialize its state.
1162
1163If an endpoint execution context attempts to make an invalid transition or a
1164valid transition that could lead to a loop in the call chain, SPMC denies the
1165transition with the help of above runtime models.
1166
1167Interrupt management
1168--------------------
1169
1170GIC ownership
1171~~~~~~~~~~~~~
1172
1173The SPMC owns the GIC configuration. Secure and non-secure interrupts are
1174trapped at S-EL2. The SPMC manages interrupt resources and allocates interrupt
1175IDs based on SP manifests. The SPMC acknowledges physical interrupts and injects
1176virtual interrupts by setting the use of vIRQ/vFIQ bits before resuming a SP.
1177
1178Abbreviations:
1179
1180 - NS-Int: A non-secure physical interrupt. It requires a switch to the normal
1181 world to be handled if it triggers while execution is in secure world.
1182 - Other S-Int: A secure physical interrupt targeted to an SP different from
1183 the one that is currently running.
1184 - Self S-Int: A secure physical interrupt targeted to the SP that is currently
1185 running.
1186
1187Non-secure interrupt handling
1188~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1189
1190This section documents the actions supported in SPMC in response to a non-secure
1191interrupt as per the guidance provided by FF-A v1.1 EAC0 specification.
1192An SP specifies one of the following actions in its partition manifest:
1193
1194 - Non-secure interrupt is signaled.
1195 - Non-secure interrupt is signaled after a managed exit.
1196 - Non-secure interrupt is queued.
1197
1198An SP execution context in a call chain could specify a less permissive action
1199than subsequent SP execution contexts in the same call chain. The less
1200permissive action takes precedence over the more permissive actions specified
1201by the subsequent execution contexts. Please refer to FF-A v1.1 EAC0 section
12028.3.1 for further explanation.
1203
1204Secure interrupt handling
1205~~~~~~~~~~~~~~~~~~~~~~~~~
1206
1207This section documents the support implemented for secure interrupt handling in
1208SPMC as per the guidance provided by FF-A v1.1 EAC0 specification.
1209The following assumptions are made about the system configuration:
1210
1211 - In the current implementation, S-EL1 SPs are expected to use the para
1212 virtualized ABIs for interrupt management rather than accessing the virtual
1213 GIC interface.
1214 - Unless explicitly stated otherwise, this support is applicable only for
1215 S-EL1 SPs managed by SPMC.
1216 - Secure interrupts are configured as G1S or G0 interrupts.
1217 - All physical interrupts are routed to SPMC when running a secure partition
1218 execution context.
1219 - All endpoints with multiple execution contexts have their contexts pinned
1220 to corresponding CPUs. Hence, a secure virtual interrupt cannot be signaled
1221 to a target vCPU that is currently running or blocked on a different
1222 physical CPU.
1223
1224A physical secure interrupt could trigger while CPU is executing in normal world
1225or secure world.
1226The action of SPMC for a secure interrupt depends on: the state of the target
1227execution context of the SP that is responsible for handling the interrupt;
1228whether the interrupt triggered while execution was in normal world or secure
1229world.
1230
1231Secure interrupt signaling mechanisms
1232~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1233
1234Signaling refers to the mechanisms used by SPMC to indicate to the SP execution
1235context that it has a pending virtual interrupt and to further run the SP
1236execution context, such that it can handle the virtual interrupt. SPMC uses
1237either the FFA_INTERRUPT interface with ERET conduit or vIRQ signal for signaling
1238to S-EL1 SPs. When normal world execution is preempted by a secure interrupt,
1239the SPMD uses the FFA_INTERRUPT ABI with ERET conduit to signal interrupt to SPMC
1240running in S-EL2.
1241
1242+-----------+---------+---------------+---------------------------------------+
1243| SP State | Conduit | Interface and | Description |
1244| | | parameters | |
1245+-----------+---------+---------------+---------------------------------------+
1246| WAITING | ERET, | FFA_INTERRUPT,| SPMC signals to SP the ID of pending |
1247| | vIRQ | Interrupt ID | interrupt. It pends vIRQ signal and |
1248| | | | resumes execution context of SP |
1249| | | | through ERET. |
1250+-----------+---------+---------------+---------------------------------------+
1251| BLOCKED | ERET, | FFA_INTERRUPT | SPMC signals to SP that an interrupt |
1252| | vIRQ | | is pending. It pends vIRQ signal and |
1253| | | | resumes execution context of SP |
1254| | | | through ERET. |
1255+-----------+---------+---------------+---------------------------------------+
1256| PREEMPTED | vIRQ | NA | SPMC pends the vIRQ signal but does |
1257| | | | not resume execution context of SP. |
1258+-----------+---------+---------------+---------------------------------------+
1259| RUNNING | ERET, | NA | SPMC pends the vIRQ signal and resumes|
1260| | vIRQ | | execution context of SP through ERET. |
1261+-----------+---------+---------------+---------------------------------------+
1262
1263Secure interrupt completion mechanisms
1264~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1265
1266A SP signals secure interrupt handling completion to the SPMC through the
1267following mechanisms:
1268
1269 - ``FFA_MSG_WAIT`` ABI if it was in WAITING state.
1270 - ``FFA_RUN`` ABI if its was in BLOCKED state.
1271
1272This is a remnant of SPMC implementation based on the FF-A v1.0 specification.
1273In the current implementation, S-EL1 SPs use the para-virtualized HVC interface
1274implemented by SPMC to perform priority drop and interrupt deactivation (SPMC
1275configures EOImode = 0, i.e. priority drop and deactivation are done together).
1276The SPMC performs checks to deny the state transition upon invocation of
1277either FFA_MSG_WAIT or FFA_RUN interface if the SP didn't perform the
1278deactivation of the secure virtual interrupt.
1279
1280If the current SP execution context was preempted by a secure interrupt to be
1281handled by execution context of target SP, SPMC resumes current SP after signal
1282completion by target SP execution context.
1283
1284Actions for a secure interrupt triggered while execution is in normal world
1285~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1286
1287+-------------------+----------+-----------------------------------------------+
1288| State of target | Action | Description |
1289| execution context | | |
1290+-------------------+----------+-----------------------------------------------+
1291| WAITING | Signaled | This starts a new call chain in SPMC scheduled|
1292| | | mode. |
1293+-------------------+----------+-----------------------------------------------+
1294| PREEMPTED | Queued | The target execution must have been preempted |
1295| | | by a non-secure interrupt. SPMC queues the |
1296| | | secure virtual interrupt now. It is signaled |
1297| | | when the target execution context next enters |
1298| | | the RUNNING state. |
1299+-------------------+----------+-----------------------------------------------+
1300| BLOCKED, RUNNING | NA | The target execution context is blocked or |
1301| | | running on a different CPU. This is not |
1302| | | supported by current SPMC implementation and |
1303| | | execution hits panic. |
1304+-------------------+----------+-----------------------------------------------+
1305
1306If normal world execution was preempted by a secure interrupt, SPMC uses
1307FFA_NORMAL_WORLD_RESUME ABI to indicate completion of secure interrupt handling
1308and further returns execution to normal world.
1309
1310The following figure describes interrupt handling flow when a secure interrupt
1311triggers while execution is in normal world:
1312
1313.. image:: ../resources/diagrams/ffa-secure-interrupt-handling-nwd.png
1314
1315A brief description of the events:
1316
1317 - 1) Secure interrupt triggers while normal world is running.
1318 - 2) FIQ gets trapped to EL3.
1319 - 3) SPMD signals secure interrupt to SPMC at S-EL2 using FFA_INTERRUPT ABI.
1320 - 4) SPMC identifies target vCPU of SP and injects virtual interrupt (pends
1321 vIRQ).
1322 - 5) Assuming SP1 vCPU is in WAITING state, SPMC signals virtual interrupt
1323 using FFA_INTERRUPT with interrupt id as an argument and resumes the SP1
1324 vCPU using ERET in SPMC scheduled mode.
1325 - 6) Execution traps to vIRQ handler in SP1 provided that the virtual
1326 interrupt is not masked i.e., PSTATE.I = 0
1327 - 7) SP1 queries for the pending virtual interrupt id using a paravirtualized
1328 HVC call. SPMC clears the pending virtual interrupt state management
1329 and returns the pending virtual interrupt id.
1330 - 8) SP1 services the virtual interrupt and invokes the paravirtualized
1331 de-activation HVC call. SPMC de-activates the physical interrupt,
1332 clears the fields tracking the secure interrupt and resumes SP1 vCPU.
1333 - 9) SP1 performs secure interrupt completion through FFA_MSG_WAIT ABI.
1334 - 10) SPMC returns control to EL3 using FFA_NORMAL_WORLD_RESUME.
1335 - 11) EL3 resumes normal world execution.
1336
1337Actions for a secure interrupt triggered while execution is in secure world
1338~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1339
1340+-------------------+----------+------------------------------------------------+
1341| State of target | Action | Description |
1342| execution context | | |
1343+-------------------+----------+------------------------------------------------+
1344| WAITING | Signaled | This starts a new call chain in SPMC scheduled |
1345| | | mode. |
1346+-------------------+----------+------------------------------------------------+
1347| PREEMPTED by Self | Signaled | The target execution context reenters the |
1348| S-Int | | RUNNING state to handle the secure virtual |
1349| | | interrupt. |
1350+-------------------+----------+------------------------------------------------+
1351| PREEMPTED by | Queued | SPMC queues the secure virtual interrupt now. |
1352| NS-Int | | It is signaled when the target execution |
1353| | | context next enters the RUNNING state. |
1354+-------------------+----------+------------------------------------------------+
1355| BLOCKED | Signaled | Both preempted and target execution contexts |
1356| | | must have been part of the Normal world |
1357| | | scheduled call chain. Refer scenario 1 of |
1358| | | Table 8.4 in the FF-A v1.1 EAC0 spec. |
1359+-------------------+----------+------------------------------------------------+
1360| RUNNING | NA | The target execution context is running on a |
1361| | | different CPU. This scenario is not supported |
1362| | | by current SPMC implementation and execution |
1363| | | hits panic. |
1364+-------------------+----------+------------------------------------------------+
1365
1366The following figure describes interrupt handling flow when a secure interrupt
1367triggers while execution is in secure world. We assume OS kernel sends a direct
1368request message to SP1. Further, SP1 sends a direct request message to SP2. SP1
1369enters BLOCKED state and SPMC resumes SP2.
1370
1371.. image:: ../resources/diagrams/ffa-secure-interrupt-handling-swd.png
1372
1373A brief description of the events:
1374
1375 - 1) Secure interrupt triggers while SP2 is running.
1376 - 2) SP2 gets preempted and execution traps to SPMC as IRQ.
1377 - 3) SPMC finds the target vCPU of secure partition responsible for handling
1378 this secure interrupt. In this scenario, it is SP1.
1379 - 4) SPMC pends vIRQ for SP1 and signals through FFA_INTERRUPT interface.
1380 SPMC further resumes SP1 through ERET conduit. Note that SP1 remains in
1381 Normal world schedule mode.
1382 - 6) Execution traps to vIRQ handler in SP1 provided that the virtual
1383 interrupt is not masked i.e., PSTATE.I = 0
1384 - 7) SP1 queries for the pending virtual interrupt id using a paravirtualized
1385 HVC call. SPMC clears the pending virtual interrupt state management
1386 and returns the pending virtual interrupt id.
1387 - 8) SP1 services the virtual interrupt and invokes the paravirtualized
1388 de-activation HVC call. SPMC de-activates the physical interrupt and
1389 clears the fields tracking the secure interrupt and resumes SP1 vCPU.
1390 - 9) Since SP1 direct request completed with FFA_INTERRUPT, it resumes the
1391 direct request to SP2 by invoking FFA_RUN.
1392 - 9) SPMC resumes the pre-empted vCPU of SP2.
1393
1394EL3 interrupt handling
1395~~~~~~~~~~~~~~~~~~~~~~
1396
1397In GICv3 based systems, EL3 interrupts are configured as Group0 secure
1398interrupts. Execution traps to SPMC when a Group0 interrupt triggers while an
1399SP is running. Further, SPMC running at S-EL2 uses FFA_EL3_INTR_HANDLE ABI to
1400request EL3 platform firmware to handle a pending Group0 interrupt.
1401Similarly, SPMD registers a handler with interrupt management framework to
1402delegate handling of Group0 interrupt to the platform if the interrupt triggers
1403in normal world.
1404
1405 - Platform hook
1406
1407 - plat_spmd_handle_group0_interrupt
1408
1409 SPMD provides platform hook to handle Group0 secure interrupts. In the
1410 current design, SPMD expects the platform not to delegate handling to the
1411 NWd (such as through SDEI) while processing Group0 interrupts.
1412
1413Power management
1414----------------
1415
1416In platforms with or without secure virtualization:
1417
1418- The NWd owns the platform PM policy.
1419- The Hypervisor or OS kernel is the component initiating PSCI service calls.
1420- The EL3 PSCI library is in charge of the PM coordination and control
1421 (eventually writing to platform registers).
1422- While coordinating PM events, the PSCI library calls backs into the Secure
1423 Payload Dispatcher for events the latter has statically registered to.
1424
1425When using the SPMD as a Secure Payload Dispatcher:
1426
1427- A power management event is relayed through the SPD hook to the SPMC.
1428- In the current implementation only cpu on (svc_on_finish) and cpu off
1429 (svc_off) hooks are registered.
1430- The behavior for the cpu on event is described in `Secondary cores boot-up`_.
1431 The SPMC is entered through its secondary physical core entry point.
1432- The cpu off event occurs when the NWd calls PSCI_CPU_OFF. The PM event is
1433 signaled to the SPMC through a power management framework message.
1434 It consists in a SPMD-to-SPMC direct request/response (`SPMC-SPMD direct
1435 requests/responses`_) conveying the event details and SPMC response.
1436 The SPMD performs a synchronous entry into the SPMC. The SPMC is entered and
1437 updates its internal state to reflect the physical core is being turned off.
1438 In the current implementation no SP is resumed as a consequence. This behavior
1439 ensures a minimal support for CPU hotplug e.g. when initiated by the NWd linux
1440 userspace.
1441
1442Arm architecture extensions for security hardening
1443==================================================
1444
1445Hafnium supports the following architecture extensions for security hardening:
1446
1447- Pointer authentication (FEAT_PAuth): the extension permits detection of forged
1448 pointers used by ROP type of attacks through the signing of the pointer
1449 value. Hafnium is built with the compiler branch protection option to permit
1450 generation of a pointer authentication code for return addresses (pointer
1451 authentication for instructions). The APIA key is used while Hafnium runs.
1452 A random key is generated at boot time and restored upon entry into Hafnium
1453 at run-time. APIA and other keys (APIB, APDA, APDB, APGA) are saved/restored
1454 in vCPU contexts permitting to enable pointer authentication in VMs/SPs.
1455- Branch Target Identification (FEAT_BTI): the extension permits detection of
1456 unexpected indirect branches used by JOP type of attacks. Hafnium is built
1457 with the compiler branch protection option, inserting land pads at function
1458 prologues that are reached by indirect branch instructions (BR/BLR).
1459 Hafnium code pages are marked as guarded in the EL2 Stage-1 MMU descriptors
1460 such that an indirect branch must always target a landpad. A fault is
1461 triggered otherwise. VMs/SPs can (independently) mark their code pages as
1462 guarded in the EL1&0 Stage-1 translation regime.
1463- Memory Tagging Extension (FEAT_MTE): the option permits detection of out of
1464 bound memory array accesses or re-use of an already freed memory region.
1465 Hafnium enables the compiler option permitting to leverage MTE stack tagging
1466 applied to core stacks. Core stacks are marked as normal tagged memory in the
1467 EL2 Stage-1 translation regime. A synchronous data abort is generated upon tag
1468 check failure on load/stores. A random seed is generated at boot time and
1469 restored upon entry into Hafnium. MTE system registers are saved/restored in
1470 vCPU contexts permitting MTE usage from VMs/SPs.
1471
1472SMMUv3 support in Hafnium
1473=========================
1474
1475An SMMU is analogous to an MMU in a CPU. It performs address translations for
1476Direct Memory Access (DMA) requests from system I/O devices.
1477The responsibilities of an SMMU include:
1478
1479- Translation: Incoming DMA requests are translated from bus address space to
1480 system physical address space using translation tables compliant to
1481 Armv8/Armv7 VMSA descriptor format.
1482- Protection: An I/O device can be prohibited from read, write access to a
1483 memory region or allowed.
1484- Isolation: Traffic from each individial device can be independently managed.
1485 The devices are differentiated from each other using unique translation
1486 tables.
1487
1488The following diagram illustrates a typical SMMU IP integrated in a SoC with
1489several I/O devices along with Interconnect and Memory system.
1490
1491.. image:: ../resources/diagrams/MMU-600.png
1492
1493SMMU has several versions including SMMUv1, SMMUv2 and SMMUv3. Hafnium provides
1494support for SMMUv3 driver in both normal and secure world. A brief introduction
1495of SMMUv3 functionality and the corresponding software support in Hafnium is
1496provided here.
1497
1498SMMUv3 features
1499---------------
1500
1501- SMMUv3 provides Stage1, Stage2 translation as well as nested (Stage1 + Stage2)
1502 translation support. It can either bypass or abort incoming translations as
1503 well.
1504- Traffic (memory transactions) from each upstream I/O peripheral device,
1505 referred to as Stream, can be independently managed using a combination of
1506 several memory based configuration structures. This allows the SMMUv3 to
1507 support a large number of streams with each stream assigned to a unique
1508 translation context.
1509- Support for Armv8.1 VMSA where the SMMU shares the translation tables with
1510 a Processing Element. AArch32(LPAE) and AArch64 translation table format
1511 are supported by SMMUv3.
1512- SMMUv3 offers non-secure stream support with secure stream support being
1513 optional. Logically, SMMUv3 behaves as if there is an indepdendent SMMU
1514 instance for secure and non-secure stream support.
1515- It also supports sub-streams to differentiate traffic from a virtualized
1516 peripheral associated with a VM/SP.
1517- Additionally, SMMUv3.2 provides support for PEs implementing Armv8.4-A
1518 extensions. Consequently, SPM depends on Secure EL2 support in SMMUv3.2
1519 for providing Secure Stage2 translation support to upstream peripheral
1520 devices.
1521
1522SMMUv3 Programming Interfaces
1523-----------------------------
1524
1525SMMUv3 has three software interfaces that are used by the Hafnium driver to
1526configure the behaviour of SMMUv3 and manage the streams.
1527
1528- Memory based data strutures that provide unique translation context for
1529 each stream.
1530- Memory based circular buffers for command queue and event queue.
1531- A large number of SMMU configuration registers that are memory mapped during
1532 boot time by Hafnium driver. Except a few registers, all configuration
1533 registers have independent secure and non-secure versions to configure the
1534 behaviour of SMMUv3 for translation of secure and non-secure streams
1535 respectively.
1536
1537Peripheral device manifest
1538--------------------------
1539
1540Currently, SMMUv3 driver in Hafnium only supports dependent peripheral devices.
1541These devices are dependent on PE endpoint to initiate and receive memory
1542management transactions on their behalf. The acccess to the MMIO regions of
1543any such device is assigned to the endpoint during boot. Moreover, SMMUv3 driver
1544uses the same stage 2 translations for the device as those used by partition
1545manager on behalf of the PE endpoint. This ensures that the peripheral device
1546has the same visibility of the physical address space as the endpoint. The
1547device node of the corresponding partition manifest (refer to `[1]`_ section 3.2
1548) must specify these additional properties for each peripheral device in the
1549system :
1550
1551- smmu-id: This field helps to identify the SMMU instance that this device is
1552 upstream of.
1553- stream-ids: List of stream IDs assigned to this device.
1554
1555.. code:: shell
1556
1557 smmuv3-testengine {
1558 base-address = <0x00000000 0x2bfe0000>;
1559 pages-count = <32>;
1560 attributes = <0x3>;
1561 smmu-id = <0>;
1562 stream-ids = <0x0 0x1>;
1563 interrupts = <0x2 0x3>, <0x4 0x5>;
1564 exclusive-access;
1565 };
1566
1567SMMUv3 driver limitations
1568-------------------------
1569
1570The primary design goal for the Hafnium SMMU driver is to support secure
1571streams.
1572
1573- Currently, the driver only supports Stage2 translations. No support for
1574 Stage1 or nested translations.
1575- Supports only AArch64 translation format.
1576- No support for features such as PCI Express (PASIDs, ATS, PRI), MSI, RAS,
1577 Fault handling, Performance Monitor Extensions, Event Handling, MPAM.
1578- No support for independent peripheral devices.
1579
1580S-EL0 Partition support
1581=======================
1582The SPMC (Hafnium) has limited capability to run S-EL0 FF-A partitions using
1583FEAT_VHE (mandatory with ARMv8.1 in non-secure state, and in secure world
1584with ARMv8.4 and FEAT_SEL2).
1585
1586S-EL0 partitions are useful for simple partitions that don't require full
1587Trusted OS functionality. It is also useful to reduce jitter and cycle
1588stealing from normal world since they are more lightweight than VMs.
1589
1590S-EL0 partitions are presented, loaded and initialized the same as S-EL1 VMs by
1591the SPMC. They are differentiated primarily by the 'exception-level' property
1592and the 'execution-ctx-count' property in the SP manifest. They are host apps
1593under the single EL2&0 Stage-1 translation regime controlled by the SPMC and
1594call into the SPMC through SVCs as opposed to HVCs and SMCs. These partitions
1595can use FF-A defined services (FFA_MEM_PERM_*) to update or change permissions
1596for memory regions.
1597
1598S-EL0 partitions are required by the FF-A specification to be UP endpoints,
1599capable of migrating, and the SPMC enforces this requirement. The SPMC allows
1600a S-EL0 partition to accept a direct message from secure world and normal world,
1601and generate direct responses to them.
1602All S-EL0 partitions must use AArch64. AArch32 S-EL0 partitions are not supported.
1603
1604Memory sharing, indirect messaging, and notifications functionality with S-EL0
1605partitions is supported.
1606
1607Interrupt handling is not supported with S-EL0 partitions and is work in
1608progress.
1609
1610References
1611==========
1612
1613.. _[1]:
1614
1615[1] `Arm Firmware Framework for Arm A-profile <https://developer.arm.com/docs/den0077/latest>`__
1616
1617.. _[2]:
1618
1619[2] `Secure Partition Manager using MM interface <https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html>`__
1620
1621.. _[3]:
1622
1623[3] `Trusted Boot Board Requirements
1624Client <https://developer.arm.com/documentation/den0006/d/>`__
1625
1626.. _[4]:
1627
1628[4] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/lib/el3_runtime/aarch64/context.S#n45
1629
1630.. _[5]:
1631
1632[5] https://git.trustedfirmware.org/TF-A/tf-a-tests.git/tree/spm/cactus/plat/arm/fvp/fdts/cactus.dts
1633
1634.. _[6]:
1635
1636[6] https://trustedfirmware-a.readthedocs.io/en/latest/components/ffa-manifest-binding.html
1637
1638.. _[7]:
1639
1640[7] https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/plat/arm/board/fvp/fdts/fvp_spmc_manifest.dts
1641
1642.. _[8]:
1643
1644[8] https://lists.trustedfirmware.org/archives/list/tf-a@lists.trustedfirmware.org/thread/CFQFGU6H2D5GZYMUYGTGUSXIU3OYZP6U/
1645
1646.. _[9]:
1647
1648[9] https://trustedfirmware-a.readthedocs.io/en/latest/design/firmware-design.html#dynamic-configuration-during-cold-boot
1649
1650--------------
1651
1652*Copyright (c) 2020-2023, Arm Limited and Contributors. All rights reserved.*