blob: 65763da8df3eef6dcca5d7e0386fcf88aa18da92 [file] [log] [blame]
Jamie Fox519cc4b2022-06-07 12:07:28 +01001Runtime Security Subsystem (RSS)
2================================
3
4Introduction
5------------
6
7Runtime Security Subsystem (RSS) is an Arm subsystem that provides a reference
8implementation of the HES Host in the
9`Arm Confidential Compute Architecture (CCA) <https://www.arm.com/architecture/security-features/arm-confidential-compute-architecture>`_.
10It is designed to be integrated into A-profile compute subsystems that implement
11Arm CCA, where it serves as the Root of Trust.
12
13RSS initially boots from immutable code (BL1_1) in its internal ROM, before
14jumping to BL1_2, which is provisioned and hash-locked in RSS OTP. The updatable
15MCUBoot BL2 boot stage is loaded from host system flash into RSS SRAM, where it
16is authenticated. BL2 loads and authenticates the TF-M runtime into RSS SRAM
17from host flash. BL2 is also responsible for loading initial boot code into
18other subsystems within the host.
19
David Vincze8c95d2a2022-01-19 10:11:58 +010020The RSS platform port supports the TF-M Crypto, TF-M Initial Attestation,
21Measured Boot and TF-M Platform services along with the corresponding
22regression tests. It supports the IPC model in multi-core topology with
23Isolation Level 1 and 2.
Jamie Fox519cc4b2022-06-07 12:07:28 +010024
25Building TF-M
26-------------
27
Anton Komlev0dbe8f12022-06-17 16:48:12 +010028Follow the instructions in :doc:`Build instructions </building/tfm_build_instruction>`.
Raef Coles5a6345e2022-09-29 12:39:58 +010029Build TF-M with platform name: `arm/rss/<rss platform name>`
Jamie Fox519cc4b2022-06-07 12:07:28 +010030
Raef Coles5a6345e2022-09-29 12:39:58 +010031For example for building RSS for Total Compute platforms:
32``-DTFM_PLATFORM=arm/rss/tc``
Jamie Fox519cc4b2022-06-07 12:07:28 +010033
34Signing host images
35-------------------
36
37RSS BL2 can load boot images into other subsystems within the host system. It
38expects images to be signed, with the signatures attached to the images in the
39MCUBoot metadata format.
40
41The `imgtool Python package <https://pypi.org/project/imgtool/>`_ can be used to
42sign images in the required format. To sign a host image using the development
43key 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 Coles00f1d202023-04-25 14:34:29 +010052 -H 0x2000 \
Jamie Fox519cc4b2022-06-07 12:07:28 +010053 --pad-header \
54 -S 0x80000 \
55 --pad \
56 --boot-record "HOST" \
57 -L <load address> \
58 <binary infile> \
59 <signed binary outfile>
60
Jamie Foxa1e86022022-07-12 17:58:02 +010061The ``load address`` is the logical address in the RSS memory map to which BL2
62will 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
64subsequent host image to be loaded at an offset of ``0x100000`` from the
65previous image. The RSS ATU should be configured to map these logical addresses
66to the physical addresses in the host system that the images need to be loaded
67to.
Jamie Fox519cc4b2022-06-07 12:07:28 +010068
69For 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
77Running the code
78----------------
79
Raef Coles078f6b02023-07-12 14:38:13 +010080To run the built images, first the ROM image must be created from the bl1_1
81binary and the ROM DMA Initial Command Sequence (ICS).::
82
83 srec_cat \
84 bl1_1.bin -Binary -offset 0x0 \
85 rom_dma_ics.bin -Binary -offset 0x1F000 \
86 -o rom.bin -Binary
87
88Then, the flash image must be created by concatenating the images that are
89output from the build. To create the flash image, the following ``fiptool``
90command should be run. ``fiptool`` documentation can be found `here
Raef Coles00f1d202023-04-25 14:34:29 +010091<https://trustedfirmware-a.readthedocs.io/en/latest/getting_started/tools-build.html?highlight=fiptool#building-and-using-the-fip-tool>`_.
Raef Colescb866c32022-11-30 10:57:18 +000092Note that an up-to-date fiptool that supports the RSS UUIDs must be used.::
93
94 fiptool create \
95 --align 8192 --rss-bl2 bl2_signed.bin \
96 --align 8192 --rss-ns tfm_ns_signed.bin \
97 --align 8192 --rss-s tfm_s_signed.bin \
98 --align 8192 --rss-scp-bl1 <signed Host SCP BL1 image> \
99 --align 8192 --rss-ap-bl1 <signed Host AP BL1 image> \
100 fip.bin
101
102If you already have a ``fip.bin`` containing host firmware images, RSS FIP
103images can be patched in::
104
105 fiptool update --align 8192 --rss-bl2 bl2_signed.bin fip.bin
106 fiptool update --align 8192 --rss-ns tfm_ns.bin fip.bin
107 fiptool update --align 8192 --rss-s tfm_s.bin fip.bin
108
109If XIP mode is enabled, the following ``fiptool`` command should be run to
Raef Coles7763a472022-11-10 17:11:40 +0000110create the flash image::
111
Raef Colescb866c32022-11-30 10:57:18 +0000112 fiptool create \
113 --align 8192 --rss-bl2 bl2_signed.bin \
114 --align 8192 --rss-ns tfm_ns.bin \
115 --align 8192 --rss-s tfm_s.bin \
116 --align 8192 --rss-sic-tables-ns tfm_ns_sic_tables_signed.bin \
117 --align 8192 --rss-sic-tables-s tfm_s_sic_tables_signed.bin \
118 --align 8192 --rss-scp-bl1 <signed Host SCP BL1 image> \
119 --align 8192 --rss-ap-bl1 <signed Host AP BL1 image> \
120 fip.bin
Raef Coles45b4f2a2022-11-10 16:43:39 +0000121
Raef Colescb866c32022-11-30 10:57:18 +0000122Once the FIP is prepared, a host flash image can be created using ``srec_cat``::
Raef Coles45b4f2a2022-11-10 16:43:39 +0000123
124 srec_cat \
Raef Colescb866c32022-11-30 10:57:18 +0000125 fip.bin -Binary -offset 0x0 \
Raef Coles45b4f2a2022-11-10 16:43:39 +0000126 -o host_flash.bin -Binary
127
Raef Colescb866c32022-11-30 10:57:18 +0000128If GPT support is enabled, and a host ``fip.bin`` and ``fip_gpt.bin`` has been
129obtained, RSS images can be inserted by first patching the host FIP and then
130inserting that patched FIP into the GPT image::
131
132 sector_size=$(gdisk -l fip_gpt.bin | grep -i "sector size (logical):" | \
133 sed 's/.*logical): \([0-9]*\) bytes/\1/')
134
135 fip_label=" FIP_A$"
136 fip_start_sector=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $2}')
137 fip_sector_am=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $3 - $2}')
138
139 dd if=fip.bin of=fip_gpt.bin bs=$sector_size seek=$fip_start_sector \
140 count=$fip_sector_am conv=notrunc
141
142 fip_label = " FIP_B$"
143 fip_start_sector = $(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $2}')
144 fip_sector_am = $(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $3 - $2}')
145
146 dd if=fip.bin of=fip_gpt.bin bs=$sector_size seek=$fip_start_sector \
147 count=$fip_sector_am conv=notrunc
148
149To patch a ``fip_gpt.bin`` without having an initial ``fip.bin``, the FIP can be
150extracted from the GPT image using the following commands (and can then be
151patched and reinserted using the above commands)::
152
153 sector_size=$(gdisk -l fip_gpt.bin | grep -i "sector size (logical):" | \
154 sed 's/.*logical): \([0-9]*\) bytes/\1/')
155
156 fip_label=" FIP_A$"
157 fip_start_sector=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $2}')
158 fip_sector_am=$(gdisk -l fip_gpt.bin | grep "$fip_label" | awk '{print $3 - $2}')
159
160 dd if=fip_gpt.bin of=fip.bin bs=$sector_size skip=$fip_start_sector \
161 count=$fip_sector_am conv=notrunc
162
163Once the ``fip_gpt.bin`` is prepared, it is placed at the base of the host flash
164image::
165
166 srec_cat \
167 fip_gpt.bin -Binary -offset 0x0 \
168 -o host_flash.bin -Binary
Jamie Fox519cc4b2022-06-07 12:07:28 +0100169
Raef Coles078f6b02023-07-12 14:38:13 +0100170The RSS ROM binary should be placed in RSS ROM at ``0x11000000`` and the host
Raef Coles00f1d202023-04-25 14:34:29 +0100171flash binary should be placed at the base of the host flash. For the TC
172platform, this is at ``0x80000000``.
Jamie Fox519cc4b2022-06-07 12:07:28 +0100173
174--------------
175
Raef Coles7763a472022-11-10 17:11:40 +0000176*Copyright (c) 2022-2023, Arm Limited. All rights reserved.*