xref: /rk3399_ARM-atf/docs/components/realm-management-extension.rst (revision 7446c266c91bc28c87fca634df57bdcf15b32a5b)
13cfa3497SZelalem Aweke
23cfa3497SZelalem AwekeRealm Management Extension (RME)
33cfa3497SZelalem Aweke====================================
43cfa3497SZelalem Aweke
53cfa3497SZelalem AwekeFEAT_RME (or RME for short) is an Armv9-A extension and is one component of the
63cfa3497SZelalem Aweke`Arm Confidential Compute Architecture (Arm CCA)`_. TF-A supports RME starting
7*7446c266SZelalem Awekefrom version 2.6. This chapter discusses the changes to TF-A to support RME and
8*7446c266SZelalem Awekeprovides instructions on how to build and run TF-A with RME.
9*7446c266SZelalem Aweke
10*7446c266SZelalem AwekeRME support in TF-A
11*7446c266SZelalem Aweke---------------------
12*7446c266SZelalem Aweke
13*7446c266SZelalem AwekeThe following diagram shows an Arm CCA software architecture with TF-A as the
14*7446c266SZelalem AwekeEL3 firmware. In the Arm CCA architecture there are two additional security
15*7446c266SZelalem Awekestates and address spaces: ``Root`` and ``Realm``. TF-A firmware runs in the
16*7446c266SZelalem AwekeRoot world. In the realm world, a Realm Management Monitor firmware (RMM)
17*7446c266SZelalem Awekemanages the execution of Realm VMs and their interaction with the hypervisor.
18*7446c266SZelalem Aweke
19*7446c266SZelalem Aweke.. image:: ../resources/diagrams/arm-cca-software-arch.png
20*7446c266SZelalem Aweke
21*7446c266SZelalem AwekeRME is the hardware extension to support Arm CCA. To support RME, various
22*7446c266SZelalem Awekechanges have been introduced to TF-A. We discuss those changes below.
23*7446c266SZelalem Aweke
24*7446c266SZelalem AwekeChanges to translation tables library
25*7446c266SZelalem Aweke***************************************
26*7446c266SZelalem AwekeRME adds Root and Realm Physical address spaces. To support this, two new
27*7446c266SZelalem Awekememory type macros, ``MT_ROOT`` and ``MT_REALM``, have been added to the
28*7446c266SZelalem Aweke:ref:`Translation (XLAT) Tables Library`. These macros are used to configure
29*7446c266SZelalem Awekememory regions as Root or Realm respectively.
30*7446c266SZelalem Aweke
31*7446c266SZelalem Aweke.. note::
32*7446c266SZelalem Aweke
33*7446c266SZelalem Aweke Only version 2 of the translation tables library supports the new memory
34*7446c266SZelalem Aweke types.
35*7446c266SZelalem Aweke
36*7446c266SZelalem AwekeChanges to context management
37*7446c266SZelalem Aweke*******************************
38*7446c266SZelalem AwekeA new CPU context for the Realm world has been added. The existing
39*7446c266SZelalem Aweke:ref:`CPU context management API<PSCI Library Integration guide for Armv8-A
40*7446c266SZelalem AwekeAArch32 systems>` can be used to manage Realm context.
41*7446c266SZelalem Aweke
42*7446c266SZelalem AwekeBoot flow changes
43*7446c266SZelalem Aweke*******************
44*7446c266SZelalem AwekeIn a typical TF-A boot flow, BL2 runs at Secure-EL1. However when RME is
45*7446c266SZelalem Awekeenabled, TF-A runs in the Root world at EL3. Therefore, the boot flow is
46*7446c266SZelalem Awekemodified to run BL2 at EL3 when RME is enabled. In addition to this, a
47*7446c266SZelalem AwekeRealm-world firmware (RMM) is loaded by BL2 in the Realm physical address
48*7446c266SZelalem Awekespace.
49*7446c266SZelalem Aweke
50*7446c266SZelalem AwekeThe boot flow when RME is enabled looks like the following:
51*7446c266SZelalem Aweke
52*7446c266SZelalem Aweke1. BL1 loads and executes BL2 at EL3
53*7446c266SZelalem Aweke2. BL2 loads images including RMM
54*7446c266SZelalem Aweke3. BL2 transfers control to BL31
55*7446c266SZelalem Aweke4. BL31 initializes SPM (if SPM is enabled)
56*7446c266SZelalem Aweke5. BL31 initializes RMM
57*7446c266SZelalem Aweke6. BL31 transfers control to Normal-world software
58*7446c266SZelalem Aweke
59*7446c266SZelalem AwekeGranule Protection Tables (GPT) library
60*7446c266SZelalem Aweke*****************************************
61*7446c266SZelalem AwekeIsolation between the four physical address spaces is enforced by a process
62*7446c266SZelalem Awekecalled Granule Protection Check (GPC) performed by the MMU downstream any
63*7446c266SZelalem Awekeaddress translation. GPC makes use of Granule Protection Table (GPT) in the
64*7446c266SZelalem AwekeRoot world that describes the physical address space assignment of every
65*7446c266SZelalem Awekepage (granule). A GPT library that provides APIs to initialize GPTs and to
66*7446c266SZelalem Aweketransition granules between different physical address spaces has been added.
67*7446c266SZelalem AwekeMore information about the GPT library can be found in the
68*7446c266SZelalem Aweke:ref:`Granule Protection Tables Library` chapter.
69*7446c266SZelalem Aweke
70*7446c266SZelalem AwekeRMM Dispatcher (RMMD)
71*7446c266SZelalem Aweke************************
72*7446c266SZelalem AwekeRMMD is a new standard runtime service that handles the switch to the Realm
73*7446c266SZelalem Awekeworld. It initializes the RMM and handles Realm Management Interface (RMI)
74*7446c266SZelalem AwekeSMC calls from Non-secure and Realm worlds.
75*7446c266SZelalem Aweke
76*7446c266SZelalem AwekeTest Realm Payload (TRP)
77*7446c266SZelalem Aweke*************************
78*7446c266SZelalem AwekeTRP is a small test payload that runs at R-EL2 and implements a subset of
79*7446c266SZelalem Awekethe Realm Management Interface (RMI) commands to primarily test EL3 firmware
80*7446c266SZelalem Awekeand the interface between R-EL2 and EL3. When building TF-A with RME enabled,
81*7446c266SZelalem Awekeif a path to an RMM image is not provided, TF-A builds the TRP by default
82*7446c266SZelalem Awekeand uses it as RMM image.
833cfa3497SZelalem Aweke
843cfa3497SZelalem AwekeBuilding and running TF-A with RME
853cfa3497SZelalem Aweke------------------------------------
863cfa3497SZelalem Aweke
873cfa3497SZelalem AwekeThis section describes how you can build and run TF-A with RME enabled.
883cfa3497SZelalem AwekeWe assume you have all the :ref:`Prerequisites` to build TF-A.
893cfa3497SZelalem Aweke
903cfa3497SZelalem AwekeTo enable RME, you need to set the ENABLE_RME build flag when building
913cfa3497SZelalem AwekeTF-A. Currently, this feature is only supported for the FVP platform.
923cfa3497SZelalem Aweke
933cfa3497SZelalem AwekeThe following instructions show you how to build and run TF-A with RME
943cfa3497SZelalem Awekefor two scenarios: TF-A with TF-A Tests, and four-world execution with
953cfa3497SZelalem AwekeHafnium and TF-A Tests. The instructions assume you have already obtained
963cfa3497SZelalem AwekeTF-A. You can use the following command to clone TF-A.
973cfa3497SZelalem Aweke
983cfa3497SZelalem Aweke.. code:: shell
993cfa3497SZelalem Aweke
1003cfa3497SZelalem Aweke git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
1013cfa3497SZelalem Aweke
102*7446c266SZelalem AwekeTo run the tests, you need an FVP model. Please use the :ref:`latest version
103*7446c266SZelalem Aweke<Arm Fixed Virtual Platforms (FVP)>` of *FVP_Base_RevC-2xAEMvA* model.
1043cfa3497SZelalem Aweke
1053cfa3497SZelalem Aweke.. note::
1063cfa3497SZelalem Aweke
1073cfa3497SZelalem Aweke ENABLE_RME build option is currently experimental.
1083cfa3497SZelalem Aweke
1093cfa3497SZelalem AwekeBuilding TF-A with TF-A Tests
1103cfa3497SZelalem Aweke********************************************
1113cfa3497SZelalem AwekeUse the following instructions to build TF-A with `TF-A Tests`_ as the
1123cfa3497SZelalem Awekenon-secure payload (BL33).
1133cfa3497SZelalem Aweke
1143cfa3497SZelalem Aweke**1. Obtain and build TF-A Tests**
1153cfa3497SZelalem Aweke
1163cfa3497SZelalem Aweke.. code:: shell
1173cfa3497SZelalem Aweke
1183cfa3497SZelalem Aweke git clone https://git.trustedfirmware.org/TF-A/tf-a-tests.git
1193cfa3497SZelalem Aweke cd tf-a-tests
1203cfa3497SZelalem Aweke make CROSS_COMPILE=aarch64-none-elf- PLAT=fvp DEBUG=1
1213cfa3497SZelalem Aweke
1223cfa3497SZelalem AwekeThis produces a TF-A Tests binary (*tftf.bin*) in the *build/fvp/debug* directory.
1233cfa3497SZelalem Aweke
1243cfa3497SZelalem Aweke**2. Build TF-A**
1253cfa3497SZelalem Aweke
1263cfa3497SZelalem Aweke.. code:: shell
1273cfa3497SZelalem Aweke
1283cfa3497SZelalem Aweke cd trusted-firmware-a
1293cfa3497SZelalem Aweke make CROSS_COMPILE=aarch64-none-elf- \
1303cfa3497SZelalem Aweke PLAT=fvp \
1313cfa3497SZelalem Aweke ENABLE_RME=1 \
1323cfa3497SZelalem Aweke FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
1333cfa3497SZelalem Aweke DEBUG=1 \
1343cfa3497SZelalem Aweke BL33=<path/to/tftf.bin> \
1353cfa3497SZelalem Aweke all fip
1363cfa3497SZelalem Aweke
1373cfa3497SZelalem AwekeThis produces *bl1.bin* and *fip.bin* binaries in the *build/fvp/debug* directory.
138*7446c266SZelalem AwekeThe above command also builds TRP. The TRP binary is packaged in *fip.bin*.
1393cfa3497SZelalem Aweke
1403cfa3497SZelalem AwekeFour-world execution with Hafnium and TF-A Tests
1413cfa3497SZelalem Aweke****************************************************
1423cfa3497SZelalem AwekeFour-world execution involves software components at each security state: root,
1433cfa3497SZelalem Awekesecure, realm and non-secure. This section describes how to build TF-A
1443cfa3497SZelalem Awekewith four-world support. We use TF-A as the root firmware, `Hafnium`_ as the
1453cfa3497SZelalem Awekesecure component, TRP as the realm-world firmware and TF-A Tests as the
1463cfa3497SZelalem Awekenon-secure payload.
1473cfa3497SZelalem Aweke
1483cfa3497SZelalem AwekeBefore building TF-A, you first need to build the other software components.
1493cfa3497SZelalem AwekeYou can find instructions on how to get and build TF-A Tests above.
1503cfa3497SZelalem Aweke
1513cfa3497SZelalem Aweke**1. Obtain and build Hafnium**
1523cfa3497SZelalem Aweke
1533cfa3497SZelalem Aweke.. code:: shell
1543cfa3497SZelalem Aweke
1553cfa3497SZelalem Aweke git clone --recurse-submodules https://git.trustedfirmware.org/hafnium/hafnium.git
1563cfa3497SZelalem Aweke cd hafnium
1573cfa3497SZelalem Aweke make PROJECT=reference
1583cfa3497SZelalem Aweke
1593cfa3497SZelalem AwekeThe Hafnium binary should be located at
1603cfa3497SZelalem Aweke*out/reference/secure_aem_v8a_fvp_clang/hafnium.bin*
1613cfa3497SZelalem Aweke
1623cfa3497SZelalem Aweke**2. Build TF-A**
1633cfa3497SZelalem Aweke
1643cfa3497SZelalem AwekeBuild TF-A with RME as well as SPM enabled.
1653cfa3497SZelalem Aweke
1663cfa3497SZelalem Aweke.. code:: shell
1673cfa3497SZelalem Aweke
1683cfa3497SZelalem Aweke make CROSS_COMPILE=aarch64-none-elf- \
1693cfa3497SZelalem Aweke PLAT=fvp \
1703cfa3497SZelalem Aweke ENABLE_RME=1 \
1713cfa3497SZelalem Aweke FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
1723cfa3497SZelalem Aweke SPD=spmd \
1733cfa3497SZelalem Aweke SPMD_SPM_AT_SEL2=1 \
1743cfa3497SZelalem Aweke BRANCH_PROTECTION=1 \
1753cfa3497SZelalem Aweke CTX_INCLUDE_PAUTH_REGS=1 \
1763cfa3497SZelalem Aweke DEBUG=1 \
1773cfa3497SZelalem Aweke SP_LAYOUT_FILE=<path/to/tf-a-tests>/build/fvp/debug/sp_layout.json> \
1783cfa3497SZelalem Aweke BL32=<path/to/hafnium.bin> \
1793cfa3497SZelalem Aweke BL33=<path/to/tftf.bin> \
1803cfa3497SZelalem Aweke all fip
1813cfa3497SZelalem Aweke
1823cfa3497SZelalem AwekeRunning the tests
1833cfa3497SZelalem Aweke*********************
1843cfa3497SZelalem AwekeUse the following command to run the tests on FVP. TF-A Tests should boot
1853cfa3497SZelalem Awekeand run the default tests including RME tests.
1863cfa3497SZelalem Aweke
1873cfa3497SZelalem Aweke.. code:: shell
1883cfa3497SZelalem Aweke
1893cfa3497SZelalem Aweke FVP_Base_RevC-2xAEMvA \
1903cfa3497SZelalem Aweke -C bp.flashloader0.fname=<path/to/fip.bin> \
1913cfa3497SZelalem Aweke -C bp.secureflashloader.fname=<path/to/bl1.bin> \
1923cfa3497SZelalem Aweke -C bp.refcounter.non_arch_start_at_default=1 \
1933cfa3497SZelalem Aweke -C bp.refcounter.use_real_time=0 \
1943cfa3497SZelalem Aweke -C bp.ve_sysregs.exit_on_shutdown=1 \
1953cfa3497SZelalem Aweke -C cache_state_modelled=1 \
1963cfa3497SZelalem Aweke -C cluster0.NUM_CORES=4 \
1973cfa3497SZelalem Aweke -C cluster0.PA_SIZE=48 \
1983cfa3497SZelalem Aweke -C cluster0.ecv_support_level=2 \
1993cfa3497SZelalem Aweke -C cluster0.gicv3.cpuintf-mmap-access-level=2 \
2003cfa3497SZelalem Aweke -C cluster0.gicv3.without-DS-support=1 \
2013cfa3497SZelalem Aweke -C cluster0.gicv4.mask-virtual-interrupt=1 \
2023cfa3497SZelalem Aweke -C cluster0.has_arm_v8-6=1 \
2033cfa3497SZelalem Aweke -C cluster0.has_branch_target_exception=1 \
2043cfa3497SZelalem Aweke -C cluster0.has_rme=1 \
2053cfa3497SZelalem Aweke -C cluster0.has_rndr=1 \
2063cfa3497SZelalem Aweke -C cluster0.has_amu=1 \
2073cfa3497SZelalem Aweke -C cluster0.has_v8_7_pmu_extension=2 \
2083cfa3497SZelalem Aweke -C cluster0.max_32bit_el=-1 \
2093cfa3497SZelalem Aweke -C cluster0.restriction_on_speculative_execution=2 \
2103cfa3497SZelalem Aweke -C cluster0.restriction_on_speculative_execution_aarch32=2 \
2113cfa3497SZelalem Aweke -C cluster1.NUM_CORES=4 \
2123cfa3497SZelalem Aweke -C cluster1.PA_SIZE=48 \
2133cfa3497SZelalem Aweke -C cluster1.ecv_support_level=2 \
2143cfa3497SZelalem Aweke -C cluster1.gicv3.cpuintf-mmap-access-level=2 \
2153cfa3497SZelalem Aweke -C cluster1.gicv3.without-DS-support=1 \
2163cfa3497SZelalem Aweke -C cluster1.gicv4.mask-virtual-interrupt=1 \
2173cfa3497SZelalem Aweke -C cluster1.has_arm_v8-6=1 \
2183cfa3497SZelalem Aweke -C cluster1.has_branch_target_exception=1 \
2193cfa3497SZelalem Aweke -C cluster1.has_rme=1 \
2203cfa3497SZelalem Aweke -C cluster1.has_rndr=1 \
2213cfa3497SZelalem Aweke -C cluster1.has_amu=1 \
2223cfa3497SZelalem Aweke -C cluster1.has_v8_7_pmu_extension=2 \
2233cfa3497SZelalem Aweke -C cluster1.max_32bit_el=-1 \
2243cfa3497SZelalem Aweke -C cluster1.restriction_on_speculative_execution=2 \
2253cfa3497SZelalem Aweke -C cluster1.restriction_on_speculative_execution_aarch32=2 \
2263cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_AIDR=2 \
2273cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B \
2283cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002 \
2293cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714 \
2303cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0475 \
2313cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002 \
2323cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_S_IDR2=0 \
2333cfa3497SZelalem Aweke -C pci.pci_smmuv3.mmu.SMMU_S_IDR3=0 \
2343cfa3497SZelalem Aweke -C bp.pl011_uart0.out_file=uart0.log \
2353cfa3497SZelalem Aweke -C bp.pl011_uart1.out_file=uart1.log \
2363cfa3497SZelalem Aweke -C bp.pl011_uart2.out_file=uart2.log \
2373cfa3497SZelalem Aweke -C pctl.startup=0.0.0.0 \
2383cfa3497SZelalem Aweke -Q 1000 \
2393cfa3497SZelalem Aweke "$@"
2403cfa3497SZelalem Aweke
2413cfa3497SZelalem AwekeThe bottom of the output from *uart0* should look something like the following.
2423cfa3497SZelalem Aweke
2433cfa3497SZelalem Aweke.. code-block:: shell
2443cfa3497SZelalem Aweke
2453cfa3497SZelalem Aweke ...
2463cfa3497SZelalem Aweke
2473cfa3497SZelalem Aweke > Test suite 'FF-A Interrupt'
2483cfa3497SZelalem Aweke                                                                Passed
2493cfa3497SZelalem Aweke > Test suite 'SMMUv3 tests'
2503cfa3497SZelalem Aweke                                                                Passed
2513cfa3497SZelalem Aweke > Test suite 'PMU Leakage'
2523cfa3497SZelalem Aweke                                                                Passed
2533cfa3497SZelalem Aweke > Test suite 'DebugFS'
2543cfa3497SZelalem Aweke                                                                Passed
2553cfa3497SZelalem Aweke > Test suite 'Realm payload tests'
2563cfa3497SZelalem Aweke                                                                Passed
2573cfa3497SZelalem Aweke ...
2583cfa3497SZelalem Aweke
2593cfa3497SZelalem Aweke
2603cfa3497SZelalem Aweke.. _Arm Confidential Compute Architecture (Arm CCA): https://www.arm.com/why-arm/architecture/security-features/arm-confidential-compute-architecture
2613cfa3497SZelalem Aweke.. _Arm Architecture Models website: https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms/arm-ecosystem-models
2623cfa3497SZelalem Aweke.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io/en/latest
2633cfa3497SZelalem Aweke.. _Hafnium: https://www.trustedfirmware.org/projects/hafnium
264