1*91f16700SchasingluluRMM-EL3 Communication interface 2*91f16700Schasinglulu******************************* 3*91f16700Schasinglulu 4*91f16700SchasingluluThis document defines the communication interface between RMM and EL3. 5*91f16700SchasingluluThere are two parts in this interface: the boot interface and the runtime 6*91f16700Schasingluluinterface. 7*91f16700Schasinglulu 8*91f16700SchasingluluThe Boot Interface defines the ABI between EL3 and RMM when the CPU enters 9*91f16700SchasingluluR-EL2 for the first time after boot. The cold boot interface defines the ABI 10*91f16700Schasinglulufor the cold boot path and the warm boot interface defines the same for the 11*91f16700Schasingluluwarm path. 12*91f16700Schasinglulu 13*91f16700SchasingluluThe RMM-EL3 runtime interface defines the ABI for EL3 services which can be 14*91f16700Schasingluluinvoked by RMM as well as the register save-restore convention when handling an 15*91f16700SchasingluluSMC call from NS. 16*91f16700Schasinglulu 17*91f16700SchasingluluThe below sections discuss these interfaces more in detail. 18*91f16700Schasinglulu 19*91f16700Schasinglulu.. _rmm_el3_ifc_versioning: 20*91f16700Schasinglulu 21*91f16700SchasingluluRMM-EL3 Interface versioning 22*91f16700Schasinglulu____________________________ 23*91f16700Schasinglulu 24*91f16700SchasingluluThe RMM Boot and Runtime Interface uses a version number to check 25*91f16700Schasinglulucompatibility with the register arguments passed as part of Boot Interface and 26*91f16700SchasingluluRMM-EL3 runtime interface. 27*91f16700Schasinglulu 28*91f16700SchasingluluThe Boot Manifest, discussed later in section :ref:`rmm_el3_boot_manifest`, 29*91f16700Schasingluluuses a separate version number but with the same scheme. 30*91f16700Schasinglulu 31*91f16700SchasingluluThe version number is a 32-bit type with the following fields: 32*91f16700Schasinglulu 33*91f16700Schasinglulu.. csv-table:: 34*91f16700Schasinglulu :header: "Bits", "Value" 35*91f16700Schasinglulu 36*91f16700Schasinglulu [0:15],``VERSION_MINOR`` 37*91f16700Schasinglulu [16:30],``VERSION_MAJOR`` 38*91f16700Schasinglulu [31],RES0 39*91f16700Schasinglulu 40*91f16700SchasingluluThe version numbers are sequentially increased and the rules for updating them 41*91f16700Schasingluluare explained below: 42*91f16700Schasinglulu 43*91f16700Schasinglulu - ``VERSION_MAJOR``: This value is increased when changes break 44*91f16700Schasinglulu compatibility with previous versions. If the changes 45*91f16700Schasinglulu on the ABI are compatible with the previous one, ``VERSION_MAJOR`` 46*91f16700Schasinglulu remains unchanged. 47*91f16700Schasinglulu 48*91f16700Schasinglulu - ``VERSION_MINOR``: This value is increased on any change that is backwards 49*91f16700Schasinglulu compatible with the previous version. When ``VERSION_MAJOR`` is increased, 50*91f16700Schasinglulu ``VERSION_MINOR`` must be set to 0. 51*91f16700Schasinglulu 52*91f16700Schasinglulu - ``RES0``: Bit 31 of the version number is reserved 0 as to maintain 53*91f16700Schasinglulu consistency with the versioning schemes used in other parts of RMM. 54*91f16700Schasinglulu 55*91f16700SchasingluluThis document specifies the 0.2 version of Boot Interface ABI and RMM-EL3 56*91f16700Schasingluluservices specification and the 0.2 version of the Boot Manifest. 57*91f16700Schasinglulu 58*91f16700Schasinglulu.. _rmm_el3_boot_interface: 59*91f16700Schasinglulu 60*91f16700SchasingluluRMM Boot Interface 61*91f16700Schasinglulu__________________ 62*91f16700Schasinglulu 63*91f16700SchasingluluThis section deals with the Boot Interface part of the specification. 64*91f16700Schasinglulu 65*91f16700SchasingluluOne of the goals of the Boot Interface is to allow EL3 firmware to pass 66*91f16700Schasingluludown into RMM certain platform specific information dynamically. This allows 67*91f16700SchasingluluRMM to be less platform dependent and be more generic across platform 68*91f16700Schasingluluvariations. It also allows RMM to be decoupled from the other boot loader 69*91f16700Schasingluluimages in the boot sequence and remain agnostic of any particular format used 70*91f16700Schasinglulufor configuration files. 71*91f16700Schasinglulu 72*91f16700SchasingluluThe Boot Interface ABI defines a set of register conventions and 73*91f16700Schasinglulualso a memory based manifest file to pass information from EL3 to RMM. The 74*91f16700SchasingluluBoot Manifest and the associated platform data in it can be dynamically created 75*91f16700Schasingluluby EL3 and there is no restriction on how the data can be obtained (e.g by DTB, 76*91f16700Schasingluluhoblist or other). 77*91f16700Schasinglulu 78*91f16700SchasingluluThe register convention and the manifest are versioned separately to manage 79*91f16700Schasinglulufuture enhancements and compatibility. 80*91f16700Schasinglulu 81*91f16700SchasingluluRMM completes the boot by issuing the ``RMM_BOOT_COMPLETE`` SMC (0xC40001CF) 82*91f16700Schasingluluback to EL3. After the RMM has finished the boot process, it can only be 83*91f16700Schasingluluentered from EL3 as part of RMI handling. 84*91f16700Schasinglulu 85*91f16700SchasingluluIf RMM returns an error during boot (in any CPU), then RMM must not be entered 86*91f16700Schasinglulufrom any CPU. 87*91f16700Schasinglulu 88*91f16700Schasinglulu.. _rmm_cold_boot_interface: 89*91f16700Schasinglulu 90*91f16700SchasingluluCold Boot Interface 91*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~ 92*91f16700Schasinglulu 93*91f16700SchasingluluDuring cold boot RMM expects the following register values: 94*91f16700Schasinglulu 95*91f16700Schasinglulu.. csv-table:: 96*91f16700Schasinglulu :header: "Register", "Value" 97*91f16700Schasinglulu :widths: 1, 5 98*91f16700Schasinglulu 99*91f16700Schasinglulu 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*91f16700Schasinglulu x1,Version for this Boot Interface as defined in :ref:`rmm_el3_ifc_versioning`. 101*91f16700Schasinglulu x2,Maximum number of CPUs to be supported at runtime. RMM should ensure that it can support this maximum number. 102*91f16700Schasinglulu 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. 103*91f16700Schasinglulu 104*91f16700SchasingluluDuring cold boot, EL3 firmware needs to allocate a 4KB page that will be 105*91f16700Schasinglulupassed to RMM in x3. This memory will be used as shared buffer for communication 106*91f16700Schasinglulubetween EL3 and RMM. It must be assigned to Realm world and must be mapped with 107*91f16700SchasingluluNormal memory attributes (IWB-OWB-ISH) at EL3. At boot, this memory will be 108*91f16700Schasingluluused to populate the Boot Manifest. Since the Boot Manifest can be accessed by 109*91f16700SchasingluluRMM prior to enabling its MMU, EL3 must ensure that proper cache maintenance 110*91f16700Schasingluluoperations are performed after the Boot Manifest is populated. 111*91f16700Schasinglulu 112*91f16700SchasingluluEL3 should also ensure that this shared buffer is always available for use by RMM 113*91f16700Schasingluluduring the lifetime of the system and that it can be used for runtime 114*91f16700Schasinglulucommunication between RMM and EL3. For example, when RMM invokes attestation 115*91f16700Schasingluluservice commands in EL3, this buffer can be used to exchange data between RMM 116*91f16700Schasingluluand EL3. It is also allowed for RMM to invoke runtime services provided by EL3 117*91f16700Schasingluluutilizing this buffer during the boot phase, prior to return back to EL3 via 118*91f16700SchasingluluRMM_BOOT_COMPLETE SMC. 119*91f16700Schasinglulu 120*91f16700SchasingluluRMM should map this memory page into its Stage 1 page-tables using Normal 121*91f16700Schasinglulumemory attributes. 122*91f16700Schasinglulu 123*91f16700SchasingluluDuring runtime, it is the RMM which initiates any communication with EL3. If that 124*91f16700Schasinglulucommunication requires the use of the shared area, it is expected that RMM needs 125*91f16700Schasingluluto do the necessary concurrency protection to prevent the use of the same buffer 126*91f16700Schasingluluby other PEs. 127*91f16700Schasinglulu 128*91f16700SchasingluluThe following sequence diagram shows how a generic EL3 Firmware would boot RMM. 129*91f16700Schasinglulu 130*91f16700Schasinglulu.. image:: ../resources/diagrams/rmm_cold_boot_generic.png 131*91f16700Schasinglulu 132*91f16700SchasingluluWarm Boot Interface 133*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~ 134*91f16700Schasinglulu 135*91f16700SchasingluluAt warm boot, RMM is already initialized and only some per-CPU initialization 136*91f16700Schasingluluis still pending. The only argument that is required by RMM at this stage is 137*91f16700Schasingluluthe CPU Id, which will be passed through register x0 whilst x1 to x3 are RES0. 138*91f16700SchasingluluThis is summarized in the following table: 139*91f16700Schasinglulu 140*91f16700Schasinglulu.. csv-table:: 141*91f16700Schasinglulu :header: "Register", "Value" 142*91f16700Schasinglulu :widths: 1, 5 143*91f16700Schasinglulu 144*91f16700Schasinglulu 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*91f16700Schasinglulu x1 - x3,RES0 146*91f16700Schasinglulu 147*91f16700SchasingluluBoot error handling and return values 148*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 149*91f16700Schasinglulu 150*91f16700SchasingluluAfter boot up and initialization, RMM returns control back to EL3 through a 151*91f16700Schasinglulu``RMM_BOOT_COMPLETE`` SMC call. The only argument of this SMC call will 152*91f16700Schasinglulube returned in x1 and it will encode a signed integer with the error reason 153*91f16700Schasingluluas per the following table: 154*91f16700Schasinglulu 155*91f16700Schasinglulu.. csv-table:: 156*91f16700Schasinglulu :header: "Error code", "Description", "ID" 157*91f16700Schasinglulu :widths: 2 4 1 158*91f16700Schasinglulu 159*91f16700Schasinglulu ``E_RMM_BOOT_SUCCESS``,Boot successful,0 160*91f16700Schasinglulu ``E_RMM_BOOT_ERR_UNKNOWN``,Unknown error,-1 161*91f16700Schasinglulu ``E_RMM_BOOT_VERSION_NOT_VALID``,Boot Interface version reported by EL3 is not supported by RMM,-2 162*91f16700Schasinglulu ``E_RMM_BOOT_CPUS_OUT_OF_RAGE``,Number of CPUs reported by EL3 larger than maximum supported by RMM,-3 163*91f16700Schasinglulu ``E_RMM_BOOT_CPU_ID_OUT_OF_RAGE``,Current CPU Id is higher or equal than the number of CPUs supported by RMM,-4 164*91f16700Schasinglulu ``E_RMM_BOOT_INVALID_SHARED_BUFFER``,Invalid pointer to shared memory area,-5 165*91f16700Schasinglulu ``E_RMM_BOOT_MANIFEST_VERSION_NOT_SUPPORTED``,Version reported by the Boot Manifest not supported by RMM,-6 166*91f16700Schasinglulu ``E_RMM_BOOT_MANIFEST_DATA_ERROR``,Error parsing core Boot Manifest,-7 167*91f16700Schasinglulu 168*91f16700SchasingluluFor any error detected in RMM during cold or warm boot, RMM will return back to 169*91f16700SchasingluluEL3 using ``RMM_BOOT_COMPLETE`` SMC with an appropriate error code. It is 170*91f16700Schasingluluexpected that EL3 will take necessary action to disable Realm world for further 171*91f16700Schasingluluentry from NS Host on receiving an error. This will be done across all the PEs 172*91f16700Schasingluluin the system so as to present a symmetric view to the NS Host. Any further 173*91f16700Schasingluluwarm boot by any PE should not enter RMM using the warm boot interface. 174*91f16700Schasinglulu 175*91f16700Schasinglulu.. _rmm_el3_boot_manifest: 176*91f16700Schasinglulu 177*91f16700SchasingluluBoot Manifest 178*91f16700Schasinglulu~~~~~~~~~~~~~ 179*91f16700Schasinglulu 180*91f16700SchasingluluDuring cold boot, EL3 Firmware passes a memory Boot Manifest to RMM containing 181*91f16700Schasingluluplatform information. 182*91f16700Schasinglulu 183*91f16700SchasingluluThis Boot Manifest is versioned independently of the Boot Interface, to help 184*91f16700Schasingluluevolve the former independent of the latter. 185*91f16700SchasingluluThe current version for the Boot Manifest is ``v0.2`` and the rules explained 186*91f16700Schasingluluin :ref:`rmm_el3_ifc_versioning` apply on this version as well. 187*91f16700Schasinglulu 188*91f16700SchasingluluThe Boot Manifest v0.2 has the following fields: 189*91f16700Schasinglulu 190*91f16700Schasinglulu - version : Version of the Manifest (v0.2) 191*91f16700Schasinglulu - plat_data : Pointer to the platform specific data and not specified by this 192*91f16700Schasinglulu document. These data are optional and can be NULL. 193*91f16700Schasinglulu - plat_dram : Structure encoding the NS DRAM information on the platform. This 194*91f16700Schasinglulu field is also optional and platform can choose to zero out this structure if 195*91f16700Schasinglulu RMM does not need EL3 to send this information during the boot. 196*91f16700Schasinglulu 197*91f16700SchasingluluFor the current version of the Boot Manifest, the core manifest contains a pointer 198*91f16700Schasingluluto the platform data. EL3 must ensure that the whole Boot Manifest, including 199*91f16700Schasingluluthe platform data, if available, fits inside the RMM EL3 shared buffer. 200*91f16700Schasinglulu 201*91f16700SchasingluluFor the data structure specification of Boot Manifest, refer to 202*91f16700Schasinglulu:ref:`rmm_el3_manifest_struct` 203*91f16700Schasinglulu 204*91f16700Schasinglulu.. _runtime_services_and_interface: 205*91f16700Schasinglulu 206*91f16700SchasingluluRMM-EL3 Runtime Interface 207*91f16700Schasinglulu__________________________ 208*91f16700Schasinglulu 209*91f16700SchasingluluThis section defines the RMM-EL3 runtime interface which specifies the ABI for 210*91f16700SchasingluluEL3 services expected by RMM at runtime as well as the register save and 211*91f16700Schasinglulurestore convention between EL3 and RMM as part of RMI call handling. It is 212*91f16700Schasingluluimportant to note that RMM is allowed to invoke EL3-RMM runtime interface 213*91f16700Schasingluluservices during the boot phase as well. The EL3 runtime service handling must 214*91f16700Schasinglulunot result in a world switch to another world unless specified. Both the RMM 215*91f16700Schasingluluand EL3 are allowed to make suitable optimizations based on this assumption. 216*91f16700Schasinglulu 217*91f16700SchasingluluIf the interface requires the use of memory, then the memory references should 218*91f16700Schasinglulube within the shared buffer communicated as part of the boot interface. See 219*91f16700Schasinglulu:ref:`rmm_cold_boot_interface` for properties of this shared buffer which both 220*91f16700SchasingluluEL3 and RMM must adhere to. 221*91f16700Schasinglulu 222*91f16700SchasingluluRMM-EL3 runtime service return codes 223*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 224*91f16700Schasinglulu 225*91f16700SchasingluluThe return codes from EL3 to RMM is a 32 bit signed integer which encapsulates 226*91f16700Schasingluluerror condition as described in the following table: 227*91f16700Schasinglulu 228*91f16700Schasinglulu.. csv-table:: 229*91f16700Schasinglulu :header: "Error code", "Description", "ID" 230*91f16700Schasinglulu :widths: 2 4 1 231*91f16700Schasinglulu 232*91f16700Schasinglulu ``E_RMM_OK``,No errors detected,0 233*91f16700Schasinglulu ``E_RMM_UNK``,Unknown/Generic error,-1 234*91f16700Schasinglulu ``E_RMM_BAD_ADDR``,The value of an address used as argument was invalid,-2 235*91f16700Schasinglulu ``E_RMM_BAD_PAS``,Incorrect PAS,-3 236*91f16700Schasinglulu ``E_RMM_NOMEM``,Not enough memory to perform an operation,-4 237*91f16700Schasinglulu ``E_RMM_INVAL``,The value of an argument was invalid,-5 238*91f16700Schasinglulu 239*91f16700SchasingluluIf multiple failure conditions are detected in an RMM to EL3 command, then EL3 240*91f16700Schasingluluis allowed to return an error code corresponding to any of the failure 241*91f16700Schasingluluconditions. 242*91f16700Schasinglulu 243*91f16700SchasingluluRMM-EL3 runtime services 244*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~ 245*91f16700Schasinglulu 246*91f16700SchasingluluThe following table summarizes the RMM runtime services that need to be 247*91f16700Schasingluluimplemented by EL3 Firmware. 248*91f16700Schasinglulu 249*91f16700Schasinglulu.. csv-table:: 250*91f16700Schasinglulu :header: "FID", "Command" 251*91f16700Schasinglulu :widths: 2 5 252*91f16700Schasinglulu 253*91f16700Schasinglulu 0xC400018F,``RMM_RMI_REQ_COMPLETE`` 254*91f16700Schasinglulu 0xC40001B0,``RMM_GTSI_DELEGATE`` 255*91f16700Schasinglulu 0xC40001B1,``RMM_GTSI_UNDELEGATE`` 256*91f16700Schasinglulu 0xC40001B2,``RMM_ATTEST_GET_REALM_KEY`` 257*91f16700Schasinglulu 0xC40001B3,``RMM_ATTEST_GET_PLAT_TOKEN`` 258*91f16700Schasinglulu 259*91f16700SchasingluluRMM_RMI_REQ_COMPLETE command 260*91f16700Schasinglulu============================ 261*91f16700Schasinglulu 262*91f16700SchasingluluNotifies the completion of an RMI call to the Non-Secure world. 263*91f16700Schasinglulu 264*91f16700SchasingluluThis call is the only function currently in RMM-EL3 runtime interface which 265*91f16700Schasingluluresults in a world switch to NS. This call is the reply to the original RMI 266*91f16700Schasinglulucall and it is forwarded by EL3 to the NS world. 267*91f16700Schasinglulu 268*91f16700SchasingluluFID 269*91f16700Schasinglulu--- 270*91f16700Schasinglulu 271*91f16700Schasinglulu``0xC400018F`` 272*91f16700Schasinglulu 273*91f16700SchasingluluInput values 274*91f16700Schasinglulu------------ 275*91f16700Schasinglulu 276*91f16700Schasinglulu.. csv-table:: 277*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 278*91f16700Schasinglulu :widths: 1 1 1 1 5 279*91f16700Schasinglulu 280*91f16700Schasinglulu fid,x0,[63:0],UInt64,Command FID 281*91f16700Schasinglulu 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 282*91f16700Schasinglulu 283*91f16700SchasingluluOutput values 284*91f16700Schasinglulu------------- 285*91f16700Schasinglulu 286*91f16700SchasingluluThis call does not return. 287*91f16700Schasinglulu 288*91f16700SchasingluluFailure conditions 289*91f16700Schasinglulu------------------ 290*91f16700Schasinglulu 291*91f16700SchasingluluSince this call does not return to RMM, there is no failure condition which 292*91f16700Schasinglulucan be notified back to RMM. 293*91f16700Schasinglulu 294*91f16700SchasingluluRMM_GTSI_DELEGATE command 295*91f16700Schasinglulu========================= 296*91f16700Schasinglulu 297*91f16700SchasingluluDelegate a memory granule by changing its PAS from Non-Secure to Realm. 298*91f16700Schasinglulu 299*91f16700SchasingluluFID 300*91f16700Schasinglulu--- 301*91f16700Schasinglulu 302*91f16700Schasinglulu``0xC40001B0`` 303*91f16700Schasinglulu 304*91f16700SchasingluluInput values 305*91f16700Schasinglulu------------ 306*91f16700Schasinglulu 307*91f16700Schasinglulu.. csv-table:: 308*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 309*91f16700Schasinglulu :widths: 1 1 1 1 5 310*91f16700Schasinglulu 311*91f16700Schasinglulu fid,x0,[63:0],UInt64,Command FID 312*91f16700Schasinglulu base_pa,x1,[63:0],Address,PA of the start of the granule to be delegated 313*91f16700Schasinglulu 314*91f16700SchasingluluOutput values 315*91f16700Schasinglulu------------- 316*91f16700Schasinglulu 317*91f16700Schasinglulu.. csv-table:: 318*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 319*91f16700Schasinglulu :widths: 1 1 1 2 4 320*91f16700Schasinglulu 321*91f16700Schasinglulu Result,x0,[63:0],Error Code,Command return status 322*91f16700Schasinglulu 323*91f16700SchasingluluFailure conditions 324*91f16700Schasinglulu------------------ 325*91f16700Schasinglulu 326*91f16700SchasingluluThe table below shows all the possible error codes returned in ``Result`` upon 327*91f16700Schasinglulua failure. The errors are ordered by condition check. 328*91f16700Schasinglulu 329*91f16700Schasinglulu.. csv-table:: 330*91f16700Schasinglulu :header: "ID", "Condition" 331*91f16700Schasinglulu :widths: 1 5 332*91f16700Schasinglulu 333*91f16700Schasinglulu ``E_RMM_BAD_ADDR``,``PA`` does not correspond to a valid granule address 334*91f16700Schasinglulu ``E_RMM_BAD_PAS``,The granule pointed by ``PA`` does not belong to Non-Secure PAS 335*91f16700Schasinglulu ``E_RMM_OK``,No errors detected 336*91f16700Schasinglulu 337*91f16700SchasingluluRMM_GTSI_UNDELEGATE command 338*91f16700Schasinglulu=========================== 339*91f16700Schasinglulu 340*91f16700SchasingluluUndelegate a memory granule by changing its PAS from Realm to Non-Secure. 341*91f16700Schasinglulu 342*91f16700SchasingluluFID 343*91f16700Schasinglulu--- 344*91f16700Schasinglulu 345*91f16700Schasinglulu``0xC40001B1`` 346*91f16700Schasinglulu 347*91f16700SchasingluluInput values 348*91f16700Schasinglulu------------ 349*91f16700Schasinglulu 350*91f16700Schasinglulu.. csv-table:: 351*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 352*91f16700Schasinglulu :widths: 1 1 1 1 5 353*91f16700Schasinglulu 354*91f16700Schasinglulu fid,x0,[63:0],UInt64,Command FID 355*91f16700Schasinglulu base_pa,x1,[63:0],Address,PA of the start of the granule to be undelegated 356*91f16700Schasinglulu 357*91f16700SchasingluluOutput values 358*91f16700Schasinglulu------------- 359*91f16700Schasinglulu 360*91f16700Schasinglulu.. csv-table:: 361*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 362*91f16700Schasinglulu :widths: 1 1 1 2 4 363*91f16700Schasinglulu 364*91f16700Schasinglulu Result,x0,[63:0],Error Code,Command return status 365*91f16700Schasinglulu 366*91f16700SchasingluluFailure conditions 367*91f16700Schasinglulu------------------ 368*91f16700Schasinglulu 369*91f16700SchasingluluThe table below shows all the possible error codes returned in ``Result`` upon 370*91f16700Schasinglulua failure. The errors are ordered by condition check. 371*91f16700Schasinglulu 372*91f16700Schasinglulu.. csv-table:: 373*91f16700Schasinglulu :header: "ID", "Condition" 374*91f16700Schasinglulu :widths: 1 5 375*91f16700Schasinglulu 376*91f16700Schasinglulu ``E_RMM_BAD_ADDR``,``PA`` does not correspond to a valid granule address 377*91f16700Schasinglulu ``E_RMM_BAD_PAS``,The granule pointed by ``PA`` does not belong to Realm PAS 378*91f16700Schasinglulu ``E_RMM_OK``,No errors detected 379*91f16700Schasinglulu 380*91f16700SchasingluluRMM_ATTEST_GET_REALM_KEY command 381*91f16700Schasinglulu================================ 382*91f16700Schasinglulu 383*91f16700SchasingluluRetrieve the Realm Attestation Token Signing key from EL3. 384*91f16700Schasinglulu 385*91f16700SchasingluluFID 386*91f16700Schasinglulu--- 387*91f16700Schasinglulu 388*91f16700Schasinglulu``0xC40001B2`` 389*91f16700Schasinglulu 390*91f16700SchasingluluInput values 391*91f16700Schasinglulu------------ 392*91f16700Schasinglulu 393*91f16700Schasinglulu.. csv-table:: 394*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 395*91f16700Schasinglulu :widths: 1 1 1 1 5 396*91f16700Schasinglulu 397*91f16700Schasinglulu fid,x0,[63:0],UInt64,Command FID 398*91f16700Schasinglulu 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 399*91f16700Schasinglulu buf_size,x2,[63:0],Size,Size in bytes of the Realm Attestation Key buffer. ``bufPa + bufSize`` must lie within the shared buffer 400*91f16700Schasinglulu ecc_curve,x3,[63:0],Enum,Type of the elliptic curve to which the requested attestation key belongs to. See :ref:`ecc_curves` 401*91f16700Schasinglulu 402*91f16700SchasingluluOutput values 403*91f16700Schasinglulu------------- 404*91f16700Schasinglulu 405*91f16700Schasinglulu.. csv-table:: 406*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 407*91f16700Schasinglulu :widths: 1 1 1 1 5 408*91f16700Schasinglulu 409*91f16700Schasinglulu Result,x0,[63:0],Error Code,Command return status 410*91f16700Schasinglulu keySize,x1,[63:0],Size,Size of the Realm Attestation Key 411*91f16700Schasinglulu 412*91f16700SchasingluluFailure conditions 413*91f16700Schasinglulu------------------ 414*91f16700Schasinglulu 415*91f16700SchasingluluThe table below shows all the possible error codes returned in ``Result`` upon 416*91f16700Schasinglulua failure. The errors are ordered by condition check. 417*91f16700Schasinglulu 418*91f16700Schasinglulu.. csv-table:: 419*91f16700Schasinglulu :header: "ID", "Condition" 420*91f16700Schasinglulu :widths: 1 5 421*91f16700Schasinglulu 422*91f16700Schasinglulu ``E_RMM_BAD_ADDR``,``PA`` is outside the shared buffer 423*91f16700Schasinglulu ``E_RMM_INVAL``,``PA + BSize`` is outside the shared buffer 424*91f16700Schasinglulu ``E_RMM_INVAL``,``Curve`` is not one of the listed in :ref:`ecc_curves` 425*91f16700Schasinglulu ``E_RMM_UNK``,An unknown error occurred whilst processing the command 426*91f16700Schasinglulu ``E_RMM_OK``,No errors detected 427*91f16700Schasinglulu 428*91f16700Schasinglulu.. _ecc_curves: 429*91f16700Schasinglulu 430*91f16700SchasingluluSupported ECC Curves 431*91f16700Schasinglulu-------------------- 432*91f16700Schasinglulu 433*91f16700Schasinglulu.. csv-table:: 434*91f16700Schasinglulu :header: "ID", "Curve" 435*91f16700Schasinglulu :widths: 1 5 436*91f16700Schasinglulu 437*91f16700Schasinglulu 0,ECC SECP384R1 438*91f16700Schasinglulu 439*91f16700SchasingluluRMM_ATTEST_GET_PLAT_TOKEN command 440*91f16700Schasinglulu================================= 441*91f16700Schasinglulu 442*91f16700SchasingluluRetrieve the Platform Token from EL3. 443*91f16700Schasinglulu 444*91f16700SchasingluluFID 445*91f16700Schasinglulu--- 446*91f16700Schasinglulu 447*91f16700Schasinglulu``0xC40001B3`` 448*91f16700Schasinglulu 449*91f16700SchasingluluInput values 450*91f16700Schasinglulu------------ 451*91f16700Schasinglulu 452*91f16700Schasinglulu.. csv-table:: 453*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 454*91f16700Schasinglulu :widths: 1 1 1 1 5 455*91f16700Schasinglulu 456*91f16700Schasinglulu fid,x0,[63:0],UInt64,Command FID 457*91f16700Schasinglulu buf_pa,x1,[63:0],Address,PA of the platform attestation token. The challenge object is passed in this buffer. The PA must belong to the shared buffer 458*91f16700Schasinglulu buf_size,x2,[63:0],Size,Size in bytes of the platform attestation token buffer. ``bufPa + bufSize`` must lie within the shared buffer 459*91f16700Schasinglulu 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 460*91f16700Schasinglulu 461*91f16700SchasingluluOutput values 462*91f16700Schasinglulu------------- 463*91f16700Schasinglulu 464*91f16700Schasinglulu.. csv-table:: 465*91f16700Schasinglulu :header: "Name", "Register", "Field", "Type", "Description" 466*91f16700Schasinglulu :widths: 1 1 1 1 5 467*91f16700Schasinglulu 468*91f16700Schasinglulu Result,x0,[63:0],Error Code,Command return status 469*91f16700Schasinglulu tokenSize,x1,[63:0],Size,Size of the platform token 470*91f16700Schasinglulu 471*91f16700SchasingluluFailure conditions 472*91f16700Schasinglulu------------------ 473*91f16700Schasinglulu 474*91f16700SchasingluluThe table below shows all the possible error codes returned in ``Result`` upon 475*91f16700Schasinglulua failure. The errors are ordered by condition check. 476*91f16700Schasinglulu 477*91f16700Schasinglulu.. csv-table:: 478*91f16700Schasinglulu :header: "ID", "Condition" 479*91f16700Schasinglulu :widths: 1 5 480*91f16700Schasinglulu 481*91f16700Schasinglulu ``E_RMM_BAD_ADDR``,``PA`` is outside the shared buffer 482*91f16700Schasinglulu ``E_RMM_INVAL``,``PA + BSize`` is outside the shared buffer 483*91f16700Schasinglulu ``E_RMM_INVAL``,``CSize`` does not represent the size of a supported SHA algorithm 484*91f16700Schasinglulu ``E_RMM_UNK``,An unknown error occurred whilst processing the command 485*91f16700Schasinglulu ``E_RMM_OK``,No errors detected 486*91f16700Schasinglulu 487*91f16700SchasingluluRMM-EL3 world switch register save restore convention 488*91f16700Schasinglulu_____________________________________________________ 489*91f16700Schasinglulu 490*91f16700SchasingluluAs part of NS world switch, EL3 is expected to maintain a register context 491*91f16700Schasingluluspecific to each world and will save and restore the registers 492*91f16700Schasingluluappropriately. This section captures the contract between EL3 and RMM on the 493*91f16700Schasingluluregister set to be saved and restored. 494*91f16700Schasinglulu 495*91f16700SchasingluluEL3 must maintain a separate register context for the following: 496*91f16700Schasinglulu 497*91f16700Schasinglulu #. General purpose registers (x0-x30) and ``sp_el0``, ``sp_el2`` stack pointers 498*91f16700Schasinglulu #. 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. 499*91f16700Schasinglulu 500*91f16700SchasingluluAs part of SMC forwarding between the NS world and Realm world, EL3 allows x0-x7 to be passed 501*91f16700Schasingluluas arguments to Realm and x0-x4 to be used for return arguments back to Non Secure. 502*91f16700SchasingluluAs per SMCCCv1.2, x4 must be preserved if not being used as return argument by the SMC function 503*91f16700Schasingluluand it is the responsibility of RMM to preserve this or use this as a return argument. 504*91f16700SchasingluluEL3 will always copy x0-x4 from Realm context to NS Context. 505*91f16700Schasinglulu 506*91f16700SchasingluluEL3 must save and restore the following as part of world switch: 507*91f16700Schasinglulu #. EL2 system registers with the exception of ``zcr_el2`` register. 508*91f16700Schasinglulu #. PAuth key registers (APIA, APIB, APDA, APDB, APGA). 509*91f16700Schasinglulu 510*91f16700SchasingluluEL3 will not save some registers as mentioned in the below list. It is the 511*91f16700Schasingluluresponsibility of RMM to ensure that these are appropriately saved if the 512*91f16700SchasingluluRealm World makes use of them: 513*91f16700Schasinglulu 514*91f16700Schasinglulu #. FP/SIMD registers 515*91f16700Schasinglulu #. SVE registers 516*91f16700Schasinglulu #. SME registers 517*91f16700Schasinglulu #. EL1/0 registers with the exception of PAuth key registers as mentioned above. 518*91f16700Schasinglulu #. zcr_el2 register. 519*91f16700Schasinglulu 520*91f16700SchasingluluIt is essential that EL3 honors this contract to maintain the Confidentiality and integrity 521*91f16700Schasingluluof the Realm world. 522*91f16700Schasinglulu 523*91f16700SchasingluluSMCCC v1.3 allows NS world to specify whether SVE context is in use. In this 524*91f16700Schasinglulucase, RMM could choose to not save the incoming SVE context but must ensure 525*91f16700Schasingluluto clear SVE registers if they have been used in Realm World. The same applies 526*91f16700Schasingluluto SME registers. 527*91f16700Schasinglulu 528*91f16700SchasingluluTypes 529*91f16700Schasinglulu_____ 530*91f16700Schasinglulu 531*91f16700Schasinglulu.. _rmm_el3_manifest_struct: 532*91f16700Schasinglulu 533*91f16700SchasingluluRMM-EL3 Boot Manifest structure 534*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 535*91f16700Schasinglulu 536*91f16700SchasingluluThe RMM-EL3 Boot Manifest v0.2 structure contains platform boot information passed 537*91f16700Schasinglulufrom EL3 to RMM. The size of the Boot Manifest is 40 bytes. 538*91f16700Schasinglulu 539*91f16700SchasingluluThe members of the RMM-EL3 Boot Manifest structure are shown in the following 540*91f16700Schasinglulutable: 541*91f16700Schasinglulu 542*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 543*91f16700Schasinglulu| Name | Offset | Type | Description | 544*91f16700Schasinglulu+===========+========+================+========================================+ 545*91f16700Schasinglulu| version | 0 | uint32_t | Boot Manifest version | 546*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 547*91f16700Schasinglulu| padding | 4 | uint32_t | Reserved, set to 0 | 548*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 549*91f16700Schasinglulu| plat_data | 8 | uintptr_t | Pointer to Platform Data section | 550*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 551*91f16700Schasinglulu| plat_dram | 16 | ns_dram_info | NS DRAM Layout Info structure | 552*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 553*91f16700Schasinglulu 554*91f16700Schasinglulu.. _ns_dram_info_struct: 555*91f16700Schasinglulu 556*91f16700SchasingluluNS DRAM Layout Info structure 557*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 558*91f16700Schasinglulu 559*91f16700SchasingluluNS DRAM Layout Info structure contains information about platform Non-secure 560*91f16700SchasingluluDRAM layout. The members of this structure are shown in the table below: 561*91f16700Schasinglulu 562*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 563*91f16700Schasinglulu| Name | Offset | Type | Description | 564*91f16700Schasinglulu+===========+========+================+========================================+ 565*91f16700Schasinglulu| num_banks | 0 | uint64_t | Number of NS DRAM banks | 566*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 567*91f16700Schasinglulu| banks | 8 | ns_dram_bank * | Pointer to 'ns_dram_bank'[] array | 568*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 569*91f16700Schasinglulu| checksum | 16 | uint64_t | Checksum | 570*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 571*91f16700Schasinglulu 572*91f16700SchasingluluChecksum is calculated as two's complement sum of 'num_banks', 'banks' pointer 573*91f16700Schasingluluand DRAM banks data array pointed by it. 574*91f16700Schasinglulu 575*91f16700Schasinglulu.. _ns_dram_bank_struct: 576*91f16700Schasinglulu 577*91f16700SchasingluluNS DRAM Bank structure 578*91f16700Schasinglulu~~~~~~~~~~~~~~~~~~~~~~ 579*91f16700Schasinglulu 580*91f16700SchasingluluNS DRAM Bank structure contains information about each Non-secure DRAM bank: 581*91f16700Schasinglulu 582*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 583*91f16700Schasinglulu| Name | Offset | Type | Description | 584*91f16700Schasinglulu+===========+========+================+========================================+ 585*91f16700Schasinglulu| base | 0 | uintptr_t | Base address | 586*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 587*91f16700Schasinglulu| size | 8 | uint64_t | Size of bank in bytes | 588*91f16700Schasinglulu+-----------+--------+----------------+----------------------------------------+ 589*91f16700Schasinglulu 590*91f16700Schasinglulu 591*91f16700Schasinglulu 592