@@ -13,7 +13,7 @@ RME support in TF-A
1313The following diagram shows an Arm CCA software architecture with TF-A as the
1414EL3 firmware. In the Arm CCA architecture there are two additional security
1515states and address spaces: ``Root `` and ``Realm ``. TF-A firmware runs in the
16- Root world. In the realm world, a Realm Management Monitor firmware (RMM)
16+ Root world. In the realm world, a Realm Management Monitor firmware (` RMM `_ )
1717manages the execution of Realm VMs and their interaction with the hypervisor.
1818
1919.. image :: ../resources/diagrams/arm-cca-software-arch.png
@@ -44,7 +44,7 @@ Boot flow changes
4444In a typical TF-A boot flow, BL2 runs at Secure-EL1. However when RME is
4545enabled, TF-A runs in the Root world at EL3. Therefore, the boot flow is
4646modified to run BL2 at EL3 when RME is enabled. In addition to this, a
47- Realm-world firmware (RMM) is loaded by BL2 in the Realm physical address
47+ Realm-world firmware (` RMM `_ ) is loaded by BL2 in the Realm physical address
4848space.
4949
5050The boot flow when RME is enabled looks like the following:
@@ -70,57 +70,85 @@ More information about the GPT library can be found in the
7070RMM Dispatcher (RMMD)
7171************************
7272RMMD is a new standard runtime service that handles the switch to the Realm
73- world. It initializes the RMM and handles Realm Management Interface (RMI)
74- SMC calls from Non-secure and Realm worlds .
73+ world. It initializes the ` RMM `_ and handles Realm Management Interface (RMI)
74+ SMC calls from Non-secure.
7575
76- There is a contract between RMM and RMMD that defines the arguments that the
76+ There is a contract between ` RMM `_ and RMMD that defines the arguments that the
7777former needs to take in order to initialize and also the possible return values.
78- This contract is defined in the RMM Boot Interface, which can be found at
78+ This contract is defined in the ` RMM `_ Boot Interface, which can be found at
7979:ref: `rmm_el3_boot_interface `.
8080
8181There is also a specification of the runtime services provided by TF-A
82- to RMM. This can be found at :ref: `runtime_services_and_interface `.
82+ to ` RMM `_ . This can be found at :ref: `runtime_services_and_interface `.
8383
8484Test Realm Payload (TRP)
8585*************************
8686TRP is a small test payload that runs at R-EL2 and implements a subset of
8787the Realm Management Interface (RMI) commands to primarily test EL3 firmware
8888and the interface between R-EL2 and EL3. When building TF-A with RME enabled,
89- if a path to an RMM image is not provided, TF-A builds the TRP by default
90- and uses it as RMM image .
89+ if the path to an RMM image is not provided, TF-A builds the TRP by default
90+ and uses it as the R-EL2 payload .
9191
9292Building and running TF-A with RME
93- ------------------------------------
93+ ----------------------------------
9494
9595This section describes how you can build and run TF-A with RME enabled.
96- We assume you have all the :ref: `Prerequisites ` to build TF-A.
96+ We assume you have read the :ref: `Prerequisites ` to build TF-A.
9797
9898The following instructions show you how to build and run TF-A with RME
99- for two scenarios:
99+ on FVP for two scenarios:
100100
101- - Three-world execution: TF-A with TF-A Tests or Linux.
101+ - Three-world execution: This is the configuration to use if Secure
102+ world functionality is not needed. TF-A is tested with the following
103+ software entities in each world as listed below:
102104
103- - NS (TF-A Test or Linux ),
105+ - NS Host (RME capable Linux or TF-A Tests ),
104106 - Root (TF-A)
105- - Realm ( RMM or TRP)
107+ - R-EL2 (` RMM `_ or TRP)
106108
107- - Four-world execution: TF-A, Hafnium and TF-A Tests or Linux.
109+ - Four-world execution: This is the configuration to use if both Secure
110+ and Realm world functionality is needed. TF-A is tested with the following
111+ software entities in each world as listed below:
108112
109- - NS (TF-A Test or Linux ),
113+ - NS Host (RME capable Linux or TF-A Tests ),
110114 - Root (TF-A)
111- - Realm ( RMM or TRP)
112- - SPM (Hafnium)
115+ - R-EL2 (` RMM `_ or TRP)
116+ - S-EL2 (Hafnium SPM )
113117
114118To run the tests, you need an FVP model. Please use the :ref: `latest version
115- <Arm Fixed Virtual Platforms (FVP)>` of *FVP_Base_RevC-2xAEMvA * model.
119+ <Arm Fixed Virtual Platforms (FVP)>` of *FVP_Base_RevC-2xAEMvA * model. If NS
120+ Host is Linux, then the below instructions assume that a suitable RME enabled
121+ kernel image and associated root filesystem are available.
116122
117- Three World Testing with TF-A Tests
118- *************************************
123+ Three-world execution
124+ *********************
119125
120- **1. Obtain and build TF-A Tests with Realm Payload **
126+ **1. Clone and build RMM Image **
121127
122- The full set of instructions to setup build host and build options for
123- TF-A-Tests can be found in the `TFTF Getting Started `_.
128+ Please refer to the `RMM Getting Started `_ on how to setup
129+ Host Environment and build `RMM `_. The build commands assume that
130+ an AArch64 toolchain and CMake executable are available in the
131+ shell PATH variable and CROSS_COMPILE variable has been setup
132+ appropriately.
133+
134+ To clone `RMM `_ and build using the default build options for FVP:
135+
136+ .. code :: shell
137+
138+ git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
139+ cd tf-rmm
140+ cmake -DRMM_CONFIG=fvp_defcfg -S . -B build
141+ cmake --build build
142+
143+ This will generate **rmm.img ** in **build/Release ** folder.
144+
145+ **2. Clone and build TF-A Tests with Realm Payload **
146+
147+ This step is only needed if NS Host is TF-A Tests. The full set
148+ of instructions to setup build host and build options for
149+ TF-A-Tests can be found in the `TFTF Getting Started `_. TF-A Tests
150+ can test Realm world with either `RMM `_ or TRP in R-EL2. In the TRP case,
151+ some tests which are not applicable will be skipped.
124152
125153Use the following instructions to build TF-A with `TF-A Tests `_ as the
126154non-secure payload (BL33).
@@ -134,37 +162,23 @@ non-secure payload (BL33).
134162 This produces a TF-A Tests binary (**tftf.bin **) with Realm payload packaged
135163and **sp_layout.json ** in the **build/fvp/debug ** directory.
136164
137- **2. Obtain and build RMM Image **
138-
139- Please refer to the `RMM Getting Started `_ on how to setup
140- Host Environment and build RMM.
141-
142- The below command shows how to build RMM using the default build options for FVP.
143-
144- .. code :: shell
145-
146- git clone --recursive https://git.trustedfirmware.org/TF-RMM/tf-rmm.git
147- cd tf-rmm
148- cmake -DRMM_CONFIG=fvp_defcfg -S . -B build
149- cmake --build build
150-
151- This will generate **rmm.img ** in **build ** folder.
152165
153- **3. Build TF-A **
166+ **3. Build RME Enabled TF-A **
154167
155168The `TF-A Getting Started `_ has the necessary instructions to setup Host
156169machine and build TF-A.
157170
158171To build for RME, set ``ENABLE_RME `` build option to 1 and provide the path to
159- the RMM binary using the ``RMM `` build option.
160- Currently, this feature is only supported for the FVP platform.
172+ the `RMM `_ binary ``rmm.img `` using ``RMM `` build option.
161173
162174.. note ::
163175
164176 ENABLE_RME build option is currently experimental.
165177
166- If the ``RMM `` option is not used, then the Test Realm Payload (TRP) in TF-A
167- will be built and used as the RMM.
178+ .. note ::
179+
180+ If the ``RMM `` option is not specified, TF-A builds the TRP to load and
181+ run at R-EL2.
168182
169183.. code :: shell
170184
@@ -176,16 +190,42 @@ will be built and used as the RMM.
176190 RMM=< path/to/rmm.img> \
177191 FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
178192 DEBUG=1 \
179- BL33=< path/to/tftf.bin> \
193+ BL33=< path/to/bl33> \
194+ all fip
195+
196+ ``BL33 `` can point to a Non Secure Bootloader like UEFI/U-Boot or
197+ the TF-A Tests binary(**tftf.bin **) from the previous step.
198+
199+ This produces **bl1.bin ** and **fip.bin ** binaries in the **build/fvp/debug **
200+ directory.
201+
202+ TF-A can also directly boot Linux kernel on the FVP. The kernel needs to be
203+ `preloaded ` to a suitable memory location and this needs to be specified via
204+ ``PRELOADED_BL33_BASE `` build option. Also TF-A should implement the Linux
205+ kernel register conventions for boot and this can be set using the
206+ ``ARM_LINUX_KERNEL_AS_BL33 `` option.
207+
208+ .. code-block :: shell
209+
210+ cd trusted-firmware-a
211+ make CROSS_COMPILE=aarch64-none-elf- \
212+ PLAT=fvp \
213+ ENABLE_RME=1 \
214+ RMM=< path/to/rmm.img> \
215+ FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
216+ DEBUG=1 \
217+ ARM_LINUX_KERNEL_AS_BL33=1 \
218+ PRELOADED_BL33_BASE=0x84000000 \
180219 all fip
181220
182- This produces **bl1.bin ** and **fip.bin ** binaries in the **build/fvp/debug ** directory.
221+ The above command assumes that the Linux kernel will be placed in FVP
222+ memory at 0x84000000 via suitable FVP option (see the next step).
223+
224+ .. _fvp_3_world_cmd :
183225
184- Running the tests for a 3 world FVP setup
185- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
226+ **4. Running FVP for 3 world setup **
186227
187- Use the following command to run the tests on FVP. TF-A Tests should boot
188- and run the default tests including Realm world tests.
228+ Use the following command to run the tests on FVP.
189229
190230.. code :: shell
191231
@@ -239,9 +279,30 @@ and run the default tests including Realm world tests.
239279 -C cluster1.restriction_on_speculative_execution_aarch32=2 \
240280 -C pctl.startup=0.0.0.0 \
241281 -C bp.smsc_91c111.enabled=1 \
242- -C bp.hostbridge.userNetworking=1
282+ -C bp.hostbridge.userNetworking=1 \
283+ -C bp.virtioblockdevice.image_path=< path/to/rootfs.ext4>
243284
244- The bottom of the output from *uart0 * should look something like the following.
285+ The ``bp.virtioblockdevice.image_path `` option presents the rootfs as a
286+ virtio block device to Linux kernel. It can be ignored if NS Host is
287+ TF-A-Tests or rootfs is accessed by some other mechanism.
288+
289+ If TF-A was built to expect a preloaded Linux kernel, then use the following
290+ FVP argument to load the kernel image at the expected address.
291+
292+ .. code-block :: shell
293+
294+ --data cluster0.cpu0=< path_to_kernel_Image> @0x84000000 \
295+
296+
297+ .. tip ::
298+ Tips to boot and run Linux faster on the FVP :
299+ 1. Set the FVP option ``cache_state_modelled `` to 0.
300+ 2. Disable the CPU Idle driver in Linux either by setting the kernel command line
301+ parameter "cpuidle.off=1" or by disabling the ``CONFIG_CPU_IDLE `` kernel config.
302+
303+ If the NS Host is TF-A-Tests, then the default test suite in TFTF
304+ will execute on the FVP and this includes Realm world tests. The
305+ tail of the output from *uart0 * should look something like the following.
245306
246307.. code-block :: shell
247308
@@ -263,52 +324,19 @@ The bottom of the output from *uart0* should look something like the following.
263324 Passed
264325 ...
265326
266- Building TF-A with RME enabled Linux Kernel
267- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
268-
269- If an RME enabled Linux kernel and filesystem is available for testing,
270- and a suitable NS boot loader is not available, then this option can be used to
271- launch kernel directly after BL31:
272-
273- .. code-block :: shell
274-
275- cd trusted-firmware-a
276- make CROSS_COMPILE=aarch64-none-elf- \
277- PLAT=fvp \
278- ENABLE_RME=1 \
279- RMM=< path/to/rmm.img> \
280- FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
281- DEBUG=1 \
282- ARM_LINUX_KERNEL_AS_BL33=1 \
283- PRELOADED_BL33_BASE=0x84000000 \
284- all fip
285-
286- Boot and run the RME enabled Linux Kernel
287- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
288-
289- Use the following additional arguments to boot the kernel on FVP.
290-
291- .. code-block :: shell
292-
293- --data cluster0.cpu0=< path_to_kernel_Image> @0x84000000 \
294- -C bp.virtioblockdevice.image_path=< path_to_rootfs.ext4>
295-
296- .. tip ::
297-
298- Set the FVP option `cache_state_modelled=0 ` to run Linux based tests much faster.
299-
300- Four-world execution with Hafnium and TF-A Tests
301- *************************************************
327+ Four-world execution
328+ ********************
302329
303330Four-world execution involves software components in each security state: root,
304331secure, realm and non-secure. This section describes how to build TF-A
305332with four-world support.
306333
307- We use TF-A as the root firmware, `Hafnium SPM `_ is the reference Secure world component
308- and the software components for the other 2 worlds (Realm and Non-Secure)
309- are as described in the previous section.
334+ We use TF-A as the root firmware, `Hafnium SPM `_ is the reference Secure world
335+ component running at S-EL2. `RMM `_ can be built as described in previous
336+ section. The examples below assume TF-A-Tests as the NS Host and utilize SPs
337+ from TF-A-Tests.
310338
311- **1. Obtain and build Hafnium **
339+ **1. Obtain and build Hafnium SPM **
312340
313341.. code :: shell
314342
@@ -342,11 +370,12 @@ project/reference submodule
342370 The Hafnium binary should be located at
343371*out/reference/secure_aem_v8a_fvp_clang/hafnium.bin *
344372
345- **2. Build TF-A **
373+ **2. Build RME enabled TF-A with SPM **
346374
347375Build TF-A with RME as well as SPM enabled.
348376
349- Use sp_layout.json previously generated in tf-a-test build.
377+ Use the ``sp_layout.json `` previously generated in TF-A Tests
378+ build to run SP tests.
350379
351380.. code :: shell
352381
@@ -355,7 +384,6 @@ Use sp_layout.json previously generated in tf-a-test build.
355384 ENABLE_RME=1 \
356385 FVP_HW_CONFIG_DTS=fdts/fvp-base-gicv3-psci-1t.dts \
357386 SPD=spmd \
358- SPMD_SPM_AT_SEL2=1 \
359387 BRANCH_PROTECTION=1 \
360388 CTX_INCLUDE_PAUTH_REGS=1 \
361389 DEBUG=1 \
@@ -365,11 +393,11 @@ Use sp_layout.json previously generated in tf-a-test build.
365393 RMM=< path/to/rmm.img> \
366394 all fip
367395
368- Running the tests for a 4 world FVP setup
369- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
396+ **3. Running the FVP for a 4 world setup **
370397
371- Use the following arguments in addition to
372- `Running the tests for a 3 world FVP setup `_ to run tests for 4 world setup.
398+ Use the following arguments in addition to the FVP options mentioned in
399+ :ref: `4. Running FVP for 3 world setup <fvp_3_world_cmd >` to run tests for
400+ 4 world setup.
373401
374402.. code :: shell
375403
@@ -388,4 +416,5 @@ Use the following arguments in addition to
388416.. _TF-A Tests : https://trustedfirmware-a-tests.readthedocs.io/en/latest
389417.. _TFTF Getting Started : https://trustedfirmware-a-tests.readthedocs.io/en/latest/getting_started/index.html
390418.. _Hafnium SPM : https://www.trustedfirmware.org/projects/hafnium
391- .. _RMM Getting Started : https://git.trustedfirmware.org/TF-RMM/tf-rmm.git/tree/docs/getting_started/index.rst
419+ .. _RMM Getting Started : https://tf-rmm.readthedocs.io/en/latest/getting_started/index.html
420+ .. _RMM : https://www.trustedfirmware.org/projects/tf-rmm/
0 commit comments