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