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******************************* 38*b5f120b5SBoyan KaratotevA new CPU context for the Realm world has been added. The existing can be used 39*b5f120b5SBoyan Karatotevto manage Realm context. 407446c266SZelalem Aweke 417446c266SZelalem AwekeBoot flow changes 427446c266SZelalem Aweke******************* 437446c266SZelalem AwekeIn a typical TF-A boot flow, BL2 runs at Secure-EL1. However when RME is 447446c266SZelalem Awekeenabled, TF-A runs in the Root world at EL3. Therefore, the boot flow is 457446c266SZelalem Awekemodified to run BL2 at EL3 when RME is enabled. In addition to this, a 46d9c976b0SSoby MathewRealm-world firmware (`RMM`_) is loaded by BL2 in the Realm physical address 477446c266SZelalem Awekespace. 487446c266SZelalem Aweke 497446c266SZelalem AwekeThe boot flow when RME is enabled looks like the following: 507446c266SZelalem Aweke 517446c266SZelalem Aweke1. BL1 loads and executes BL2 at EL3 527446c266SZelalem Aweke2. BL2 loads images including RMM 537446c266SZelalem Aweke3. BL2 transfers control to BL31 547446c266SZelalem Aweke4. BL31 initializes SPM (if SPM is enabled) 557446c266SZelalem Aweke5. BL31 initializes RMM 567446c266SZelalem Aweke6. BL31 transfers control to Normal-world software 577446c266SZelalem Aweke 587446c266SZelalem AwekeGranule Protection Tables (GPT) library 597446c266SZelalem Aweke***************************************** 607446c266SZelalem AwekeIsolation between the four physical address spaces is enforced by a process 617446c266SZelalem Awekecalled Granule Protection Check (GPC) performed by the MMU downstream any 627446c266SZelalem Awekeaddress translation. GPC makes use of Granule Protection Table (GPT) in the 637446c266SZelalem AwekeRoot world that describes the physical address space assignment of every 647446c266SZelalem Awekepage (granule). A GPT library that provides APIs to initialize GPTs and to 657446c266SZelalem Aweketransition granules between different physical address spaces has been added. 667446c266SZelalem AwekeMore information about the GPT library can be found in the 677446c266SZelalem Aweke:ref:`Granule Protection Tables Library` chapter. 687446c266SZelalem Aweke 697446c266SZelalem AwekeRMM Dispatcher (RMMD) 707446c266SZelalem Aweke************************ 717446c266SZelalem AwekeRMMD is a new standard runtime service that handles the switch to the Realm 72d9c976b0SSoby Mathewworld. It initializes the `RMM`_ and handles Realm Management Interface (RMI) 73d9c976b0SSoby MathewSMC calls from Non-secure. 747446c266SZelalem Aweke 75d9c976b0SSoby MathewThere is a contract between `RMM`_ and RMMD that defines the arguments that the 7669447290SJavier Almansa Sobrinoformer needs to take in order to initialize and also the possible return values. 77d9c976b0SSoby MathewThis contract is defined in the `RMM`_ Boot Interface, which can be found at 7869447290SJavier Almansa Sobrino:ref:`rmm_el3_boot_interface`. 7969447290SJavier Almansa Sobrino 8069447290SJavier Almansa SobrinoThere is also a specification of the runtime services provided by TF-A 81d9c976b0SSoby Mathewto `RMM`_. This can be found at :ref:`runtime_services_and_interface`. 8269447290SJavier Almansa Sobrino 837446c266SZelalem AwekeTest Realm Payload (TRP) 847446c266SZelalem Aweke************************* 857446c266SZelalem AwekeTRP is a small test payload that runs at R-EL2 and implements a subset of 867446c266SZelalem Awekethe Realm Management Interface (RMI) commands to primarily test EL3 firmware 877446c266SZelalem Awekeand the interface between R-EL2 and EL3. When building TF-A with RME enabled, 88d9c976b0SSoby Mathewif the path to an RMM image is not provided, TF-A builds the TRP by default 89d9c976b0SSoby Mathewand uses it as the R-EL2 payload. 903cfa3497SZelalem Aweke 913cfa3497SZelalem AwekeBuilding and running TF-A with RME 92d9c976b0SSoby Mathew---------------------------------- 933cfa3497SZelalem Aweke 943cfa3497SZelalem AwekeThis section describes how you can build and run TF-A with RME enabled. 95d9c976b0SSoby MathewWe assume you have read the :ref:`Prerequisites` to build TF-A. 963cfa3497SZelalem Aweke 973cfa3497SZelalem AwekeThe following instructions show you how to build and run TF-A with RME 98d9c976b0SSoby Mathewon FVP for two scenarios: 993cfa3497SZelalem Aweke 100d9c976b0SSoby Mathew- Three-world execution: This is the configuration to use if Secure 101d9c976b0SSoby Mathew world functionality is not needed. TF-A is tested with the following 102d9c976b0SSoby Mathew software entities in each world as listed below: 1033cfa3497SZelalem Aweke 104d9c976b0SSoby Mathew - NS Host (RME capable Linux or TF-A Tests), 10599d9ce8aSShruti Gupta - Root (TF-A) 106d9c976b0SSoby Mathew - R-EL2 (`RMM`_ or TRP) 10799d9ce8aSShruti Gupta 108d9c976b0SSoby Mathew- Four-world execution: This is the configuration to use if both Secure 109d9c976b0SSoby Mathew and Realm world functionality is needed. TF-A is tested with the following 110d9c976b0SSoby Mathew software entities in each world as listed below: 11199d9ce8aSShruti Gupta 112d9c976b0SSoby Mathew - NS Host (RME capable Linux or TF-A Tests), 11399d9ce8aSShruti Gupta - Root (TF-A) 114d9c976b0SSoby Mathew - R-EL2 (`RMM`_ or TRP) 115d9c976b0SSoby Mathew - S-EL2 (Hafnium SPM) 1163cfa3497SZelalem Aweke 1177446c266SZelalem AwekeTo run the tests, you need an FVP model. Please use the :ref:`latest version 118d9c976b0SSoby Mathew<Arm Fixed Virtual Platforms (FVP)>` of *FVP_Base_RevC-2xAEMvA* model. If NS 119d9c976b0SSoby MathewHost is Linux, then the below instructions assume that a suitable RME enabled 120d9c976b0SSoby Mathewkernel image and associated root filesystem are available. 1213cfa3497SZelalem Aweke 122d9c976b0SSoby MathewThree-world execution 123d9c976b0SSoby Mathew********************* 1243cfa3497SZelalem Aweke 125d9c976b0SSoby Mathew**1. Clone and build RMM Image** 1263cfa3497SZelalem Aweke 127d9c976b0SSoby MathewPlease refer to the `RMM Getting Started`_ on how to setup 128d9c976b0SSoby MathewHost Environment and build `RMM`_. The build commands assume that 129d9c976b0SSoby Mathewan AArch64 toolchain and CMake executable are available in the 130d9c976b0SSoby Mathewshell PATH variable and CROSS_COMPILE variable has been setup 131d9c976b0SSoby Mathewappropriately. 132d9c976b0SSoby Mathew 133d9c976b0SSoby MathewTo clone `RMM`_ and build using the default build options for FVP: 134d9c976b0SSoby Mathew 135d9c976b0SSoby Mathew.. code:: shell 136d9c976b0SSoby Mathew 137d9c976b0SSoby Mathew git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git 138d9c976b0SSoby Mathew cd tf-rmm 139d9c976b0SSoby Mathew cmake -DRMM_CONFIG=fvp_defcfg -S . -B build 140d9c976b0SSoby Mathew cmake --build build 141d9c976b0SSoby Mathew 142d9c976b0SSoby MathewThis will generate **rmm.img** in **build/Release** folder. 143d9c976b0SSoby Mathew 144d9c976b0SSoby Mathew**2. Clone and build TF-A Tests with Realm Payload** 145d9c976b0SSoby Mathew 146d9c976b0SSoby MathewThis step is only needed if NS Host is TF-A Tests. The full set 147d9c976b0SSoby Mathewof instructions to setup build host and build options for 148d9c976b0SSoby MathewTF-A-Tests can be found in the `TFTF Getting Started`_. TF-A Tests 149d9c976b0SSoby Mathewcan test Realm world with either `RMM`_ or TRP in R-EL2. In the TRP case, 150d9c976b0SSoby Mathewsome tests which are not applicable will be skipped. 15199d9ce8aSShruti Gupta 1523cfa3497SZelalem AwekeUse the following instructions to build TF-A with `TF-A Tests`_ as the 1533cfa3497SZelalem Awekenon-secure payload (BL33). 1543cfa3497SZelalem Aweke 1553cfa3497SZelalem Aweke.. code:: shell 1563cfa3497SZelalem Aweke 1573cfa3497SZelalem Aweke git clone https://git.trustedfirmware.org/TF-A/tf-a-tests.git 1583cfa3497SZelalem Aweke cd tf-a-tests 159b1752870SShruti Gupta make CROSS_COMPILE=aarch64-none-elf- PLAT=fvp DEBUG=1 ENABLE_REALM_PAYLOAD_TESTS=1 all 1603cfa3497SZelalem Aweke 16199d9ce8aSShruti GuptaThis produces a TF-A Tests binary (**tftf.bin**) with Realm payload packaged 16299d9ce8aSShruti Guptaand **sp_layout.json** in the **build/fvp/debug** directory. 1633cfa3497SZelalem Aweke 16499d9ce8aSShruti Gupta 165d9c976b0SSoby Mathew**3. Build RME Enabled TF-A** 16699d9ce8aSShruti Gupta 16799d9ce8aSShruti GuptaThe `TF-A Getting Started`_ has the necessary instructions to setup Host 16899d9ce8aSShruti Guptamachine and build TF-A. 16999d9ce8aSShruti Gupta 17099d9ce8aSShruti GuptaTo build for RME, set ``ENABLE_RME`` build option to 1 and provide the path to 171d9c976b0SSoby Mathewthe `RMM`_ binary ``rmm.img`` using ``RMM`` build option. 17299d9ce8aSShruti Gupta 17399d9ce8aSShruti Gupta.. note:: 17499d9ce8aSShruti Gupta 17599d9ce8aSShruti Gupta ENABLE_RME build option is currently experimental. 17699d9ce8aSShruti Gupta 177d9c976b0SSoby Mathew.. note:: 178d9c976b0SSoby Mathew 179d9c976b0SSoby Mathew If the ``RMM`` option is not specified, TF-A builds the TRP to load and 180d9c976b0SSoby Mathew run at R-EL2. 18199d9ce8aSShruti Gupta 18299d9ce8aSShruti Gupta.. code:: shell 18399d9ce8aSShruti Gupta 18499d9ce8aSShruti Gupta git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git 1853cfa3497SZelalem Aweke cd trusted-firmware-a 1863cfa3497SZelalem Aweke make CROSS_COMPILE=aarch64-none-elf- \ 1873cfa3497SZelalem Aweke PLAT=fvp \ 1883cfa3497SZelalem Aweke ENABLE_RME=1 \ 18999d9ce8aSShruti Gupta RMM=<path/to/rmm.img> \ 1903cfa3497SZelalem Aweke FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \ 1913cfa3497SZelalem Aweke DEBUG=1 \ 192d9c976b0SSoby Mathew BL33=<path/to/bl33> \ 1933cfa3497SZelalem Aweke all fip 1943cfa3497SZelalem Aweke 195d9c976b0SSoby Mathew``BL33`` can point to a Non Secure Bootloader like UEFI/U-Boot or 196d9c976b0SSoby Mathewthe TF-A Tests binary(**tftf.bin**) from the previous step. 1973cfa3497SZelalem Aweke 198d9c976b0SSoby MathewThis produces **bl1.bin** and **fip.bin** binaries in the **build/fvp/debug** 199d9c976b0SSoby Mathewdirectory. 2003cfa3497SZelalem Aweke 201d9c976b0SSoby MathewTF-A can also directly boot Linux kernel on the FVP. The kernel needs to be 202d9c976b0SSoby Mathew`preloaded` to a suitable memory location and this needs to be specified via 203d9c976b0SSoby Mathew``PRELOADED_BL33_BASE`` build option. Also TF-A should implement the Linux 204d9c976b0SSoby Mathewkernel register conventions for boot and this can be set using the 205d9c976b0SSoby Mathew``ARM_LINUX_KERNEL_AS_BL33`` option. 206d9c976b0SSoby Mathew 207d9c976b0SSoby Mathew.. code-block:: shell 208d9c976b0SSoby Mathew 209d9c976b0SSoby Mathew cd trusted-firmware-a 210d9c976b0SSoby Mathew make CROSS_COMPILE=aarch64-none-elf- \ 211d9c976b0SSoby Mathew PLAT=fvp \ 212d9c976b0SSoby Mathew ENABLE_RME=1 \ 213d9c976b0SSoby Mathew RMM=<path/to/rmm.img> \ 214d9c976b0SSoby Mathew FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \ 215d9c976b0SSoby Mathew DEBUG=1 \ 216d9c976b0SSoby Mathew ARM_LINUX_KERNEL_AS_BL33=1 \ 217d9c976b0SSoby Mathew PRELOADED_BL33_BASE=0x84000000 \ 218d9c976b0SSoby Mathew all fip 219d9c976b0SSoby Mathew 220d9c976b0SSoby MathewThe above command assumes that the Linux kernel will be placed in FVP 221d9c976b0SSoby Mathewmemory at 0x84000000 via suitable FVP option (see the next step). 222d9c976b0SSoby Mathew 223d9c976b0SSoby Mathew.. _fvp_3_world_cmd: 224d9c976b0SSoby Mathew 225d9c976b0SSoby Mathew**4. Running FVP for 3 world setup** 226d9c976b0SSoby Mathew 227d9c976b0SSoby MathewUse the following command to run the tests on FVP. 2283cfa3497SZelalem Aweke 2293cfa3497SZelalem Aweke.. code:: shell 2303cfa3497SZelalem Aweke 2313cfa3497SZelalem Aweke FVP_Base_RevC-2xAEMvA \ 2323cfa3497SZelalem Aweke -C bp.refcounter.non_arch_start_at_default=1 \ 23399d9ce8aSShruti Gupta -C bp.secureflashloader.fname=<path/to/bl1.bin> \ 23499d9ce8aSShruti Gupta -C bp.flashloader0.fname=<path/to/fip.bin> \ 2353cfa3497SZelalem Aweke -C bp.refcounter.use_real_time=0 \ 2363cfa3497SZelalem Aweke -C bp.ve_sysregs.exit_on_shutdown=1 \ 2373cfa3497SZelalem Aweke -C cache_state_modelled=1 \ 238346cfe2bSAlexeiFedorov -C bp.dram_size=4 \ 239e0afd147SJ-Alves -C bp.secure_memory=0 \ 24099d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_ROOT_IDR0=3 \ 24199d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_ROOT_IIDR=0x43B \ 24299d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.root_register_page_offset=0x20000 \ 2433cfa3497SZelalem Aweke -C cluster0.NUM_CORES=4 \ 2443cfa3497SZelalem Aweke -C cluster0.PA_SIZE=48 \ 2453cfa3497SZelalem Aweke -C cluster0.ecv_support_level=2 \ 2463cfa3497SZelalem Aweke -C cluster0.gicv3.cpuintf-mmap-access-level=2 \ 2473cfa3497SZelalem Aweke -C cluster0.gicv3.without-DS-support=1 \ 2483cfa3497SZelalem Aweke -C cluster0.gicv4.mask-virtual-interrupt=1 \ 2493cfa3497SZelalem Aweke -C cluster0.has_arm_v8-6=1 \ 2503cfa3497SZelalem Aweke -C cluster0.has_amu=1 \ 25199d9ce8aSShruti Gupta -C cluster0.has_branch_target_exception=1 \ 25299d9ce8aSShruti Gupta -C cluster0.rme_support_level=2 \ 25399d9ce8aSShruti Gupta -C cluster0.has_rndr=1 \ 2543cfa3497SZelalem Aweke -C cluster0.has_v8_7_pmu_extension=2 \ 2553cfa3497SZelalem Aweke -C cluster0.max_32bit_el=-1 \ 25699d9ce8aSShruti Gupta -C cluster0.stage12_tlb_size=1024 \ 25799d9ce8aSShruti Gupta -C cluster0.check_memory_attributes=0 \ 25899d9ce8aSShruti Gupta -C cluster0.ish_is_osh=1 \ 2593cfa3497SZelalem Aweke -C cluster0.restriction_on_speculative_execution=2 \ 2603cfa3497SZelalem Aweke -C cluster0.restriction_on_speculative_execution_aarch32=2 \ 2613cfa3497SZelalem Aweke -C cluster1.NUM_CORES=4 \ 2623cfa3497SZelalem Aweke -C cluster1.PA_SIZE=48 \ 2633cfa3497SZelalem Aweke -C cluster1.ecv_support_level=2 \ 2643cfa3497SZelalem Aweke -C cluster1.gicv3.cpuintf-mmap-access-level=2 \ 2653cfa3497SZelalem Aweke -C cluster1.gicv3.without-DS-support=1 \ 2663cfa3497SZelalem Aweke -C cluster1.gicv4.mask-virtual-interrupt=1 \ 2673cfa3497SZelalem Aweke -C cluster1.has_arm_v8-6=1 \ 2683cfa3497SZelalem Aweke -C cluster1.has_amu=1 \ 26999d9ce8aSShruti Gupta -C cluster1.has_branch_target_exception=1 \ 27099d9ce8aSShruti Gupta -C cluster1.rme_support_level=2 \ 27199d9ce8aSShruti Gupta -C cluster1.has_rndr=1 \ 2723cfa3497SZelalem Aweke -C cluster1.has_v8_7_pmu_extension=2 \ 2733cfa3497SZelalem Aweke -C cluster1.max_32bit_el=-1 \ 27499d9ce8aSShruti Gupta -C cluster1.stage12_tlb_size=1024 \ 27599d9ce8aSShruti Gupta -C cluster1.check_memory_attributes=0 \ 27699d9ce8aSShruti Gupta -C cluster1.ish_is_osh=1 \ 2773cfa3497SZelalem Aweke -C cluster1.restriction_on_speculative_execution=2 \ 2783cfa3497SZelalem Aweke -C cluster1.restriction_on_speculative_execution_aarch32=2 \ 2793cfa3497SZelalem Aweke -C pctl.startup=0.0.0.0 \ 28099d9ce8aSShruti Gupta -C bp.smsc_91c111.enabled=1 \ 281d9c976b0SSoby Mathew -C bp.hostbridge.userNetworking=1 \ 282d9c976b0SSoby Mathew -C bp.virtioblockdevice.image_path=<path/to/rootfs.ext4> 2833cfa3497SZelalem Aweke 284d9c976b0SSoby MathewThe ``bp.virtioblockdevice.image_path`` option presents the rootfs as a 285d9c976b0SSoby Mathewvirtio block device to Linux kernel. It can be ignored if NS Host is 286d9c976b0SSoby MathewTF-A-Tests or rootfs is accessed by some other mechanism. 287d9c976b0SSoby Mathew 288d9c976b0SSoby MathewIf TF-A was built to expect a preloaded Linux kernel, then use the following 289d9c976b0SSoby MathewFVP argument to load the kernel image at the expected address. 290d9c976b0SSoby Mathew 291d9c976b0SSoby Mathew.. code-block:: shell 292d9c976b0SSoby Mathew 293d9c976b0SSoby Mathew --data cluster0.cpu0=<path_to_kernel_Image>@0x84000000 \ 294d9c976b0SSoby Mathew 295d9c976b0SSoby Mathew 296d9c976b0SSoby Mathew.. tip:: 297d9c976b0SSoby Mathew Tips to boot and run Linux faster on the FVP : 298d9c976b0SSoby Mathew 1. Set the FVP option ``cache_state_modelled`` to 0. 299d9c976b0SSoby Mathew 2. Disable the CPU Idle driver in Linux either by setting the kernel command line 300d9c976b0SSoby Mathew parameter "cpuidle.off=1" or by disabling the ``CONFIG_CPU_IDLE`` kernel config. 301d9c976b0SSoby Mathew 302d9c976b0SSoby MathewIf the NS Host is TF-A-Tests, then the default test suite in TFTF 303d9c976b0SSoby Mathewwill execute on the FVP and this includes Realm world tests. The 304d9c976b0SSoby Mathewtail of the output from *uart0* should look something like the following. 3053cfa3497SZelalem Aweke 3063cfa3497SZelalem Aweke.. code-block:: shell 3073cfa3497SZelalem Aweke 3083cfa3497SZelalem Aweke ... 3093cfa3497SZelalem Aweke 3103cfa3497SZelalem Aweke > Test suite 'FF-A Interrupt' 3113cfa3497SZelalem Aweke Passed 3123cfa3497SZelalem Aweke > Test suite 'SMMUv3 tests' 3133cfa3497SZelalem Aweke Passed 3143cfa3497SZelalem Aweke > Test suite 'PMU Leakage' 3153cfa3497SZelalem Aweke Passed 3163cfa3497SZelalem Aweke > Test suite 'DebugFS' 3173cfa3497SZelalem Aweke Passed 31899d9ce8aSShruti Gupta > Test suite 'RMI and SPM tests' 31999d9ce8aSShruti Gupta Passed 32099d9ce8aSShruti Gupta > Test suite 'Realm payload at EL1' 3213cfa3497SZelalem Aweke Passed 3221dd4bafbSManish Pandey > Test suite 'Invalid memory access' 3231dd4bafbSManish Pandey Passed 3243cfa3497SZelalem Aweke ... 3253cfa3497SZelalem Aweke 326d9c976b0SSoby MathewFour-world execution 327d9c976b0SSoby Mathew******************** 32899d9ce8aSShruti Gupta 32999d9ce8aSShruti GuptaFour-world execution involves software components in each security state: root, 33099d9ce8aSShruti Guptasecure, realm and non-secure. This section describes how to build TF-A 33199d9ce8aSShruti Guptawith four-world support. 33299d9ce8aSShruti Gupta 333d9c976b0SSoby MathewWe use TF-A as the root firmware, `Hafnium SPM`_ is the reference Secure world 334d9c976b0SSoby Mathewcomponent running at S-EL2. `RMM`_ can be built as described in previous 335d9c976b0SSoby Mathewsection. The examples below assume TF-A-Tests as the NS Host and utilize SPs 336d9c976b0SSoby Mathewfrom TF-A-Tests. 33799d9ce8aSShruti Gupta 338d9c976b0SSoby Mathew**1. Obtain and build Hafnium SPM** 33999d9ce8aSShruti Gupta 34099d9ce8aSShruti Gupta.. code:: shell 34199d9ce8aSShruti Gupta 34299d9ce8aSShruti Gupta git clone --recurse-submodules https://git.trustedfirmware.org/hafnium/hafnium.git 34399d9ce8aSShruti Gupta cd hafnium 34499d9ce8aSShruti Gupta # Use the default prebuilt LLVM/clang toolchain 34599d9ce8aSShruti Gupta PATH=$PWD/prebuilts/linux-x64/clang/bin:$PWD/prebuilts/linux-x64/dtc:$PATH 34699d9ce8aSShruti Gupta 34799d9ce8aSShruti GuptaFeature MTE needs to be disabled in Hafnium build, apply following patch to 34899d9ce8aSShruti Guptaproject/reference submodule 34999d9ce8aSShruti Gupta 35099d9ce8aSShruti Gupta.. code:: diff 35199d9ce8aSShruti Gupta 35299d9ce8aSShruti Gupta diff --git a/BUILD.gn b/BUILD.gn 35399d9ce8aSShruti Gupta index cc6a78f..234b20a 100644 35499d9ce8aSShruti Gupta --- a/BUILD.gn 35599d9ce8aSShruti Gupta +++ b/BUILD.gn 35699d9ce8aSShruti Gupta @@ -83,7 +83,6 @@ aarch64_toolchains("secure_aem_v8a_fvp") { 35799d9ce8aSShruti Gupta pl011_base_address = "0x1c090000" 35899d9ce8aSShruti Gupta smmu_base_address = "0x2b400000" 35999d9ce8aSShruti Gupta smmu_memory_size = "0x100000" 36099d9ce8aSShruti Gupta - enable_mte = "1" 36199d9ce8aSShruti Gupta plat_log_level = "LOG_LEVEL_INFO" 36299d9ce8aSShruti Gupta } 36399d9ce8aSShruti Gupta } 36499d9ce8aSShruti Gupta 36599d9ce8aSShruti Gupta.. code:: shell 36699d9ce8aSShruti Gupta 36799d9ce8aSShruti Gupta make PROJECT=reference 36899d9ce8aSShruti Gupta 36999d9ce8aSShruti GuptaThe Hafnium binary should be located at 37099d9ce8aSShruti Gupta*out/reference/secure_aem_v8a_fvp_clang/hafnium.bin* 37199d9ce8aSShruti Gupta 372d9c976b0SSoby Mathew**2. Build RME enabled TF-A with SPM** 37399d9ce8aSShruti Gupta 37499d9ce8aSShruti GuptaBuild TF-A with RME as well as SPM enabled. 37599d9ce8aSShruti Gupta 376d9c976b0SSoby MathewUse the ``sp_layout.json`` previously generated in TF-A Tests 377d9c976b0SSoby Mathewbuild to run SP tests. 37899d9ce8aSShruti Gupta 37999d9ce8aSShruti Gupta.. code:: shell 38099d9ce8aSShruti Gupta 38199d9ce8aSShruti Gupta make CROSS_COMPILE=aarch64-none-elf- \ 38299d9ce8aSShruti Gupta PLAT=fvp \ 38399d9ce8aSShruti Gupta ENABLE_RME=1 \ 38499d9ce8aSShruti Gupta FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \ 38599d9ce8aSShruti Gupta SPD=spmd \ 38699d9ce8aSShruti Gupta BRANCH_PROTECTION=1 \ 38799d9ce8aSShruti Gupta CTX_INCLUDE_PAUTH_REGS=1 \ 38899d9ce8aSShruti Gupta DEBUG=1 \ 38999d9ce8aSShruti Gupta SP_LAYOUT_FILE=<path/to/sp_layout.json> \ 39099d9ce8aSShruti Gupta BL32=<path/to/hafnium.bin> \ 39199d9ce8aSShruti Gupta BL33=<path/to/tftf.bin> \ 39299d9ce8aSShruti Gupta RMM=<path/to/rmm.img> \ 39399d9ce8aSShruti Gupta all fip 39499d9ce8aSShruti Gupta 395d9c976b0SSoby Mathew**3. Running the FVP for a 4 world setup** 39699d9ce8aSShruti Gupta 397d9c976b0SSoby MathewUse the following arguments in addition to the FVP options mentioned in 398d9c976b0SSoby Mathew:ref:`4. Running FVP for 3 world setup <fvp_3_world_cmd>` to run tests for 399d9c976b0SSoby Mathew4 world setup. 40099d9ce8aSShruti Gupta 40199d9ce8aSShruti Gupta.. code:: shell 40299d9ce8aSShruti Gupta 40399d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_AIDR=2 \ 40499d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR0=0x0046123B \ 40599d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR1=0x00600002 \ 40699d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR3=0x1714 \ 40799d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_IDR5=0xFFFF0475 \ 40899d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_S_IDR1=0xA0000002 \ 40999d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_S_IDR2=0 \ 41099d9ce8aSShruti Gupta -C pci.pci_smmuv3.mmu.SMMU_S_IDR3=0 4113cfa3497SZelalem Aweke 4123cfa3497SZelalem Aweke.. _Arm Confidential Compute Architecture (Arm CCA): https://www.arm.com/why-arm/architecture/security-features/arm-confidential-compute-architecture 4133cfa3497SZelalem Aweke.. _Arm Architecture Models website: https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms/arm-ecosystem-models 41499d9ce8aSShruti Gupta.. _TF-A Getting Started: https://trustedfirmware-a.readthedocs.io/en/latest/getting_started/index.html 4153cfa3497SZelalem Aweke.. _TF-A Tests: https://trustedfirmware-a-tests.readthedocs.io/en/latest 41699d9ce8aSShruti Gupta.. _TFTF Getting Started: https://trustedfirmware-a-tests.readthedocs.io/en/latest/getting_started/index.html 41799d9ce8aSShruti Gupta.. _Hafnium SPM: https://www.trustedfirmware.org/projects/hafnium 418d9c976b0SSoby Mathew.. _RMM Getting Started: https://tf-rmm.readthedocs.io/en/latest/getting_started/index.html 419d9c976b0SSoby Mathew.. _RMM: https://www.trustedfirmware.org/projects/tf-rmm/ 420