xref: /arm-trusted-firmware/docs/design_documents/drtm_poc.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluDRTM Proof of Concept
2*91f16700Schasinglulu=====================
3*91f16700Schasinglulu
4*91f16700SchasingluluDynamic Root of Trust for Measurement (DRTM) begins a new trust environment
5*91f16700Schasingluluby measuring and executing a protected payload.
6*91f16700Schasinglulu
7*91f16700SchasingluluStatic Root of Trust for Measurement (SRTM)/Measured Boot implementation,
8*91f16700Schasinglulucurrently used by TF-A covers all firmwares, from the boot ROM to the normal
9*91f16700Schasingluluworld bootloader. As a whole, they make up the system's TCB. These boot
10*91f16700Schasinglulumeasurements allow attesting to what software is running on the system and
11*91f16700Schasingluluenable enforcing security policies.
12*91f16700Schasinglulu
13*91f16700SchasingluluAs the boot chain grows or firmware becomes dynamically extensible,
14*91f16700Schasingluluestablishing an attestable TCB becomes more challenging. DRTM  provides a
15*91f16700Schasinglulusolution to this problem by allowing measurement chains to be started at
16*91f16700Schasingluluany time. As these measurements are stored separately from the boot-time
17*91f16700Schasinglulumeasurements, they reduce the size of the TCB, which helps reduce the attack
18*91f16700Schasinglulusurface and the risk of untrusted code executing, which could compromise
19*91f16700Schasingluluthe security of the system.
20*91f16700Schasinglulu
21*91f16700SchasingluluComponents
22*91f16700Schasinglulu~~~~~~~~~~
23*91f16700Schasinglulu
24*91f16700Schasinglulu   - **DCE-Preamble**: The DCE Preamble prepares the platform for DRTM by
25*91f16700Schasinglulu     doing any needed configuration, loading the target payload image(DLME),
26*91f16700Schasinglulu     and preparing input parameters needed by DRTM. Finally, it invokes the
27*91f16700Schasinglulu     DL Event to start the dynamic launch.
28*91f16700Schasinglulu
29*91f16700Schasinglulu   - **D-CRTM**: The D-CRTM is the trust anchor (or root of trust) for the
30*91f16700Schasinglulu     DRTM boot sequence and is where the dynamic launch starts. The D-CRTM
31*91f16700Schasinglulu     must be implemented as a trusted agent in the system. The D-CRTM
32*91f16700Schasinglulu     initializes the TPM for DRTM and prepares the environment for the next
33*91f16700Schasinglulu     stage of DRTM, the DCE. The D-CRTM measures the DCE, verifies its
34*91f16700Schasinglulu     signature, and transfers control to it.
35*91f16700Schasinglulu
36*91f16700Schasinglulu   - **DCE**: The DCE executes on an application core. The DCE verifies the
37*91f16700Schasinglulu     system’s state, measures security-critical attributes of the system,
38*91f16700Schasinglulu     prepares the memory region for the target payload, measures the payload,
39*91f16700Schasinglulu     and finally transfers control to the payload.
40*91f16700Schasinglulu
41*91f16700Schasinglulu   - **DLME**: The protected payload is referred to as the Dynamically Launched
42*91f16700Schasinglulu     Measured Environment, or DLME. The DLME begins execution in a safe state,
43*91f16700Schasinglulu     with a single thread of execution, DMA protections, and interrupts
44*91f16700Schasinglulu     disabled. The DCE provides data to the DLME that it can use to verify the
45*91f16700Schasinglulu     configuration of the system.
46*91f16700Schasinglulu
47*91f16700SchasingluluIn this proof of concept, DCE and D-CRTM are implemented in BL31 and
48*91f16700SchasingluluDCE-Preamble and DLME are implemented in UEFI application. A DL Event is
49*91f16700Schasinglulutriggered as a SMC by DCE-Preamble and handled by D-CRTM, which launches the
50*91f16700SchasingluluDLME via DCE.
51*91f16700Schasinglulu
52*91f16700SchasingluluThis manual provides instructions to build TF-A code with pre-buit EDK2
53*91f16700Schasingluluand DRTM UEFI application.
54*91f16700Schasinglulu
55*91f16700SchasingluluBuilding the PoC for the Arm FVP platform
56*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57*91f16700Schasinglulu
58*91f16700Schasinglulu(1) Use the below command to clone TF-A source code -
59*91f16700Schasinglulu
60*91f16700Schasinglulu.. code:: shell
61*91f16700Schasinglulu
62*91f16700Schasinglulu   $ git clone https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git
63*91f16700Schasinglulu
64*91f16700Schasinglulu(2) There are prebuilt binaries required to execute the DRTM implementation
65*91f16700Schasinglulu    in the `prebuilts-drtm-bins`_.
66*91f16700Schasinglulu    Download EDK2  *FVP_AARCH64_EFI.fd* and UEFI DRTM application *test-disk.img*
67*91f16700Schasinglulu    binary from `prebuilts-drtm-bins`_.
68*91f16700Schasinglulu
69*91f16700Schasinglulu(3) Build the TF-A code using below command
70*91f16700Schasinglulu
71*91f16700Schasinglulu.. code:: shell
72*91f16700Schasinglulu
73*91f16700Schasinglulu   $ make CROSS_COMPILE=aarch64-none-elf- ARM_ROTPK_LOCATION=devel_rsa
74*91f16700Schasinglulu     DEBUG=1 V=1 BL33=</path/to/FVP_AARCH64_EFI.fd> DRTM_SUPPORT=1
75*91f16700Schasinglulu     MBEDTLS_DIR=</path/to/mbedTLS-source> USE_ROMLIB=1 all fip
76*91f16700Schasinglulu
77*91f16700SchasingluluRunning DRTM UEFI application on the Armv8-A AEM FVP
78*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79*91f16700SchasingluluTo run the DRTM test application along with DRTM implementation in BL31,
80*91f16700Schasingluluyou need an FVP model. Please use the version of FVP_Base_RevC-2xAEMvA model
81*91f16700Schasingluluadvertised in the TF-A documentation.
82*91f16700Schasinglulu
83*91f16700Schasinglulu.. code:: shell
84*91f16700Schasinglulu
85*91f16700Schasinglulu    FVP_Base_RevC-2xAEMvA \
86*91f16700Schasinglulu    --data cluster0.cpu0=</path/to/romlib.bin>@0x03ff2000 \
87*91f16700Schasinglulu    --stat \
88*91f16700Schasinglulu    -C bp.flashloader0.fname=<path/to/fip.bin> \
89*91f16700Schasinglulu    -C bp.secureflashloader.fname=<path/to/bl1.bin> \
90*91f16700Schasinglulu    -C bp.ve_sysregs.exit_on_shutdown=1 \
91*91f16700Schasinglulu    -C bp.virtioblockdevice.image_path=<path/to/test-disk.img> \
92*91f16700Schasinglulu    -C cache_state_modelled=1 \
93*91f16700Schasinglulu    -C cluster0.check_memory_attributes=0 \
94*91f16700Schasinglulu    -C cluster0.cpu0.etm-present=0 \
95*91f16700Schasinglulu    -C cluster0.cpu1.etm-present=0 \
96*91f16700Schasinglulu    -C cluster0.cpu2.etm-present=0 \
97*91f16700Schasinglulu    -C cluster0.cpu3.etm-present=0 \
98*91f16700Schasinglulu    -C cluster0.stage12_tlb_size=1024 \
99*91f16700Schasinglulu    -C cluster1.check_memory_attributes=0 \
100*91f16700Schasinglulu    -C cluster1.cpu0.etm-present=0 \
101*91f16700Schasinglulu    -C cluster1.cpu1.etm-present=0 \
102*91f16700Schasinglulu    -C cluster1.cpu2.etm-present=0 \
103*91f16700Schasinglulu    -C cluster1.cpu3.etm-present=0 \
104*91f16700Schasinglulu    -C cluster1.stage12_tlb_size=1024 \
105*91f16700Schasinglulu    -C pctl.startup=0.0.0.0 \
106*91f16700Schasinglulu    -Q 1000 \
107*91f16700Schasinglulu    "$@"
108*91f16700Schasinglulu
109*91f16700SchasingluluThe bottom of the output from *uart1* should look something like the
110*91f16700Schasinglulufollowing to indicate that the last SMC to unprotect memory has been fired
111*91f16700Schasinglulusuccessfully.
112*91f16700Schasinglulu
113*91f16700Schasinglulu.. code-block:: shell
114*91f16700Schasinglulu
115*91f16700Schasinglulu ...
116*91f16700Schasinglulu
117*91f16700Schasinglulu INFO:    DRTM service handler: version
118*91f16700Schasinglulu INFO:    ++ DRTM service handler: TPM features
119*91f16700Schasinglulu INFO:    ++ DRTM service handler: Min. mem. requirement features
120*91f16700Schasinglulu INFO:    ++ DRTM service handler: DMA protection features
121*91f16700Schasinglulu INFO:    ++ DRTM service handler: Boot PE ID features
122*91f16700Schasinglulu INFO:    ++ DRTM service handler: TCB-hashes features
123*91f16700Schasinglulu INFO:    DRTM service handler: dynamic launch
124*91f16700Schasinglulu WARNING: DRTM service handler: close locality is not supported
125*91f16700Schasinglulu INFO:    DRTM service handler: unprotect mem
126*91f16700Schasinglulu
127*91f16700Schasinglulu--------------
128*91f16700Schasinglulu
129*91f16700Schasinglulu*Copyright (c) 2022, Arm Limited. All rights reserved.*
130*91f16700Schasinglulu
131*91f16700Schasinglulu.. _prebuilts-drtm-bins: https://downloads.trustedfirmware.org/tf-a/drtm
132*91f16700Schasinglulu.. _DRTM-specification: https://developer.arm.com/documentation/den0113/a
133