xref: /rk3399_ARM-atf/docs/components/realm-management-extension.rst (revision e0afd1471c49669c0760fd92d3bd6b012479eb1e)
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
77446c266SZelalem Awekefrom version 2.6. This chapter discusses the changes to TF-A to support RME and
87446c266SZelalem Awekeprovides instructions on how to build and run TF-A with RME.
97446c266SZelalem Aweke
107446c266SZelalem AwekeRME support in TF-A
117446c266SZelalem Aweke---------------------
127446c266SZelalem Aweke
137446c266SZelalem AwekeThe following diagram shows an Arm CCA software architecture with TF-A as the
147446c266SZelalem AwekeEL3 firmware. In the Arm CCA architecture there are two additional security
157446c266SZelalem Awekestates and address spaces: ``Root`` and ``Realm``. TF-A firmware runs in the
16d9c976b0SSoby MathewRoot world. In the realm world, a Realm Management Monitor firmware (`RMM`_)
177446c266SZelalem Awekemanages the execution of Realm VMs and their interaction with the hypervisor.
187446c266SZelalem Aweke
197446c266SZelalem Aweke.. image:: ../resources/diagrams/arm-cca-software-arch.png
207446c266SZelalem Aweke
217446c266SZelalem AwekeRME is the hardware extension to support Arm CCA. To support RME, various
227446c266SZelalem Awekechanges have been introduced to TF-A. We discuss those changes below.
237446c266SZelalem Aweke
247446c266SZelalem AwekeChanges to translation tables library
257446c266SZelalem Aweke***************************************
267446c266SZelalem AwekeRME adds Root and Realm Physical address spaces. To support this, two new
277446c266SZelalem Awekememory type macros, ``MT_ROOT`` and ``MT_REALM``, have been added to the
287446c266SZelalem Aweke:ref:`Translation (XLAT) Tables Library`. These macros are used to configure
297446c266SZelalem Awekememory regions as Root or Realm respectively.
307446c266SZelalem Aweke
317446c266SZelalem Aweke.. note::
327446c266SZelalem Aweke
337446c266SZelalem Aweke Only version 2 of the translation tables library supports the new memory
347446c266SZelalem Aweke types.
357446c266SZelalem Aweke
367446c266SZelalem AwekeChanges to context management
377446c266SZelalem Aweke*******************************
387446c266SZelalem AwekeA new CPU context for the Realm world has been added. The existing
397446c266SZelalem Aweke:ref:`CPU context management API<PSCI Library Integration guide for Armv8-A
407446c266SZelalem AwekeAArch32 systems>` can be used to manage Realm context.
417446c266SZelalem Aweke
427446c266SZelalem AwekeBoot flow changes
437446c266SZelalem Aweke*******************
447446c266SZelalem AwekeIn a typical TF-A boot flow, BL2 runs at Secure-EL1. However when RME is
457446c266SZelalem Awekeenabled, TF-A runs in the Root world at EL3. Therefore, the boot flow is
467446c266SZelalem Awekemodified to run BL2 at EL3 when RME is enabled. In addition to this, a
47d9c976b0SSoby MathewRealm-world firmware (`RMM`_) is loaded by BL2 in the Realm physical address
487446c266SZelalem Awekespace.
497446c266SZelalem Aweke
507446c266SZelalem AwekeThe boot flow when RME is enabled looks like the following:
517446c266SZelalem Aweke
527446c266SZelalem Aweke1. BL1 loads and executes BL2 at EL3
537446c266SZelalem Aweke2. BL2 loads images including RMM
547446c266SZelalem Aweke3. BL2 transfers control to BL31
557446c266SZelalem Aweke4. BL31 initializes SPM (if SPM is enabled)
567446c266SZelalem Aweke5. BL31 initializes RMM
577446c266SZelalem Aweke6. BL31 transfers control to Normal-world software
587446c266SZelalem Aweke
597446c266SZelalem AwekeGranule Protection Tables (GPT) library
607446c266SZelalem Aweke*****************************************
617446c266SZelalem AwekeIsolation between the four physical address spaces is enforced by a process
627446c266SZelalem Awekecalled Granule Protection Check (GPC) performed by the MMU downstream any
637446c266SZelalem Awekeaddress translation. GPC makes use of Granule Protection Table (GPT) in the
647446c266SZelalem AwekeRoot world that describes the physical address space assignment of every
657446c266SZelalem Awekepage (granule). A GPT library that provides APIs to initialize GPTs and to
667446c266SZelalem Aweketransition granules between different physical address spaces has been added.
677446c266SZelalem AwekeMore information about the GPT library can be found in the
687446c266SZelalem Aweke:ref:`Granule Protection Tables Library` chapter.
697446c266SZelalem Aweke
707446c266SZelalem AwekeRMM Dispatcher (RMMD)
717446c266SZelalem Aweke************************
727446c266SZelalem AwekeRMMD is a new standard runtime service that handles the switch to the Realm
73d9c976b0SSoby Mathewworld. It initializes the `RMM`_ and handles Realm Management Interface (RMI)
74d9c976b0SSoby MathewSMC calls from Non-secure.
757446c266SZelalem Aweke
76d9c976b0SSoby MathewThere is a contract between `RMM`_ and RMMD that defines the arguments that the
7769447290SJavier Almansa Sobrinoformer needs to take in order to initialize and also the possible return values.
78d9c976b0SSoby MathewThis contract is defined in the `RMM`_ Boot Interface, which can be found at
7969447290SJavier Almansa Sobrino:ref:`rmm_el3_boot_interface`.
8069447290SJavier Almansa Sobrino
8169447290SJavier Almansa SobrinoThere is also a specification of the runtime services provided by TF-A
82d9c976b0SSoby Mathewto `RMM`_. This can be found at :ref:`runtime_services_and_interface`.
8369447290SJavier Almansa Sobrino
847446c266SZelalem AwekeTest Realm Payload (TRP)
857446c266SZelalem Aweke*************************
867446c266SZelalem AwekeTRP is a small test payload that runs at R-EL2 and implements a subset of
877446c266SZelalem Awekethe Realm Management Interface (RMI) commands to primarily test EL3 firmware
887446c266SZelalem Awekeand the interface between R-EL2 and EL3. When building TF-A with RME enabled,
89d9c976b0SSoby Mathewif the path to an RMM image is not provided, TF-A builds the TRP by default
90d9c976b0SSoby Mathewand uses it as the R-EL2 payload.
913cfa3497SZelalem Aweke
923cfa3497SZelalem AwekeBuilding and running TF-A with RME
93d9c976b0SSoby Mathew----------------------------------
943cfa3497SZelalem Aweke
953cfa3497SZelalem AwekeThis section describes how you can build and run TF-A with RME enabled.
96d9c976b0SSoby MathewWe assume you have read the :ref:`Prerequisites` to build TF-A.
973cfa3497SZelalem Aweke
983cfa3497SZelalem AwekeThe following instructions show you how to build and run TF-A with RME
99d9c976b0SSoby Mathewon FVP for two scenarios:
1003cfa3497SZelalem Aweke
101d9c976b0SSoby Mathew- Three-world execution:  This is the configuration to use if Secure
102d9c976b0SSoby Mathew  world functionality is not needed. TF-A is tested with the following
103d9c976b0SSoby Mathew  software entities in each world as listed below:
1043cfa3497SZelalem Aweke
105d9c976b0SSoby Mathew  - NS Host (RME capable Linux or TF-A Tests),
10699d9ce8aSShruti Gupta  - Root (TF-A)
107d9c976b0SSoby Mathew  - R-EL2 (`RMM`_ or TRP)
10899d9ce8aSShruti Gupta
109d9c976b0SSoby Mathew- Four-world execution: This is the configuration to use if both Secure
110d9c976b0SSoby Mathew  and Realm world functionality is needed. TF-A is tested with the following
111d9c976b0SSoby Mathew  software entities in each world as listed below:
11299d9ce8aSShruti Gupta
113d9c976b0SSoby Mathew  - NS Host (RME capable Linux or TF-A Tests),
11499d9ce8aSShruti Gupta  - Root (TF-A)
115d9c976b0SSoby Mathew  - R-EL2 (`RMM`_ or TRP)
116d9c976b0SSoby Mathew  - S-EL2 (Hafnium SPM)
1173cfa3497SZelalem Aweke
1187446c266SZelalem AwekeTo run the tests, you need an FVP model. Please use the :ref:`latest version
119d9c976b0SSoby Mathew<Arm Fixed Virtual Platforms (FVP)>` of *FVP_Base_RevC-2xAEMvA* model. If NS
120d9c976b0SSoby MathewHost is Linux, then the below instructions assume that a suitable RME enabled
121d9c976b0SSoby Mathewkernel image and associated root filesystem are available.
1223cfa3497SZelalem Aweke
123d9c976b0SSoby MathewThree-world execution
124d9c976b0SSoby Mathew*********************
1253cfa3497SZelalem Aweke
126d9c976b0SSoby Mathew**1. Clone and build RMM Image**
1273cfa3497SZelalem Aweke
128d9c976b0SSoby MathewPlease refer to the `RMM Getting Started`_ on how to setup
129d9c976b0SSoby MathewHost Environment and build `RMM`_. The build commands assume that
130d9c976b0SSoby Mathewan AArch64 toolchain and CMake executable are available in the
131d9c976b0SSoby Mathewshell PATH variable and CROSS_COMPILE variable has been setup
132d9c976b0SSoby Mathewappropriately.
133d9c976b0SSoby Mathew
134d9c976b0SSoby MathewTo clone `RMM`_ and build using the default build options for FVP:
135d9c976b0SSoby Mathew
136d9c976b0SSoby Mathew.. code:: shell
137d9c976b0SSoby Mathew
138d9c976b0SSoby Mathew git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
139d9c976b0SSoby Mathew cd tf-rmm
140d9c976b0SSoby Mathew cmake -DRMM_CONFIG=fvp_defcfg -S . -B build
141d9c976b0SSoby Mathew cmake --build build
142d9c976b0SSoby Mathew
143d9c976b0SSoby MathewThis will generate **rmm.img** in **build/Release** folder.
144d9c976b0SSoby Mathew
145d9c976b0SSoby Mathew**2. Clone and build TF-A Tests with Realm Payload**
146d9c976b0SSoby Mathew
147d9c976b0SSoby MathewThis step is only needed if NS Host is TF-A Tests. The full set
148d9c976b0SSoby Mathewof instructions to setup build host and build options for
149d9c976b0SSoby MathewTF-A-Tests can be found in the `TFTF Getting Started`_. TF-A Tests
150d9c976b0SSoby Mathewcan test Realm world with either `RMM`_ or TRP in R-EL2. In the TRP case,
151d9c976b0SSoby Mathewsome tests which are not applicable will be skipped.
15299d9ce8aSShruti Gupta
1533cfa3497SZelalem AwekeUse the following instructions to build TF-A with `TF-A Tests`_ as the
1543cfa3497SZelalem Awekenon-secure payload (BL33).
1553cfa3497SZelalem Aweke
1563cfa3497SZelalem Aweke.. code:: shell
1573cfa3497SZelalem Aweke
1583cfa3497SZelalem Aweke git clone https://git.trustedfirmware.org/TF-A/tf-a-tests.git
1593cfa3497SZelalem Aweke cd tf-a-tests
160b1752870SShruti Gupta make CROSS_COMPILE=aarch64-none-elf- PLAT=fvp DEBUG=1 ENABLE_REALM_PAYLOAD_TESTS=1 all
1613cfa3497SZelalem Aweke
16299d9ce8aSShruti GuptaThis produces a TF-A Tests binary (**tftf.bin**) with Realm payload packaged
16399d9ce8aSShruti Guptaand **sp_layout.json** in the **build/fvp/debug** directory.
1643cfa3497SZelalem Aweke
16599d9ce8aSShruti Gupta
166d9c976b0SSoby Mathew**3. Build RME Enabled TF-A**
16799d9ce8aSShruti Gupta
16899d9ce8aSShruti GuptaThe `TF-A Getting Started`_ has the necessary instructions to setup Host
16999d9ce8aSShruti Guptamachine and build TF-A.
17099d9ce8aSShruti Gupta
17199d9ce8aSShruti GuptaTo build for RME, set ``ENABLE_RME`` build option to 1 and provide the path to
172d9c976b0SSoby Mathewthe `RMM`_ binary ``rmm.img`` using ``RMM`` build option.
17399d9ce8aSShruti Gupta
17499d9ce8aSShruti Gupta.. note::
17599d9ce8aSShruti Gupta
17699d9ce8aSShruti Gupta ENABLE_RME build option is currently experimental.
17799d9ce8aSShruti Gupta
178d9c976b0SSoby Mathew.. note::
179d9c976b0SSoby Mathew
180d9c976b0SSoby Mathew If the ``RMM`` option is not specified, TF-A builds the TRP to load and
181d9c976b0SSoby Mathew run at R-EL2.
18299d9ce8aSShruti Gupta
18399d9ce8aSShruti Gupta.. code:: shell
18499d9ce8aSShruti Gupta
18599d9ce8aSShruti Gupta git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
1863cfa3497SZelalem Aweke cd trusted-firmware-a
1873cfa3497SZelalem Aweke make CROSS_COMPILE=aarch64-none-elf- \
1883cfa3497SZelalem Aweke PLAT=fvp \
1893cfa3497SZelalem Aweke ENABLE_RME=1 \
19099d9ce8aSShruti Gupta RMM=<path/to/rmm.img> \
1913cfa3497SZelalem Aweke FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
1923cfa3497SZelalem Aweke DEBUG=1 \
193d9c976b0SSoby Mathew BL33=<path/to/bl33> \
1943cfa3497SZelalem Aweke all fip
1953cfa3497SZelalem Aweke
196d9c976b0SSoby Mathew``BL33`` can point to a Non Secure Bootloader like UEFI/U-Boot or
197d9c976b0SSoby Mathewthe TF-A Tests binary(**tftf.bin**) from the previous step.
1983cfa3497SZelalem Aweke
199d9c976b0SSoby MathewThis produces **bl1.bin** and **fip.bin** binaries in the **build/fvp/debug**
200d9c976b0SSoby Mathewdirectory.
2013cfa3497SZelalem Aweke
202d9c976b0SSoby MathewTF-A can also directly boot Linux kernel on the FVP. The kernel needs to be
203d9c976b0SSoby Mathew`preloaded` to a suitable memory location and this needs to be specified via
204d9c976b0SSoby Mathew``PRELOADED_BL33_BASE`` build option. Also TF-A should implement the Linux
205d9c976b0SSoby Mathewkernel register conventions for boot and this can be set using the
206d9c976b0SSoby Mathew``ARM_LINUX_KERNEL_AS_BL33`` option.
207d9c976b0SSoby Mathew
208d9c976b0SSoby Mathew.. code-block:: shell
209d9c976b0SSoby Mathew
210d9c976b0SSoby Mathew cd trusted-firmware-a
211d9c976b0SSoby Mathew make CROSS_COMPILE=aarch64-none-elf- \
212d9c976b0SSoby Mathew PLAT=fvp \
213d9c976b0SSoby Mathew ENABLE_RME=1 \
214d9c976b0SSoby Mathew RMM=<path/to/rmm.img> \
215d9c976b0SSoby Mathew FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
216d9c976b0SSoby Mathew DEBUG=1 \
217d9c976b0SSoby Mathew ARM_LINUX_KERNEL_AS_BL33=1 \
218d9c976b0SSoby Mathew PRELOADED_BL33_BASE=0x84000000 \
219d9c976b0SSoby Mathew all fip
220d9c976b0SSoby Mathew
221d9c976b0SSoby MathewThe above command assumes that the Linux kernel will be placed in FVP
222d9c976b0SSoby Mathewmemory at 0x84000000 via suitable FVP option (see the next step).
223d9c976b0SSoby Mathew
224d9c976b0SSoby Mathew.. _fvp_3_world_cmd:
225d9c976b0SSoby Mathew
226d9c976b0SSoby Mathew**4. Running FVP for 3 world setup**
227d9c976b0SSoby Mathew
228d9c976b0SSoby MathewUse the following command to run the tests on FVP.
2293cfa3497SZelalem Aweke
2303cfa3497SZelalem Aweke.. code:: shell
2313cfa3497SZelalem Aweke
2323cfa3497SZelalem Aweke FVP_Base_RevC-2xAEMvA                                          \
2333cfa3497SZelalem Aweke -C bp.refcounter.non_arch_start_at_default=1                   \
23499d9ce8aSShruti Gupta -C bp.secureflashloader.fname=<path/to/bl1.bin>                \
23599d9ce8aSShruti Gupta -C bp.flashloader0.fname=<path/to/fip.bin>                     \
2363cfa3497SZelalem Aweke -C bp.refcounter.use_real_time=0                               \
2373cfa3497SZelalem Aweke -C bp.ve_sysregs.exit_on_shutdown=1                            \
2383cfa3497SZelalem Aweke -C cache_state_modelled=1                                      \
239346cfe2bSAlexeiFedorov -C bp.dram_size=4                                              \
240*e0afd147SJ-Alves -C bp.secure_memory=0                                          \
24199d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_ROOT_IDR0=3                         \
24299d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_ROOT_IIDR=0x43B                     \
24399d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.root_register_page_offset=0x20000        \
2443cfa3497SZelalem Aweke -C cluster0.NUM_CORES=4                                        \
2453cfa3497SZelalem Aweke -C cluster0.PA_SIZE=48                                         \
2463cfa3497SZelalem Aweke -C cluster0.ecv_support_level=2                                \
2473cfa3497SZelalem Aweke -C cluster0.gicv3.cpuintf-mmap-access-level=2                  \
2483cfa3497SZelalem Aweke -C cluster0.gicv3.without-DS-support=1                         \
2493cfa3497SZelalem Aweke -C cluster0.gicv4.mask-virtual-interrupt=1                     \
2503cfa3497SZelalem Aweke -C cluster0.has_arm_v8-6=1                                     \
2513cfa3497SZelalem Aweke -C cluster0.has_amu=1                                          \
25299d9ce8aSShruti Gupta -C cluster0.has_branch_target_exception=1                      \
25399d9ce8aSShruti Gupta -C cluster0.rme_support_level=2                                \
25499d9ce8aSShruti Gupta -C cluster0.has_rndr=1                                         \
2553cfa3497SZelalem Aweke -C cluster0.has_v8_7_pmu_extension=2                           \
2563cfa3497SZelalem Aweke -C cluster0.max_32bit_el=-1                                    \
25799d9ce8aSShruti Gupta -C cluster0.stage12_tlb_size=1024                              \
25899d9ce8aSShruti Gupta -C cluster0.check_memory_attributes=0                          \
25999d9ce8aSShruti Gupta -C cluster0.ish_is_osh=1                                       \
2603cfa3497SZelalem Aweke -C cluster0.restriction_on_speculative_execution=2             \
2613cfa3497SZelalem Aweke -C cluster0.restriction_on_speculative_execution_aarch32=2     \
2623cfa3497SZelalem Aweke -C cluster1.NUM_CORES=4                                        \
2633cfa3497SZelalem Aweke -C cluster1.PA_SIZE=48                                         \
2643cfa3497SZelalem Aweke -C cluster1.ecv_support_level=2                                \
2653cfa3497SZelalem Aweke -C cluster1.gicv3.cpuintf-mmap-access-level=2                  \
2663cfa3497SZelalem Aweke -C cluster1.gicv3.without-DS-support=1                         \
2673cfa3497SZelalem Aweke -C cluster1.gicv4.mask-virtual-interrupt=1                     \
2683cfa3497SZelalem Aweke -C cluster1.has_arm_v8-6=1                                     \
2693cfa3497SZelalem Aweke -C cluster1.has_amu=1                                          \
27099d9ce8aSShruti Gupta -C cluster1.has_branch_target_exception=1                      \
27199d9ce8aSShruti Gupta -C cluster1.rme_support_level=2                                \
27299d9ce8aSShruti Gupta -C cluster1.has_rndr=1                                         \
2733cfa3497SZelalem Aweke -C cluster1.has_v8_7_pmu_extension=2                           \
2743cfa3497SZelalem Aweke -C cluster1.max_32bit_el=-1                                    \
27599d9ce8aSShruti Gupta -C cluster1.stage12_tlb_size=1024                              \
27699d9ce8aSShruti Gupta -C cluster1.check_memory_attributes=0                          \
27799d9ce8aSShruti Gupta -C cluster1.ish_is_osh=1                                       \
2783cfa3497SZelalem Aweke -C cluster1.restriction_on_speculative_execution=2             \
2793cfa3497SZelalem Aweke -C cluster1.restriction_on_speculative_execution_aarch32=2     \
2803cfa3497SZelalem Aweke -C pctl.startup=0.0.0.0                                        \
28199d9ce8aSShruti Gupta -C bp.smsc_91c111.enabled=1                                    \
282d9c976b0SSoby Mathew -C bp.hostbridge.userNetworking=1                              \
283d9c976b0SSoby Mathew -C bp.virtioblockdevice.image_path=<path/to/rootfs.ext4>
2843cfa3497SZelalem Aweke
285d9c976b0SSoby MathewThe ``bp.virtioblockdevice.image_path`` option presents the rootfs as a
286d9c976b0SSoby Mathewvirtio block device to Linux kernel. It can be ignored if NS Host is
287d9c976b0SSoby MathewTF-A-Tests or rootfs is accessed by some other mechanism.
288d9c976b0SSoby Mathew
289d9c976b0SSoby MathewIf TF-A was built to expect a preloaded Linux kernel, then use the following
290d9c976b0SSoby MathewFVP argument to load the kernel image at the expected address.
291d9c976b0SSoby Mathew
292d9c976b0SSoby Mathew.. code-block:: shell
293d9c976b0SSoby Mathew
294d9c976b0SSoby Mathew --data cluster0.cpu0=<path_to_kernel_Image>@0x84000000         \
295d9c976b0SSoby Mathew
296d9c976b0SSoby Mathew
297d9c976b0SSoby Mathew.. tip::
298d9c976b0SSoby Mathew Tips to boot and run Linux faster on the FVP :
299d9c976b0SSoby Mathew  1. Set the FVP option ``cache_state_modelled`` to 0.
300d9c976b0SSoby Mathew  2. Disable the CPU Idle driver in Linux either by setting the kernel command line
301d9c976b0SSoby Mathew     parameter "cpuidle.off=1" or by disabling the ``CONFIG_CPU_IDLE`` kernel config.
302d9c976b0SSoby Mathew
303d9c976b0SSoby MathewIf the NS Host is TF-A-Tests, then the default test suite in TFTF
304d9c976b0SSoby Mathewwill execute on the FVP and this includes Realm world tests. The
305d9c976b0SSoby Mathewtail of the output from *uart0* should look something like the following.
3063cfa3497SZelalem Aweke
3073cfa3497SZelalem Aweke.. code-block:: shell
3083cfa3497SZelalem Aweke
3093cfa3497SZelalem Aweke ...
3103cfa3497SZelalem Aweke
3113cfa3497SZelalem Aweke > Test suite 'FF-A Interrupt'
3123cfa3497SZelalem Aweke                                                                Passed
3133cfa3497SZelalem Aweke > Test suite 'SMMUv3 tests'
3143cfa3497SZelalem Aweke                                                                Passed
3153cfa3497SZelalem Aweke > Test suite 'PMU Leakage'
3163cfa3497SZelalem Aweke                                                                Passed
3173cfa3497SZelalem Aweke > Test suite 'DebugFS'
3183cfa3497SZelalem Aweke                                                                Passed
31999d9ce8aSShruti Gupta > Test suite 'RMI and SPM tests'
32099d9ce8aSShruti Gupta                                                                Passed
32199d9ce8aSShruti Gupta > Test suite 'Realm payload at EL1'
3223cfa3497SZelalem Aweke                                                                Passed
3231dd4bafbSManish Pandey > Test suite 'Invalid memory access'
3241dd4bafbSManish Pandey                                                                Passed
3253cfa3497SZelalem Aweke ...
3263cfa3497SZelalem Aweke
327d9c976b0SSoby MathewFour-world execution
328d9c976b0SSoby Mathew********************
32999d9ce8aSShruti Gupta
33099d9ce8aSShruti GuptaFour-world execution involves software components in each security state: root,
33199d9ce8aSShruti Guptasecure, realm and non-secure. This section describes how to build TF-A
33299d9ce8aSShruti Guptawith four-world support.
33399d9ce8aSShruti Gupta
334d9c976b0SSoby MathewWe use TF-A as the root firmware, `Hafnium SPM`_ is the reference Secure world
335d9c976b0SSoby Mathewcomponent running at S-EL2. `RMM`_ can be built as described in previous
336d9c976b0SSoby Mathewsection. The examples below assume TF-A-Tests as the NS Host and utilize SPs
337d9c976b0SSoby Mathewfrom TF-A-Tests.
33899d9ce8aSShruti Gupta
339d9c976b0SSoby Mathew**1. Obtain and build Hafnium SPM**
34099d9ce8aSShruti Gupta
34199d9ce8aSShruti Gupta.. code:: shell
34299d9ce8aSShruti Gupta
34399d9ce8aSShruti Gupta git clone --recurse-submodules https://git.trustedfirmware.org/hafnium/hafnium.git
34499d9ce8aSShruti Gupta cd hafnium
34599d9ce8aSShruti Gupta #  Use the default prebuilt LLVM/clang toolchain
34699d9ce8aSShruti Gupta PATH=$PWD/prebuilts/linux-x64/clang/bin:$PWD/prebuilts/linux-x64/dtc:$PATH
34799d9ce8aSShruti Gupta
34899d9ce8aSShruti GuptaFeature MTE needs to be disabled in Hafnium build, apply following patch to
34999d9ce8aSShruti Guptaproject/reference submodule
35099d9ce8aSShruti Gupta
35199d9ce8aSShruti Gupta.. code:: diff
35299d9ce8aSShruti Gupta
35399d9ce8aSShruti Gupta diff --git a/BUILD.gn b/BUILD.gn
35499d9ce8aSShruti Gupta index cc6a78f..234b20a 100644
35599d9ce8aSShruti Gupta --- a/BUILD.gn
35699d9ce8aSShruti Gupta +++ b/BUILD.gn
35799d9ce8aSShruti Gupta @@ -83,7 +83,6 @@ aarch64_toolchains("secure_aem_v8a_fvp") {
35899d9ce8aSShruti Gupta     pl011_base_address = "0x1c090000"
35999d9ce8aSShruti Gupta     smmu_base_address = "0x2b400000"
36099d9ce8aSShruti Gupta     smmu_memory_size = "0x100000"
36199d9ce8aSShruti Gupta -    enable_mte = "1"
36299d9ce8aSShruti Gupta     plat_log_level = "LOG_LEVEL_INFO"
36399d9ce8aSShruti Gupta   }
36499d9ce8aSShruti Gupta }
36599d9ce8aSShruti Gupta
36699d9ce8aSShruti Gupta.. code:: shell
36799d9ce8aSShruti Gupta
36899d9ce8aSShruti Gupta make PROJECT=reference
36999d9ce8aSShruti Gupta
37099d9ce8aSShruti GuptaThe Hafnium binary should be located at
37199d9ce8aSShruti Gupta*out/reference/secure_aem_v8a_fvp_clang/hafnium.bin*
37299d9ce8aSShruti Gupta
373d9c976b0SSoby Mathew**2. Build RME enabled TF-A with SPM**
37499d9ce8aSShruti Gupta
37599d9ce8aSShruti GuptaBuild TF-A with RME as well as SPM enabled.
37699d9ce8aSShruti Gupta
377d9c976b0SSoby MathewUse the ``sp_layout.json`` previously generated in TF-A Tests
378d9c976b0SSoby Mathewbuild to run SP tests.
37999d9ce8aSShruti Gupta
38099d9ce8aSShruti Gupta.. code:: shell
38199d9ce8aSShruti Gupta
38299d9ce8aSShruti Gupta make CROSS_COMPILE=aarch64-none-elf- \
38399d9ce8aSShruti Gupta PLAT=fvp \
38499d9ce8aSShruti Gupta ENABLE_RME=1 \
38599d9ce8aSShruti Gupta FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
38699d9ce8aSShruti Gupta SPD=spmd \
38799d9ce8aSShruti Gupta BRANCH_PROTECTION=1 \
38899d9ce8aSShruti Gupta CTX_INCLUDE_PAUTH_REGS=1 \
38999d9ce8aSShruti Gupta DEBUG=1 \
39099d9ce8aSShruti Gupta SP_LAYOUT_FILE=<path/to/sp_layout.json> \
39199d9ce8aSShruti Gupta BL32=<path/to/hafnium.bin> \
39299d9ce8aSShruti Gupta BL33=<path/to/tftf.bin> \
39399d9ce8aSShruti Gupta RMM=<path/to/rmm.img> \
39499d9ce8aSShruti Gupta all fip
39599d9ce8aSShruti Gupta
396d9c976b0SSoby Mathew**3. Running the FVP for a 4 world setup**
39799d9ce8aSShruti Gupta
398d9c976b0SSoby MathewUse the following arguments in addition to the FVP options mentioned in
399d9c976b0SSoby Mathew:ref:`4. Running FVP for 3 world setup <fvp_3_world_cmd>` to run tests for
400d9c976b0SSoby Mathew4 world setup.
40199d9ce8aSShruti Gupta
40299d9ce8aSShruti Gupta.. code:: shell
40399d9ce8aSShruti Gupta
40499d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_AIDR=2              \
40599d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B     \
40699d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002     \
40799d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714         \
40899d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0475     \
40999d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002   \
41099d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_S_IDR2=0            \
41199d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_S_IDR3=0
4123cfa3497SZelalem Aweke
4133cfa3497SZelalem Aweke.. _Arm Confidential Compute Architecture (Arm CCA): https://www.arm.com/why-arm/architecture/security-features/arm-confidential-compute-architecture
4143cfa3497SZelalem Aweke.. _Arm Architecture Models website: https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms/arm-ecosystem-models
41599d9ce8aSShruti Gupta.. _TF-A Getting Started: https://trustedfirmware-a.readthedocs.io/en/latest/getting_started/index.html
4163cfa3497SZelalem Aweke.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io/en/latest
41799d9ce8aSShruti Gupta.. _TFTF Getting Started: https://trustedfirmware-a-tests.readthedocs.io/en/latest/getting_started/index.html
41899d9ce8aSShruti Gupta.. _Hafnium SPM: https://www.trustedfirmware.org/projects/hafnium
419d9c976b0SSoby Mathew.. _RMM Getting Started: https://tf-rmm.readthedocs.io/en/latest/getting_started/index.html
420d9c976b0SSoby Mathew.. _RMM: https://www.trustedfirmware.org/projects/tf-rmm/
421