drtm_poc.rst 5.3 KB

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