Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 1 | RMM-EL3 Communication interface |
| 2 | ******************************* |
| 3 | |
| 4 | This document defines the communication interface between RMM and EL3. |
| 5 | There are two parts in this interface: the boot interface and the runtime |
| 6 | interface. |
| 7 | |
| 8 | The Boot Interface defines the ABI between EL3 and RMM when the CPU enters |
| 9 | R-EL2 for the first time after boot. The cold boot interface defines the ABI |
| 10 | for the cold boot path and the warm boot interface defines the same for the |
| 11 | warm path. |
| 12 | |
| 13 | The RMM-EL3 runtime interface defines the ABI for EL3 services which can be |
| 14 | invoked by RMM as well as the register save-restore convention when handling an |
| 15 | SMC call from NS. |
| 16 | |
| 17 | The below sections discuss these interfaces more in detail. |
| 18 | |
| 19 | .. _rmm_el3_ifc_versioning: |
| 20 | |
| 21 | RMM-EL3 Interface versioning |
| 22 | ____________________________ |
| 23 | |
| 24 | The RMM Boot and Runtime Interface uses a version number to check |
| 25 | compatibility with the register arguments passed as part of Boot Interface and |
| 26 | RMM-EL3 runtime interface. |
| 27 | |
| 28 | The Boot Manifest, discussed later in section :ref:`rmm_el3_boot_manifest`, |
| 29 | uses a separate version number but with the same scheme. |
| 30 | |
| 31 | The version number is a 32-bit type with the following fields: |
| 32 | |
| 33 | .. csv-table:: |
| 34 | :header: "Bits", "Value" |
| 35 | |
| 36 | [0:15],``VERSION_MINOR`` |
| 37 | [16:30],``VERSION_MAJOR`` |
| 38 | [31],RES0 |
| 39 | |
| 40 | The version numbers are sequentially increased and the rules for updating them |
| 41 | are explained below: |
| 42 | |
| 43 | - ``VERSION_MAJOR``: This value is increased when changes break |
| 44 | compatibility with previous versions. If the changes |
| 45 | on the ABI are compatible with the previous one, ``VERSION_MAJOR`` |
| 46 | remains unchanged. |
| 47 | |
| 48 | - ``VERSION_MINOR``: This value is increased on any change that is backwards |
| 49 | compatible with the previous version. When ``VERSION_MAJOR`` is increased, |
| 50 | ``VERSION_MINOR`` must be set to 0. |
| 51 | |
| 52 | - ``RES0``: Bit 31 of the version number is reserved 0 as to maintain |
| 53 | consistency with the versioning schemes used in other parts of RMM. |
| 54 | |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 55 | This document specifies the 0.3 version of Boot Interface ABI and RMM-EL3 |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 56 | services specification and the 0.3 version of the Boot Manifest. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 57 | |
| 58 | .. _rmm_el3_boot_interface: |
| 59 | |
| 60 | RMM Boot Interface |
| 61 | __________________ |
| 62 | |
| 63 | This section deals with the Boot Interface part of the specification. |
| 64 | |
| 65 | One of the goals of the Boot Interface is to allow EL3 firmware to pass |
| 66 | down into RMM certain platform specific information dynamically. This allows |
| 67 | RMM to be less platform dependent and be more generic across platform |
| 68 | variations. It also allows RMM to be decoupled from the other boot loader |
| 69 | images in the boot sequence and remain agnostic of any particular format used |
| 70 | for configuration files. |
| 71 | |
| 72 | The Boot Interface ABI defines a set of register conventions and |
| 73 | also a memory based manifest file to pass information from EL3 to RMM. The |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 74 | Boot Manifest and the associated platform data in it can be dynamically created |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 75 | by EL3 and there is no restriction on how the data can be obtained (e.g by DTB, |
| 76 | hoblist or other). |
| 77 | |
| 78 | The register convention and the manifest are versioned separately to manage |
| 79 | future enhancements and compatibility. |
| 80 | |
| 81 | RMM completes the boot by issuing the ``RMM_BOOT_COMPLETE`` SMC (0xC40001CF) |
| 82 | back to EL3. After the RMM has finished the boot process, it can only be |
| 83 | entered from EL3 as part of RMI handling. |
| 84 | |
| 85 | If RMM returns an error during boot (in any CPU), then RMM must not be entered |
| 86 | from any CPU. |
| 87 | |
| 88 | .. _rmm_cold_boot_interface: |
| 89 | |
| 90 | Cold Boot Interface |
| 91 | ~~~~~~~~~~~~~~~~~~~ |
| 92 | |
| 93 | During cold boot RMM expects the following register values: |
| 94 | |
| 95 | .. csv-table:: |
| 96 | :header: "Register", "Value" |
| 97 | :widths: 1, 5 |
| 98 | |
| 99 | x0,Linear index of this PE. This index starts from 0 and must be less than the maximum number of CPUs to be supported at runtime (see x2). |
| 100 | x1,Version for this Boot Interface as defined in :ref:`rmm_el3_ifc_versioning`. |
| 101 | x2,Maximum number of CPUs to be supported at runtime. RMM should ensure that it can support this maximum number. |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 102 | x3,Base address for the shared buffer used for communication between EL3 firmware and RMM. This buffer must be of 4KB size (1 page). The Boot Manifest must be present at the base of this shared buffer during cold boot. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 103 | |
Javier Almansa Sobrino | 04a6f2f | 2022-12-01 17:20:45 +0000 | [diff] [blame] | 104 | During cold boot, EL3 firmware needs to allocate a 4KB page that will be |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 105 | passed to RMM in x3. This memory will be used as shared buffer for communication |
| 106 | between EL3 and RMM. It must be assigned to Realm world and must be mapped with |
| 107 | Normal memory attributes (IWB-OWB-ISH) at EL3. At boot, this memory will be |
| 108 | used to populate the Boot Manifest. Since the Boot Manifest can be accessed by |
| 109 | RMM prior to enabling its MMU, EL3 must ensure that proper cache maintenance |
| 110 | operations are performed after the Boot Manifest is populated. |
| 111 | |
| 112 | EL3 should also ensure that this shared buffer is always available for use by RMM |
| 113 | during the lifetime of the system and that it can be used for runtime |
| 114 | communication between RMM and EL3. For example, when RMM invokes attestation |
| 115 | service commands in EL3, this buffer can be used to exchange data between RMM |
| 116 | and EL3. It is also allowed for RMM to invoke runtime services provided by EL3 |
| 117 | utilizing this buffer during the boot phase, prior to return back to EL3 via |
| 118 | RMM_BOOT_COMPLETE SMC. |
| 119 | |
| 120 | RMM should map this memory page into its Stage 1 page-tables using Normal |
| 121 | memory attributes. |
| 122 | |
| 123 | During runtime, it is the RMM which initiates any communication with EL3. If that |
| 124 | communication requires the use of the shared area, it is expected that RMM needs |
| 125 | to do the necessary concurrency protection to prevent the use of the same buffer |
| 126 | by other PEs. |
| 127 | |
| 128 | The following sequence diagram shows how a generic EL3 Firmware would boot RMM. |
| 129 | |
| 130 | .. image:: ../resources/diagrams/rmm_cold_boot_generic.png |
| 131 | |
| 132 | Warm Boot Interface |
| 133 | ~~~~~~~~~~~~~~~~~~~ |
| 134 | |
| 135 | At warm boot, RMM is already initialized and only some per-CPU initialization |
| 136 | is still pending. The only argument that is required by RMM at this stage is |
| 137 | the CPU Id, which will be passed through register x0 whilst x1 to x3 are RES0. |
| 138 | This is summarized in the following table: |
| 139 | |
| 140 | .. csv-table:: |
| 141 | :header: "Register", "Value" |
| 142 | :widths: 1, 5 |
| 143 | |
| 144 | x0,Linear index of this PE. This index starts from 0 and must be less than the maximum number of CPUs to be supported at runtime (see x2). |
| 145 | x1 - x3,RES0 |
| 146 | |
| 147 | Boot error handling and return values |
| 148 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 149 | |
| 150 | After boot up and initialization, RMM returns control back to EL3 through a |
| 151 | ``RMM_BOOT_COMPLETE`` SMC call. The only argument of this SMC call will |
| 152 | be returned in x1 and it will encode a signed integer with the error reason |
| 153 | as per the following table: |
| 154 | |
| 155 | .. csv-table:: |
| 156 | :header: "Error code", "Description", "ID" |
| 157 | :widths: 2 4 1 |
| 158 | |
| 159 | ``E_RMM_BOOT_SUCCESS``,Boot successful,0 |
| 160 | ``E_RMM_BOOT_ERR_UNKNOWN``,Unknown error,-1 |
| 161 | ``E_RMM_BOOT_VERSION_NOT_VALID``,Boot Interface version reported by EL3 is not supported by RMM,-2 |
Javier Almansa Sobrino | 7a8e3b4 | 2023-11-30 13:54:44 +0000 | [diff] [blame] | 162 | ``E_RMM_BOOT_CPUS_OUT_OF_RANGE``,Number of CPUs reported by EL3 larger than maximum supported by RMM,-3 |
| 163 | ``E_RMM_BOOT_CPU_ID_OUT_OF_RANGE``,Current CPU Id is higher or equal than the number of CPUs supported by RMM,-4 |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 164 | ``E_RMM_BOOT_INVALID_SHARED_BUFFER``,Invalid pointer to shared memory area,-5 |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 165 | ``E_RMM_BOOT_MANIFEST_VERSION_NOT_SUPPORTED``,Version reported by the Boot Manifest not supported by RMM,-6 |
| 166 | ``E_RMM_BOOT_MANIFEST_DATA_ERROR``,Error parsing core Boot Manifest,-7 |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 167 | |
| 168 | For any error detected in RMM during cold or warm boot, RMM will return back to |
| 169 | EL3 using ``RMM_BOOT_COMPLETE`` SMC with an appropriate error code. It is |
| 170 | expected that EL3 will take necessary action to disable Realm world for further |
| 171 | entry from NS Host on receiving an error. This will be done across all the PEs |
| 172 | in the system so as to present a symmetric view to the NS Host. Any further |
| 173 | warm boot by any PE should not enter RMM using the warm boot interface. |
| 174 | |
| 175 | .. _rmm_el3_boot_manifest: |
| 176 | |
| 177 | Boot Manifest |
| 178 | ~~~~~~~~~~~~~ |
| 179 | |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 180 | During cold boot, EL3 Firmware passes a memory Boot Manifest to RMM containing |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 181 | platform information. |
| 182 | |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 183 | This Boot Manifest is versioned independently of the Boot Interface, to help |
| 184 | evolve the former independent of the latter. |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 185 | The current version for the Boot Manifest is ``v0.3`` and the rules explained |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 186 | in :ref:`rmm_el3_ifc_versioning` apply on this version as well. |
| 187 | |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 188 | The Boot Manifest v0.3 has the following fields: |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 189 | |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 190 | - version : Version of the Manifest (v0.3) |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 191 | - plat_data : Pointer to the platform specific data and not specified by this |
| 192 | document. These data are optional and can be NULL. |
| 193 | - plat_dram : Structure encoding the NS DRAM information on the platform. This |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 194 | field is optional and platform can choose to zero out this structure if |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 195 | RMM does not need EL3 to send this information during the boot. |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 196 | - plat_console : Structure encoding the list of consoles for RMM use on the |
| 197 | platform. This field is optional and platform can choose to not populate |
| 198 | the console list if this is not needed by the RMM for this platform. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 199 | |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 200 | For the current version of the Boot Manifest, the core manifest contains a pointer |
| 201 | to the platform data. EL3 must ensure that the whole Boot Manifest, including |
| 202 | the platform data, if available, fits inside the RMM EL3 shared buffer. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 203 | |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 204 | For the data structure specification of Boot Manifest, refer to |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 205 | :ref:`rmm_el3_manifest_struct` |
| 206 | |
| 207 | .. _runtime_services_and_interface: |
| 208 | |
Javier Almansa Sobrino | f809b16 | 2022-07-04 17:06:36 +0100 | [diff] [blame] | 209 | RMM-EL3 Runtime Interface |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 210 | __________________________ |
| 211 | |
| 212 | This section defines the RMM-EL3 runtime interface which specifies the ABI for |
| 213 | EL3 services expected by RMM at runtime as well as the register save and |
| 214 | restore convention between EL3 and RMM as part of RMI call handling. It is |
| 215 | important to note that RMM is allowed to invoke EL3-RMM runtime interface |
| 216 | services during the boot phase as well. The EL3 runtime service handling must |
| 217 | not result in a world switch to another world unless specified. Both the RMM |
| 218 | and EL3 are allowed to make suitable optimizations based on this assumption. |
| 219 | |
| 220 | If the interface requires the use of memory, then the memory references should |
| 221 | be within the shared buffer communicated as part of the boot interface. See |
| 222 | :ref:`rmm_cold_boot_interface` for properties of this shared buffer which both |
| 223 | EL3 and RMM must adhere to. |
| 224 | |
| 225 | RMM-EL3 runtime service return codes |
| 226 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 227 | |
| 228 | The return codes from EL3 to RMM is a 32 bit signed integer which encapsulates |
| 229 | error condition as described in the following table: |
| 230 | |
| 231 | .. csv-table:: |
| 232 | :header: "Error code", "Description", "ID" |
| 233 | :widths: 2 4 1 |
| 234 | |
| 235 | ``E_RMM_OK``,No errors detected,0 |
| 236 | ``E_RMM_UNK``,Unknown/Generic error,-1 |
| 237 | ``E_RMM_BAD_ADDR``,The value of an address used as argument was invalid,-2 |
| 238 | ``E_RMM_BAD_PAS``,Incorrect PAS,-3 |
| 239 | ``E_RMM_NOMEM``,Not enough memory to perform an operation,-4 |
| 240 | ``E_RMM_INVAL``,The value of an argument was invalid,-5 |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 241 | ``E_RMM_AGAIN``,The resource is busy. Try again.,-6 |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 242 | |
| 243 | If multiple failure conditions are detected in an RMM to EL3 command, then EL3 |
| 244 | is allowed to return an error code corresponding to any of the failure |
| 245 | conditions. |
| 246 | |
| 247 | RMM-EL3 runtime services |
| 248 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
| 249 | |
| 250 | The following table summarizes the RMM runtime services that need to be |
| 251 | implemented by EL3 Firmware. |
| 252 | |
| 253 | .. csv-table:: |
| 254 | :header: "FID", "Command" |
| 255 | :widths: 2 5 |
| 256 | |
Javier Almansa Sobrino | f809b16 | 2022-07-04 17:06:36 +0100 | [diff] [blame] | 257 | 0xC400018F,``RMM_RMI_REQ_COMPLETE`` |
| 258 | 0xC40001B0,``RMM_GTSI_DELEGATE`` |
| 259 | 0xC40001B1,``RMM_GTSI_UNDELEGATE`` |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 260 | 0xC40001B2,``RMM_ATTEST_GET_REALM_KEY`` |
| 261 | 0xC40001B3,``RMM_ATTEST_GET_PLAT_TOKEN`` |
| 262 | |
Javier Almansa Sobrino | f809b16 | 2022-07-04 17:06:36 +0100 | [diff] [blame] | 263 | RMM_RMI_REQ_COMPLETE command |
| 264 | ============================ |
| 265 | |
| 266 | Notifies the completion of an RMI call to the Non-Secure world. |
| 267 | |
| 268 | This call is the only function currently in RMM-EL3 runtime interface which |
| 269 | results in a world switch to NS. This call is the reply to the original RMI |
| 270 | call and it is forwarded by EL3 to the NS world. |
| 271 | |
| 272 | FID |
| 273 | --- |
| 274 | |
| 275 | ``0xC400018F`` |
| 276 | |
| 277 | Input values |
| 278 | ------------ |
| 279 | |
| 280 | .. csv-table:: |
| 281 | :header: "Name", "Register", "Field", "Type", "Description" |
| 282 | :widths: 1 1 1 1 5 |
| 283 | |
| 284 | fid,x0,[63:0],UInt64,Command FID |
| 285 | err_code,x1,[63:0],RmiCommandReturnCode,Error code returned by the RMI service invoked by NS World. See Realm Management Monitor specification for more info |
| 286 | |
| 287 | Output values |
| 288 | ------------- |
| 289 | |
| 290 | This call does not return. |
| 291 | |
| 292 | Failure conditions |
| 293 | ------------------ |
| 294 | |
| 295 | Since this call does not return to RMM, there is no failure condition which |
| 296 | can be notified back to RMM. |
| 297 | |
| 298 | RMM_GTSI_DELEGATE command |
| 299 | ========================= |
| 300 | |
| 301 | Delegate a memory granule by changing its PAS from Non-Secure to Realm. |
| 302 | |
| 303 | FID |
| 304 | --- |
| 305 | |
| 306 | ``0xC40001B0`` |
| 307 | |
| 308 | Input values |
| 309 | ------------ |
| 310 | |
| 311 | .. csv-table:: |
| 312 | :header: "Name", "Register", "Field", "Type", "Description" |
| 313 | :widths: 1 1 1 1 5 |
| 314 | |
| 315 | fid,x0,[63:0],UInt64,Command FID |
| 316 | base_pa,x1,[63:0],Address,PA of the start of the granule to be delegated |
| 317 | |
| 318 | Output values |
| 319 | ------------- |
| 320 | |
| 321 | .. csv-table:: |
| 322 | :header: "Name", "Register", "Field", "Type", "Description" |
| 323 | :widths: 1 1 1 2 4 |
| 324 | |
| 325 | Result,x0,[63:0],Error Code,Command return status |
| 326 | |
| 327 | Failure conditions |
| 328 | ------------------ |
| 329 | |
| 330 | The table below shows all the possible error codes returned in ``Result`` upon |
| 331 | a failure. The errors are ordered by condition check. |
| 332 | |
| 333 | .. csv-table:: |
| 334 | :header: "ID", "Condition" |
| 335 | :widths: 1 5 |
| 336 | |
| 337 | ``E_RMM_BAD_ADDR``,``PA`` does not correspond to a valid granule address |
| 338 | ``E_RMM_BAD_PAS``,The granule pointed by ``PA`` does not belong to Non-Secure PAS |
| 339 | ``E_RMM_OK``,No errors detected |
| 340 | |
| 341 | RMM_GTSI_UNDELEGATE command |
| 342 | =========================== |
| 343 | |
| 344 | Undelegate a memory granule by changing its PAS from Realm to Non-Secure. |
| 345 | |
| 346 | FID |
| 347 | --- |
| 348 | |
| 349 | ``0xC40001B1`` |
| 350 | |
| 351 | Input values |
| 352 | ------------ |
| 353 | |
| 354 | .. csv-table:: |
| 355 | :header: "Name", "Register", "Field", "Type", "Description" |
| 356 | :widths: 1 1 1 1 5 |
| 357 | |
| 358 | fid,x0,[63:0],UInt64,Command FID |
| 359 | base_pa,x1,[63:0],Address,PA of the start of the granule to be undelegated |
| 360 | |
| 361 | Output values |
| 362 | ------------- |
| 363 | |
| 364 | .. csv-table:: |
| 365 | :header: "Name", "Register", "Field", "Type", "Description" |
| 366 | :widths: 1 1 1 2 4 |
| 367 | |
| 368 | Result,x0,[63:0],Error Code,Command return status |
| 369 | |
| 370 | Failure conditions |
| 371 | ------------------ |
| 372 | |
| 373 | The table below shows all the possible error codes returned in ``Result`` upon |
| 374 | a failure. The errors are ordered by condition check. |
| 375 | |
| 376 | .. csv-table:: |
| 377 | :header: "ID", "Condition" |
| 378 | :widths: 1 5 |
| 379 | |
| 380 | ``E_RMM_BAD_ADDR``,``PA`` does not correspond to a valid granule address |
| 381 | ``E_RMM_BAD_PAS``,The granule pointed by ``PA`` does not belong to Realm PAS |
| 382 | ``E_RMM_OK``,No errors detected |
| 383 | |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 384 | RMM_ATTEST_GET_REALM_KEY command |
| 385 | ================================ |
| 386 | |
| 387 | Retrieve the Realm Attestation Token Signing key from EL3. |
| 388 | |
| 389 | FID |
| 390 | --- |
| 391 | |
| 392 | ``0xC40001B2`` |
| 393 | |
| 394 | Input values |
| 395 | ------------ |
| 396 | |
| 397 | .. csv-table:: |
| 398 | :header: "Name", "Register", "Field", "Type", "Description" |
| 399 | :widths: 1 1 1 1 5 |
| 400 | |
| 401 | fid,x0,[63:0],UInt64,Command FID |
| 402 | buf_pa,x1,[63:0],Address,PA where the Realm Attestation Key must be stored by EL3. The PA must belong to the shared buffer |
| 403 | buf_size,x2,[63:0],Size,Size in bytes of the Realm Attestation Key buffer. ``bufPa + bufSize`` must lie within the shared buffer |
| 404 | ecc_curve,x3,[63:0],Enum,Type of the elliptic curve to which the requested attestation key belongs to. See :ref:`ecc_curves` |
| 405 | |
| 406 | Output values |
| 407 | ------------- |
| 408 | |
| 409 | .. csv-table:: |
| 410 | :header: "Name", "Register", "Field", "Type", "Description" |
| 411 | :widths: 1 1 1 1 5 |
| 412 | |
| 413 | Result,x0,[63:0],Error Code,Command return status |
| 414 | keySize,x1,[63:0],Size,Size of the Realm Attestation Key |
| 415 | |
| 416 | Failure conditions |
| 417 | ------------------ |
| 418 | |
| 419 | The table below shows all the possible error codes returned in ``Result`` upon |
| 420 | a failure. The errors are ordered by condition check. |
| 421 | |
| 422 | .. csv-table:: |
| 423 | :header: "ID", "Condition" |
| 424 | :widths: 1 5 |
| 425 | |
| 426 | ``E_RMM_BAD_ADDR``,``PA`` is outside the shared buffer |
| 427 | ``E_RMM_INVAL``,``PA + BSize`` is outside the shared buffer |
| 428 | ``E_RMM_INVAL``,``Curve`` is not one of the listed in :ref:`ecc_curves` |
| 429 | ``E_RMM_UNK``,An unknown error occurred whilst processing the command |
| 430 | ``E_RMM_OK``,No errors detected |
| 431 | |
| 432 | .. _ecc_curves: |
| 433 | |
| 434 | Supported ECC Curves |
| 435 | -------------------- |
| 436 | |
| 437 | .. csv-table:: |
| 438 | :header: "ID", "Curve" |
| 439 | :widths: 1 5 |
| 440 | |
| 441 | 0,ECC SECP384R1 |
| 442 | |
| 443 | RMM_ATTEST_GET_PLAT_TOKEN command |
| 444 | ================================= |
| 445 | |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 446 | Retrieve the Platform Token from EL3. If the entire token does not fit in the |
| 447 | buffer, EL3 returns a hunk of the token (via ``tokenHunkSize`` parameter) and |
| 448 | indicates the remaining bytes that are pending retrieval (via ``remainingSize`` |
| 449 | parameter). The challenge object for the platform token must be populated in |
| 450 | the buffer for the first call of this command and the size of the object is |
| 451 | indicated by ``c_size`` parameter. Subsequent calls to retrieve remaining hunks of |
| 452 | the token must be made with ``c_size`` as 0. |
| 453 | |
| 454 | If ``c_size`` is not 0, this command could cause regeneration of platform token |
| 455 | and will return token hunk corresponding to beginning of the token. |
| 456 | |
| 457 | It is valid for the calls of this command to return ``E_RMM_AGAIN`` error, |
| 458 | which is an indication to the caller to retry this command again. Depending on the |
| 459 | platform, this mechanism can be used to implement queuing to HES, if HES is |
| 460 | involved in platform token generation. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 461 | |
| 462 | FID |
| 463 | --- |
| 464 | |
| 465 | ``0xC40001B3`` |
| 466 | |
| 467 | Input values |
| 468 | ------------ |
| 469 | |
| 470 | .. csv-table:: |
| 471 | :header: "Name", "Register", "Field", "Type", "Description" |
| 472 | :widths: 1 1 1 1 5 |
| 473 | |
| 474 | fid,x0,[63:0],UInt64,Command FID |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 475 | buf_pa,x1,[63:0],Address,"PA of the platform attestation token. The challenge object must be passed in this buffer for the first call of this command. Any subsequent calls, if required to retrieve the full token, should not have this object. The PA must belong to the shared buffer." |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 476 | buf_size,x2,[63:0],Size,Size in bytes of the platform attestation token buffer. ``bufPa + bufSize`` must lie within the shared buffer |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 477 | c_size,x3,[63:0],Size,"Size in bytes of the challenge object. It corresponds to the size of one of the defined SHA algorithms. Any subsequent calls, if required to retrieve the full token, should set this size to 0." |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 478 | |
| 479 | Output values |
| 480 | ------------- |
| 481 | |
| 482 | .. csv-table:: |
| 483 | :header: "Name", "Register", "Field", "Type", "Description" |
| 484 | :widths: 1 1 1 1 5 |
| 485 | |
| 486 | Result,x0,[63:0],Error Code,Command return status |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 487 | tokenHunkSize,x1,[63:0],Size,Size of the platform token hunk retrieved |
| 488 | remainingSize,x2,[63:0],Size,Remaining bytes of the token that are pending retrieval |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 489 | |
| 490 | Failure conditions |
| 491 | ------------------ |
| 492 | |
| 493 | The table below shows all the possible error codes returned in ``Result`` upon |
| 494 | a failure. The errors are ordered by condition check. |
| 495 | |
| 496 | .. csv-table:: |
| 497 | :header: "ID", "Condition" |
| 498 | :widths: 1 5 |
| 499 | |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 500 | ``E_RMM_AGAIN``,Resource for Platform token retrieval is busy. Try again. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 501 | ``E_RMM_BAD_ADDR``,``PA`` is outside the shared buffer |
| 502 | ``E_RMM_INVAL``,``PA + BSize`` is outside the shared buffer |
Juan Pablo Conde | 9b94a42 | 2024-07-10 14:33:42 -0500 | [diff] [blame] | 503 | ``E_RMM_INVAL``,``CSize`` does not represent the size of a supported SHA algorithm for the first call to this command |
| 504 | ``E_RMM_INVAL``,``CSize`` is not 0 for subsequent calls to retrieve remaining hunks of the token |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 505 | ``E_RMM_UNK``,An unknown error occurred whilst processing the command |
| 506 | ``E_RMM_OK``,No errors detected |
| 507 | |
| 508 | RMM-EL3 world switch register save restore convention |
| 509 | _____________________________________________________ |
| 510 | |
| 511 | As part of NS world switch, EL3 is expected to maintain a register context |
| 512 | specific to each world and will save and restore the registers |
| 513 | appropriately. This section captures the contract between EL3 and RMM on the |
| 514 | register set to be saved and restored. |
| 515 | |
| 516 | EL3 must maintain a separate register context for the following: |
| 517 | |
| 518 | #. General purpose registers (x0-x30) and ``sp_el0``, ``sp_el2`` stack pointers |
| 519 | #. EL2 system register context for all enabled features by EL3. These include system registers with the ``_EL2`` prefix. The EL2 physical and virtual timer registers must not be included in this. |
| 520 | |
AlexeiFedorov | 90ce18f | 2022-09-23 16:57:28 +0100 | [diff] [blame] | 521 | As part of SMC forwarding between the NS world and Realm world, EL3 allows x0-x7 to be passed |
| 522 | as arguments to Realm and x0-x4 to be used for return arguments back to Non Secure. |
| 523 | As per SMCCCv1.2, x4 must be preserved if not being used as return argument by the SMC function |
| 524 | and it is the responsibility of RMM to preserve this or use this as a return argument. |
| 525 | EL3 will always copy x0-x4 from Realm context to NS Context. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 526 | |
Shruti Gupta | 3440e56 | 2023-05-15 14:43:57 +0100 | [diff] [blame] | 527 | EL3 must save and restore the following as part of world switch: |
| 528 | #. EL2 system registers with the exception of ``zcr_el2`` register. |
| 529 | #. PAuth key registers (APIA, APIB, APDA, APDB, APGA). |
| 530 | |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 531 | EL3 will not save some registers as mentioned in the below list. It is the |
| 532 | responsibility of RMM to ensure that these are appropriately saved if the |
| 533 | Realm World makes use of them: |
| 534 | |
| 535 | #. FP/SIMD registers |
| 536 | #. SVE registers |
| 537 | #. SME registers |
Shruti Gupta | 3440e56 | 2023-05-15 14:43:57 +0100 | [diff] [blame] | 538 | #. EL1/0 registers with the exception of PAuth key registers as mentioned above. |
| 539 | #. zcr_el2 register. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 540 | |
Shruti Gupta | 3440e56 | 2023-05-15 14:43:57 +0100 | [diff] [blame] | 541 | It is essential that EL3 honors this contract to maintain the Confidentiality and integrity |
| 542 | of the Realm world. |
AlexeiFedorov | 90ce18f | 2022-09-23 16:57:28 +0100 | [diff] [blame] | 543 | |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 544 | SMCCC v1.3 allows NS world to specify whether SVE context is in use. In this |
| 545 | case, RMM could choose to not save the incoming SVE context but must ensure |
| 546 | to clear SVE registers if they have been used in Realm World. The same applies |
| 547 | to SME registers. |
| 548 | |
| 549 | Types |
| 550 | _____ |
| 551 | |
| 552 | .. _rmm_el3_manifest_struct: |
| 553 | |
Javier Almansa Sobrino | 04a6f2f | 2022-12-01 17:20:45 +0000 | [diff] [blame] | 554 | RMM-EL3 Boot Manifest structure |
| 555 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 556 | |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 557 | The RMM-EL3 Boot Manifest v0.3 structure contains platform boot information passed |
| 558 | from EL3 to RMM. The size of the Boot Manifest is 64 bytes. |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 559 | |
| 560 | The members of the RMM-EL3 Boot Manifest structure are shown in the following |
| 561 | table: |
| 562 | |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 563 | +--------------+--------+----------------+----------------------------------------+ |
| 564 | | Name | Offset | Type | Description | |
| 565 | +==============+========+================+========================================+ |
| 566 | | version | 0 | uint32_t | Boot Manifest version | |
| 567 | +--------------+--------+----------------+----------------------------------------+ |
| 568 | | padding | 4 | uint32_t | Reserved, set to 0 | |
| 569 | +--------------+--------+----------------+----------------------------------------+ |
| 570 | | plat_data | 8 | uintptr_t | Pointer to Platform Data section | |
| 571 | +--------------+--------+----------------+----------------------------------------+ |
| 572 | | plat_dram | 16 | ns_dram_info | NS DRAM Layout Info structure | |
| 573 | +--------------+--------+----------------+----------------------------------------+ |
| 574 | | plat_console | 40 | console_list | List of consoles available to RMM | |
| 575 | +--------------+--------+----------------+----------------------------------------+ |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 576 | |
| 577 | .. _ns_dram_info_struct: |
| 578 | |
| 579 | NS DRAM Layout Info structure |
| 580 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 581 | |
| 582 | NS DRAM Layout Info structure contains information about platform Non-secure |
| 583 | DRAM layout. The members of this structure are shown in the table below: |
| 584 | |
| 585 | +-----------+--------+----------------+----------------------------------------+ |
| 586 | | Name | Offset | Type | Description | |
| 587 | +===========+========+================+========================================+ |
| 588 | | num_banks | 0 | uint64_t | Number of NS DRAM banks | |
| 589 | +-----------+--------+----------------+----------------------------------------+ |
| 590 | | banks | 8 | ns_dram_bank * | Pointer to 'ns_dram_bank'[] array | |
| 591 | +-----------+--------+----------------+----------------------------------------+ |
| 592 | | checksum | 16 | uint64_t | Checksum | |
| 593 | +-----------+--------+----------------+----------------------------------------+ |
| 594 | |
| 595 | Checksum is calculated as two's complement sum of 'num_banks', 'banks' pointer |
| 596 | and DRAM banks data array pointed by it. |
| 597 | |
| 598 | .. _ns_dram_bank_struct: |
| 599 | |
| 600 | NS DRAM Bank structure |
| 601 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 602 | |
| 603 | NS DRAM Bank structure contains information about each Non-secure DRAM bank: |
| 604 | |
| 605 | +-----------+--------+----------------+----------------------------------------+ |
| 606 | | Name | Offset | Type | Description | |
| 607 | +===========+========+================+========================================+ |
| 608 | | base | 0 | uintptr_t | Base address | |
| 609 | +-----------+--------+----------------+----------------------------------------+ |
| 610 | | size | 8 | uint64_t | Size of bank in bytes | |
| 611 | +-----------+--------+----------------+----------------------------------------+ |
| 612 | |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 613 | .. _console_list_struct: |
| 614 | |
| 615 | Console List structure |
| 616 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 617 | |
| 618 | Console List structure contains information about the available consoles for RMM. |
| 619 | The members of this structure are shown in the table below: |
| 620 | |
| 621 | +--------------+--------+----------------+----------------------------------------+ |
| 622 | | Name | Offset | Type | Description | |
| 623 | +==============+========+================+========================================+ |
| 624 | | num_consoles | 0 | uint64_t | Number of consoles | |
| 625 | +--------------+--------+----------------+----------------------------------------+ |
| 626 | | consoles | 8 | console_info * | Pointer to 'console_info'[] array | |
| 627 | +--------------+--------+----------------+----------------------------------------+ |
| 628 | | checksum | 16 | uint64_t | Checksum | |
| 629 | +--------------+--------+----------------+----------------------------------------+ |
| 630 | |
| 631 | Checksum is calculated as two's complement sum of 'num_consoles', 'consoles' |
| 632 | pointer and the consoles array pointed by it. |
| 633 | |
| 634 | .. _console_info_struct: |
| 635 | |
| 636 | Console Info structure |
| 637 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 638 | |
| 639 | Console Info structure contains information about each Console available to RMM. |
AlexeiFedorov | 288dad1 | 2023-01-18 14:53:56 +0000 | [diff] [blame] | 640 | |
Harry Moulton | 5ff435e | 2024-03-28 10:16:50 +0000 | [diff] [blame] | 641 | +-----------+--------+---------------+----------------------------------------+ |
| 642 | | Name | Offset | Type | Description | |
| 643 | +===========+========+===============+========================================+ |
| 644 | | base | 0 | uintptr_t | Console Base address | |
| 645 | +-----------+--------+---------------+----------------------------------------+ |
| 646 | | map_pages | 8 | uint64_t | Num of pages to map for console MMIO | |
| 647 | +-----------+--------+---------------+----------------------------------------+ |
| 648 | | name | 16 | char[] | Name of console | |
| 649 | +-----------+--------+---------------+----------------------------------------+ |
| 650 | | clk_in_hz | 24 | uint64_t | UART clock (in hz) for console | |
| 651 | +-----------+--------+---------------+----------------------------------------+ |
| 652 | | baud_rate | 32 | uint64_t | Baud rate | |
| 653 | +-----------+--------+---------------+----------------------------------------+ |
| 654 | | flags | 40 | uint64_t | Additional flags (RES0) | |
| 655 | +-----------+--------+---------------+----------------------------------------+ |
Javier Almansa Sobrino | 37bf69c | 2022-04-07 18:26:49 +0100 | [diff] [blame] | 656 | |