Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 1 | Runtime Security Subsystem (RSS) |
| 2 | ================================ |
| 3 | |
| 4 | Introduction |
| 5 | ------------ |
| 6 | |
| 7 | Runtime Security Subsystem (RSS) is an Arm subsystem that provides a reference |
| 8 | implementation of the HES Host in the |
| 9 | `Arm Confidential Compute Architecture (CCA) <https://www.arm.com/architecture/security-features/arm-confidential-compute-architecture>`_. |
| 10 | It is designed to be integrated into A-profile compute subsystems that implement |
| 11 | Arm CCA, where it serves as the Root of Trust. |
| 12 | |
| 13 | RSS initially boots from immutable code (BL1_1) in its internal ROM, before |
| 14 | jumping to BL1_2, which is provisioned and hash-locked in RSS OTP. The updatable |
| 15 | MCUBoot BL2 boot stage is loaded from host system flash into RSS SRAM, where it |
| 16 | is authenticated. BL2 loads and authenticates the TF-M runtime into RSS SRAM |
| 17 | from host flash. BL2 is also responsible for loading initial boot code into |
| 18 | other subsystems within the host. |
| 19 | |
David Vincze | 8c95d2a | 2022-01-19 10:11:58 +0100 | [diff] [blame] | 20 | The RSS platform port supports the TF-M Crypto, TF-M Initial Attestation, |
| 21 | Measured Boot and TF-M Platform services along with the corresponding |
| 22 | regression tests. It supports the IPC model in multi-core topology with |
| 23 | Isolation Level 1 and 2. |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 24 | |
| 25 | Building TF-M |
| 26 | ------------- |
| 27 | |
Anton Komlev | 0dbe8f1 | 2022-06-17 16:48:12 +0100 | [diff] [blame] | 28 | Follow the instructions in :doc:`Build instructions </building/tfm_build_instruction>`. |
Raef Coles | 5a6345e | 2022-09-29 12:39:58 +0100 | [diff] [blame] | 29 | Build TF-M with platform name: `arm/rss/<rss platform name>` |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 30 | |
Raef Coles | 5a6345e | 2022-09-29 12:39:58 +0100 | [diff] [blame] | 31 | For example for building RSS for Total Compute platforms: |
| 32 | ``-DTFM_PLATFORM=arm/rss/tc`` |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 33 | |
| 34 | Signing host images |
| 35 | ------------------- |
| 36 | |
| 37 | RSS BL2 can load boot images into other subsystems within the host system. It |
| 38 | expects images to be signed, with the signatures attached to the images in the |
| 39 | MCUBoot metadata format. |
| 40 | |
| 41 | The `imgtool Python package <https://pypi.org/project/imgtool/>`_ can be used to |
| 42 | sign images in the required format. To sign a host image using the development |
| 43 | key distributed with TF-M, use the following command:: |
| 44 | |
| 45 | imgtool sign \ |
| 46 | -k <TF-M base directory>/bl2/ext/mcuboot/root-RSA-3072.pem \ |
| 47 | --public-key-format full \ |
| 48 | --max-align 8 \ |
| 49 | --align 1 \ |
| 50 | -v "0.0.1" \ |
| 51 | -s 1 \ |
Raef Coles | 00f1d20 | 2023-04-25 14:34:29 +0100 | [diff] [blame] | 52 | -H 0x2000 \ |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 53 | --pad-header \ |
| 54 | -S 0x80000 \ |
| 55 | --pad \ |
| 56 | --boot-record "HOST" \ |
| 57 | -L <load address> \ |
| 58 | <binary infile> \ |
| 59 | <signed binary outfile> |
| 60 | |
Jamie Fox | a1e8602 | 2022-07-12 17:58:02 +0100 | [diff] [blame] | 61 | The ``load address`` is the logical address in the RSS memory map to which BL2 |
| 62 | will load the image. RSS FW expects the first host image to be loaded to address |
| 63 | ``0x70000000`` (the beginning of the RSS ATU host access region), and each |
| 64 | subsequent host image to be loaded at an offset of ``0x100000`` from the |
| 65 | previous image. The RSS ATU should be configured to map these logical addresses |
| 66 | to the physical addresses in the host system that the images need to be loaded |
| 67 | to. |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 68 | |
| 69 | For more information on the ``imgtool`` parameters, see the MCUBoot |
| 70 | `imgtool documentation <https://docs.mcuboot.com/imgtool.html>`_. |
| 71 | |
| 72 | .. warning:: |
| 73 | |
| 74 | The TF-M development key must never be used in production. To generate a |
| 75 | production key, follow the imgtool documentation. |
| 76 | |
| 77 | Running the code |
| 78 | ---------------- |
| 79 | |
Raef Coles | 00f1d20 | 2023-04-25 14:34:29 +0100 | [diff] [blame] | 80 | To run the built images, the flash image must be created by concatenating the |
| 81 | images that are output from the build. To create the flash image, the following |
| 82 | ``fiptool`` command should be run. ``fiptool`` documentation can be found `here |
| 83 | <https://trustedfirmware-a.readthedocs.io/en/latest/getting_started/tools-build.html?highlight=fiptool#building-and-using-the-fip-tool>`_. |
Raef Coles | cb866c3 | 2022-11-30 10:57:18 +0000 | [diff] [blame] | 84 | Note that an up-to-date fiptool that supports the RSS UUIDs must be used.:: |
| 85 | |
| 86 | fiptool create \ |
| 87 | --align 8192 --rss-bl2 bl2_signed.bin \ |
| 88 | --align 8192 --rss-ns tfm_ns_signed.bin \ |
| 89 | --align 8192 --rss-s tfm_s_signed.bin \ |
| 90 | --align 8192 --rss-scp-bl1 <signed Host SCP BL1 image> \ |
| 91 | --align 8192 --rss-ap-bl1 <signed Host AP BL1 image> \ |
| 92 | fip.bin |
| 93 | |
| 94 | If you already have a ``fip.bin`` containing host firmware images, RSS FIP |
| 95 | images can be patched in:: |
| 96 | |
| 97 | fiptool update --align 8192 --rss-bl2 bl2_signed.bin fip.bin |
| 98 | fiptool update --align 8192 --rss-ns tfm_ns.bin fip.bin |
| 99 | fiptool update --align 8192 --rss-s tfm_s.bin fip.bin |
| 100 | |
| 101 | If XIP mode is enabled, the following ``fiptool`` command should be run to |
Raef Coles | 7763a47 | 2022-11-10 17:11:40 +0000 | [diff] [blame] | 102 | create the flash image:: |
| 103 | |
Raef Coles | cb866c3 | 2022-11-30 10:57:18 +0000 | [diff] [blame] | 104 | fiptool create \ |
| 105 | --align 8192 --rss-bl2 bl2_signed.bin \ |
| 106 | --align 8192 --rss-ns tfm_ns.bin \ |
| 107 | --align 8192 --rss-s tfm_s.bin \ |
| 108 | --align 8192 --rss-sic-tables-ns tfm_ns_sic_tables_signed.bin \ |
| 109 | --align 8192 --rss-sic-tables-s tfm_s_sic_tables_signed.bin \ |
| 110 | --align 8192 --rss-scp-bl1 <signed Host SCP BL1 image> \ |
| 111 | --align 8192 --rss-ap-bl1 <signed Host AP BL1 image> \ |
| 112 | fip.bin |
Raef Coles | 45b4f2a | 2022-11-10 16:43:39 +0000 | [diff] [blame] | 113 | |
Raef Coles | cb866c3 | 2022-11-30 10:57:18 +0000 | [diff] [blame] | 114 | Once the FIP is prepared, a host flash image can be created using ``srec_cat``:: |
Raef Coles | 45b4f2a | 2022-11-10 16:43:39 +0000 | [diff] [blame] | 115 | |
| 116 | srec_cat \ |
Raef Coles | cb866c3 | 2022-11-30 10:57:18 +0000 | [diff] [blame] | 117 | fip.bin -Binary -offset 0x0 \ |
Raef Coles | 45b4f2a | 2022-11-10 16:43:39 +0000 | [diff] [blame] | 118 | -o host_flash.bin -Binary |
| 119 | |
Raef Coles | cb866c3 | 2022-11-30 10:57:18 +0000 | [diff] [blame] | 120 | If GPT support is enabled, and a host ``fip.bin`` and ``fip_gpt.bin`` has been |
| 121 | obtained, RSS images can be inserted by first patching the host FIP and then |
| 122 | inserting that patched FIP into the GPT image:: |
| 123 | |
| 124 | sector_size=$(gdisk -l fip_gpt.bin | grep -i "sector size (logical):" | \ |
| 125 | sed 's/.*logical): \([0-9]*\) bytes/\1/') |
| 126 | |
| 127 | fip_label=" FIP_A$" |
| 128 | fip_start_sector=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $2}') |
| 129 | fip_sector_am=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $3 - $2}') |
| 130 | |
| 131 | dd if=fip.bin of=fip_gpt.bin bs=$sector_size seek=$fip_start_sector \ |
| 132 | count=$fip_sector_am conv=notrunc |
| 133 | |
| 134 | fip_label = " FIP_B$" |
| 135 | fip_start_sector = $(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $2}') |
| 136 | fip_sector_am = $(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $3 - $2}') |
| 137 | |
| 138 | dd if=fip.bin of=fip_gpt.bin bs=$sector_size seek=$fip_start_sector \ |
| 139 | count=$fip_sector_am conv=notrunc |
| 140 | |
| 141 | To patch a ``fip_gpt.bin`` without having an initial ``fip.bin``, the FIP can be |
| 142 | extracted from the GPT image using the following commands (and can then be |
| 143 | patched and reinserted using the above commands):: |
| 144 | |
| 145 | sector_size=$(gdisk -l fip_gpt.bin | grep -i "sector size (logical):" | \ |
| 146 | sed 's/.*logical): \([0-9]*\) bytes/\1/') |
| 147 | |
| 148 | fip_label=" FIP_A$" |
| 149 | fip_start_sector=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $2}') |
| 150 | fip_sector_am=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $3 - $2}') |
| 151 | |
| 152 | dd if=fip_gpt.bin of=fip.bin bs=$sector_size skip=$fip_start_sector \ |
| 153 | count=$fip_sector_am conv=notrunc |
| 154 | |
| 155 | Once the ``fip_gpt.bin`` is prepared, it is placed at the base of the host flash |
| 156 | image:: |
| 157 | |
| 158 | srec_cat \ |
| 159 | fip_gpt.bin -Binary -offset 0x0 \ |
| 160 | -o host_flash.bin -Binary |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 161 | |
Raef Coles | 00f1d20 | 2023-04-25 14:34:29 +0100 | [diff] [blame] | 162 | The BL1_1 ROM binary should be placed in RSS ROM at ``0x11000000`` and the host |
| 163 | flash binary should be placed at the base of the host flash. For the TC |
| 164 | platform, this is at ``0x80000000``. |
Jamie Fox | 519cc4b | 2022-06-07 12:07:28 +0100 | [diff] [blame] | 165 | |
| 166 | -------------- |
| 167 | |
Raef Coles | 7763a47 | 2022-11-10 17:11:40 +0000 | [diff] [blame] | 168 | *Copyright (c) 2022-2023, Arm Limited. All rights reserved.* |