169447290SJavier Almansa SobrinoRMM-EL3 Communication interface 269447290SJavier Almansa Sobrino******************************* 369447290SJavier Almansa Sobrino 469447290SJavier Almansa SobrinoThis document defines the communication interface between RMM and EL3. 569447290SJavier Almansa SobrinoThere are two parts in this interface: the boot interface and the runtime 669447290SJavier Almansa Sobrinointerface. 769447290SJavier Almansa Sobrino 869447290SJavier Almansa SobrinoThe Boot Interface defines the ABI between EL3 and RMM when the CPU enters 969447290SJavier Almansa SobrinoR-EL2 for the first time after boot. The cold boot interface defines the ABI 1069447290SJavier Almansa Sobrinofor the cold boot path and the warm boot interface defines the same for the 1169447290SJavier Almansa Sobrinowarm path. 1269447290SJavier Almansa Sobrino 1369447290SJavier Almansa SobrinoThe RMM-EL3 runtime interface defines the ABI for EL3 services which can be 1469447290SJavier Almansa Sobrinoinvoked by RMM as well as the register save-restore convention when handling an 1569447290SJavier Almansa SobrinoSMC call from NS. 1669447290SJavier Almansa Sobrino 1769447290SJavier Almansa SobrinoThe below sections discuss these interfaces more in detail. 1869447290SJavier Almansa Sobrino 1969447290SJavier Almansa Sobrino.. _rmm_el3_ifc_versioning: 2069447290SJavier Almansa Sobrino 2169447290SJavier Almansa SobrinoRMM-EL3 Interface versioning 2269447290SJavier Almansa Sobrino____________________________ 2369447290SJavier Almansa Sobrino 2469447290SJavier Almansa SobrinoThe RMM Boot and Runtime Interface uses a version number to check 2569447290SJavier Almansa Sobrinocompatibility with the register arguments passed as part of Boot Interface and 2669447290SJavier Almansa SobrinoRMM-EL3 runtime interface. 2769447290SJavier Almansa Sobrino 2869447290SJavier Almansa SobrinoThe Boot Manifest, discussed later in section :ref:`rmm_el3_boot_manifest`, 2969447290SJavier Almansa Sobrinouses a separate version number but with the same scheme. 3069447290SJavier Almansa Sobrino 3169447290SJavier Almansa SobrinoThe version number is a 32-bit type with the following fields: 3269447290SJavier Almansa Sobrino 3369447290SJavier Almansa Sobrino.. csv-table:: 3469447290SJavier Almansa Sobrino :header: "Bits", "Value" 3569447290SJavier Almansa Sobrino 3669447290SJavier Almansa Sobrino [0:15],``VERSION_MINOR`` 3769447290SJavier Almansa Sobrino [16:30],``VERSION_MAJOR`` 3869447290SJavier Almansa Sobrino [31],RES0 3969447290SJavier Almansa Sobrino 4069447290SJavier Almansa SobrinoThe version numbers are sequentially increased and the rules for updating them 4169447290SJavier Almansa Sobrinoare explained below: 4269447290SJavier Almansa Sobrino 4369447290SJavier Almansa Sobrino - ``VERSION_MAJOR``: This value is increased when changes break 4469447290SJavier Almansa Sobrino compatibility with previous versions. If the changes 4569447290SJavier Almansa Sobrino on the ABI are compatible with the previous one, ``VERSION_MAJOR`` 4669447290SJavier Almansa Sobrino remains unchanged. 4769447290SJavier Almansa Sobrino 4869447290SJavier Almansa Sobrino - ``VERSION_MINOR``: This value is increased on any change that is backwards 4969447290SJavier Almansa Sobrino compatible with the previous version. When ``VERSION_MAJOR`` is increased, 5069447290SJavier Almansa Sobrino ``VERSION_MINOR`` must be set to 0. 5169447290SJavier Almansa Sobrino 5269447290SJavier Almansa Sobrino - ``RES0``: Bit 31 of the version number is reserved 0 as to maintain 5369447290SJavier Almansa Sobrino consistency with the versioning schemes used in other parts of RMM. 5469447290SJavier Almansa Sobrino 55*13cc1aa7SShruti GuptaThis document specifies the 0.2 version of Boot Interface ABI and RMM-EL3 561db295cfSAlexeiFedorovservices specification and the 0.2 version of the Boot Manifest. 5769447290SJavier Almansa Sobrino 5869447290SJavier Almansa Sobrino.. _rmm_el3_boot_interface: 5969447290SJavier Almansa Sobrino 6069447290SJavier Almansa SobrinoRMM Boot Interface 6169447290SJavier Almansa Sobrino__________________ 6269447290SJavier Almansa Sobrino 6369447290SJavier Almansa SobrinoThis section deals with the Boot Interface part of the specification. 6469447290SJavier Almansa Sobrino 6569447290SJavier Almansa SobrinoOne of the goals of the Boot Interface is to allow EL3 firmware to pass 6669447290SJavier Almansa Sobrinodown into RMM certain platform specific information dynamically. This allows 6769447290SJavier Almansa SobrinoRMM to be less platform dependent and be more generic across platform 6869447290SJavier Almansa Sobrinovariations. It also allows RMM to be decoupled from the other boot loader 6969447290SJavier Almansa Sobrinoimages in the boot sequence and remain agnostic of any particular format used 7069447290SJavier Almansa Sobrinofor configuration files. 7169447290SJavier Almansa Sobrino 7269447290SJavier Almansa SobrinoThe Boot Interface ABI defines a set of register conventions and 7369447290SJavier Almansa Sobrinoalso a memory based manifest file to pass information from EL3 to RMM. The 741db295cfSAlexeiFedorovBoot Manifest and the associated platform data in it can be dynamically created 7569447290SJavier Almansa Sobrinoby EL3 and there is no restriction on how the data can be obtained (e.g by DTB, 7669447290SJavier Almansa Sobrinohoblist or other). 7769447290SJavier Almansa Sobrino 7869447290SJavier Almansa SobrinoThe register convention and the manifest are versioned separately to manage 7969447290SJavier Almansa Sobrinofuture enhancements and compatibility. 8069447290SJavier Almansa Sobrino 8169447290SJavier Almansa SobrinoRMM completes the boot by issuing the ``RMM_BOOT_COMPLETE`` SMC (0xC40001CF) 8269447290SJavier Almansa Sobrinoback to EL3. After the RMM has finished the boot process, it can only be 8369447290SJavier Almansa Sobrinoentered from EL3 as part of RMI handling. 8469447290SJavier Almansa Sobrino 8569447290SJavier Almansa SobrinoIf RMM returns an error during boot (in any CPU), then RMM must not be entered 8669447290SJavier Almansa Sobrinofrom any CPU. 8769447290SJavier Almansa Sobrino 8869447290SJavier Almansa Sobrino.. _rmm_cold_boot_interface: 8969447290SJavier Almansa Sobrino 9069447290SJavier Almansa SobrinoCold Boot Interface 9169447290SJavier Almansa Sobrino~~~~~~~~~~~~~~~~~~~ 9269447290SJavier Almansa Sobrino 9369447290SJavier Almansa SobrinoDuring cold boot RMM expects the following register values: 9469447290SJavier Almansa Sobrino 9569447290SJavier Almansa Sobrino.. csv-table:: 9669447290SJavier Almansa Sobrino :header: "Register", "Value" 9769447290SJavier Almansa Sobrino :widths: 1, 5 9869447290SJavier Almansa Sobrino 9969447290SJavier Almansa Sobrino 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). 10069447290SJavier Almansa Sobrino x1,Version for this Boot Interface as defined in :ref:`rmm_el3_ifc_versioning`. 10169447290SJavier Almansa Sobrino x2,Maximum number of CPUs to be supported at runtime. RMM should ensure that it can support this maximum number. 1021db295cfSAlexeiFedorov 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. 10369447290SJavier Almansa Sobrino 104dc0ca64eSJavier Almansa SobrinoDuring cold boot, EL3 firmware needs to allocate a 4KB page that will be 10569447290SJavier Almansa Sobrinopassed to RMM in x3. This memory will be used as shared buffer for communication 10669447290SJavier Almansa Sobrinobetween EL3 and RMM. It must be assigned to Realm world and must be mapped with 10769447290SJavier Almansa SobrinoNormal memory attributes (IWB-OWB-ISH) at EL3. At boot, this memory will be 10869447290SJavier Almansa Sobrinoused to populate the Boot Manifest. Since the Boot Manifest can be accessed by 10969447290SJavier Almansa SobrinoRMM prior to enabling its MMU, EL3 must ensure that proper cache maintenance 11069447290SJavier Almansa Sobrinooperations are performed after the Boot Manifest is populated. 11169447290SJavier Almansa Sobrino 11269447290SJavier Almansa SobrinoEL3 should also ensure that this shared buffer is always available for use by RMM 11369447290SJavier Almansa Sobrinoduring the lifetime of the system and that it can be used for runtime 11469447290SJavier Almansa Sobrinocommunication between RMM and EL3. For example, when RMM invokes attestation 11569447290SJavier Almansa Sobrinoservice commands in EL3, this buffer can be used to exchange data between RMM 11669447290SJavier Almansa Sobrinoand EL3. It is also allowed for RMM to invoke runtime services provided by EL3 11769447290SJavier Almansa Sobrinoutilizing this buffer during the boot phase, prior to return back to EL3 via 11869447290SJavier Almansa SobrinoRMM_BOOT_COMPLETE SMC. 11969447290SJavier Almansa Sobrino 12069447290SJavier Almansa SobrinoRMM should map this memory page into its Stage 1 page-tables using Normal 12169447290SJavier Almansa Sobrinomemory attributes. 12269447290SJavier Almansa Sobrino 12369447290SJavier Almansa SobrinoDuring runtime, it is the RMM which initiates any communication with EL3. If that 12469447290SJavier Almansa Sobrinocommunication requires the use of the shared area, it is expected that RMM needs 12569447290SJavier Almansa Sobrinoto do the necessary concurrency protection to prevent the use of the same buffer 12669447290SJavier Almansa Sobrinoby other PEs. 12769447290SJavier Almansa Sobrino 12869447290SJavier Almansa SobrinoThe following sequence diagram shows how a generic EL3 Firmware would boot RMM. 12969447290SJavier Almansa Sobrino 13069447290SJavier Almansa Sobrino.. image:: ../resources/diagrams/rmm_cold_boot_generic.png 13169447290SJavier Almansa Sobrino 13269447290SJavier Almansa SobrinoWarm Boot Interface 13369447290SJavier Almansa Sobrino~~~~~~~~~~~~~~~~~~~ 13469447290SJavier Almansa Sobrino 13569447290SJavier Almansa SobrinoAt warm boot, RMM is already initialized and only some per-CPU initialization 13669447290SJavier Almansa Sobrinois still pending. The only argument that is required by RMM at this stage is 13769447290SJavier Almansa Sobrinothe CPU Id, which will be passed through register x0 whilst x1 to x3 are RES0. 13869447290SJavier Almansa SobrinoThis is summarized in the following table: 13969447290SJavier Almansa Sobrino 14069447290SJavier Almansa Sobrino.. csv-table:: 14169447290SJavier Almansa Sobrino :header: "Register", "Value" 14269447290SJavier Almansa Sobrino :widths: 1, 5 14369447290SJavier Almansa Sobrino 14469447290SJavier Almansa Sobrino 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). 14569447290SJavier Almansa Sobrino x1 - x3,RES0 14669447290SJavier Almansa Sobrino 14769447290SJavier Almansa SobrinoBoot error handling and return values 14869447290SJavier Almansa Sobrino~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 14969447290SJavier Almansa Sobrino 15069447290SJavier Almansa SobrinoAfter boot up and initialization, RMM returns control back to EL3 through a 15169447290SJavier Almansa Sobrino``RMM_BOOT_COMPLETE`` SMC call. The only argument of this SMC call will 15269447290SJavier Almansa Sobrinobe returned in x1 and it will encode a signed integer with the error reason 15369447290SJavier Almansa Sobrinoas per the following table: 15469447290SJavier Almansa Sobrino 15569447290SJavier Almansa Sobrino.. csv-table:: 15669447290SJavier Almansa Sobrino :header: "Error code", "Description", "ID" 15769447290SJavier Almansa Sobrino :widths: 2 4 1 15869447290SJavier Almansa Sobrino 15969447290SJavier Almansa Sobrino ``E_RMM_BOOT_SUCCESS``,Boot successful,0 16069447290SJavier Almansa Sobrino ``E_RMM_BOOT_ERR_UNKNOWN``,Unknown error,-1 16169447290SJavier Almansa Sobrino ``E_RMM_BOOT_VERSION_NOT_VALID``,Boot Interface version reported by EL3 is not supported by RMM,-2 16269447290SJavier Almansa Sobrino ``E_RMM_BOOT_CPUS_OUT_OF_RAGE``,Number of CPUs reported by EL3 larger than maximum supported by RMM,-3 16369447290SJavier Almansa Sobrino ``E_RMM_BOOT_CPU_ID_OUT_OF_RAGE``,Current CPU Id is higher or equal than the number of CPUs supported by RMM,-4 16469447290SJavier Almansa Sobrino ``E_RMM_BOOT_INVALID_SHARED_BUFFER``,Invalid pointer to shared memory area,-5 1651db295cfSAlexeiFedorov ``E_RMM_BOOT_MANIFEST_VERSION_NOT_SUPPORTED``,Version reported by the Boot Manifest not supported by RMM,-6 1661db295cfSAlexeiFedorov ``E_RMM_BOOT_MANIFEST_DATA_ERROR``,Error parsing core Boot Manifest,-7 16769447290SJavier Almansa Sobrino 16869447290SJavier Almansa SobrinoFor any error detected in RMM during cold or warm boot, RMM will return back to 16969447290SJavier Almansa SobrinoEL3 using ``RMM_BOOT_COMPLETE`` SMC with an appropriate error code. It is 17069447290SJavier Almansa Sobrinoexpected that EL3 will take necessary action to disable Realm world for further 17169447290SJavier Almansa Sobrinoentry from NS Host on receiving an error. This will be done across all the PEs 17269447290SJavier Almansa Sobrinoin the system so as to present a symmetric view to the NS Host. Any further 17369447290SJavier Almansa Sobrinowarm boot by any PE should not enter RMM using the warm boot interface. 17469447290SJavier Almansa Sobrino 17569447290SJavier Almansa Sobrino.. _rmm_el3_boot_manifest: 17669447290SJavier Almansa Sobrino 17769447290SJavier Almansa SobrinoBoot Manifest 17869447290SJavier Almansa Sobrino~~~~~~~~~~~~~ 17969447290SJavier Almansa Sobrino 1801db295cfSAlexeiFedorovDuring cold boot, EL3 Firmware passes a memory Boot Manifest to RMM containing 18169447290SJavier Almansa Sobrinoplatform information. 18269447290SJavier Almansa Sobrino 1831db295cfSAlexeiFedorovThis Boot Manifest is versioned independently of the Boot Interface, to help 1841db295cfSAlexeiFedorovevolve the former independent of the latter. 1851db295cfSAlexeiFedorovThe current version for the Boot Manifest is ``v0.2`` and the rules explained 18669447290SJavier Almansa Sobrinoin :ref:`rmm_el3_ifc_versioning` apply on this version as well. 18769447290SJavier Almansa Sobrino 1881db295cfSAlexeiFedorovThe Boot Manifest v0.2 has the following fields: 18969447290SJavier Almansa Sobrino 1901db295cfSAlexeiFedorov - version : Version of the Manifest (v0.2) 1911db295cfSAlexeiFedorov - plat_data : Pointer to the platform specific data and not specified by this 1921db295cfSAlexeiFedorov document. These data are optional and can be NULL. 1931db295cfSAlexeiFedorov - plat_dram : Structure encoding the NS DRAM information on the platform. This 1941db295cfSAlexeiFedorov field is also optional and platform can choose to zero out this structure if 1951db295cfSAlexeiFedorov RMM does not need EL3 to send this information during the boot. 19669447290SJavier Almansa Sobrino 1971db295cfSAlexeiFedorovFor the current version of the Boot Manifest, the core manifest contains a pointer 1981db295cfSAlexeiFedorovto the platform data. EL3 must ensure that the whole Boot Manifest, including 1991db295cfSAlexeiFedorovthe platform data, if available, fits inside the RMM EL3 shared buffer. 20069447290SJavier Almansa Sobrino 2011db295cfSAlexeiFedorovFor the data structure specification of Boot Manifest, refer to 20269447290SJavier Almansa Sobrino:ref:`rmm_el3_manifest_struct` 20369447290SJavier Almansa Sobrino 20469447290SJavier Almansa Sobrino.. _runtime_services_and_interface: 20569447290SJavier Almansa Sobrino 206e50fedbcSJavier Almansa SobrinoRMM-EL3 Runtime Interface 20769447290SJavier Almansa Sobrino__________________________ 20869447290SJavier Almansa Sobrino 20969447290SJavier Almansa SobrinoThis section defines the RMM-EL3 runtime interface which specifies the ABI for 21069447290SJavier Almansa SobrinoEL3 services expected by RMM at runtime as well as the register save and 21169447290SJavier Almansa Sobrinorestore convention between EL3 and RMM as part of RMI call handling. It is 21269447290SJavier Almansa Sobrinoimportant to note that RMM is allowed to invoke EL3-RMM runtime interface 21369447290SJavier Almansa Sobrinoservices during the boot phase as well. The EL3 runtime service handling must 21469447290SJavier Almansa Sobrinonot result in a world switch to another world unless specified. Both the RMM 21569447290SJavier Almansa Sobrinoand EL3 are allowed to make suitable optimizations based on this assumption. 21669447290SJavier Almansa Sobrino 21769447290SJavier Almansa SobrinoIf the interface requires the use of memory, then the memory references should 21869447290SJavier Almansa Sobrinobe within the shared buffer communicated as part of the boot interface. See 21969447290SJavier Almansa Sobrino:ref:`rmm_cold_boot_interface` for properties of this shared buffer which both 22069447290SJavier Almansa SobrinoEL3 and RMM must adhere to. 22169447290SJavier Almansa Sobrino 22269447290SJavier Almansa SobrinoRMM-EL3 runtime service return codes 22369447290SJavier Almansa Sobrino~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22469447290SJavier Almansa Sobrino 22569447290SJavier Almansa SobrinoThe return codes from EL3 to RMM is a 32 bit signed integer which encapsulates 22669447290SJavier Almansa Sobrinoerror condition as described in the following table: 22769447290SJavier Almansa Sobrino 22869447290SJavier Almansa Sobrino.. csv-table:: 22969447290SJavier Almansa Sobrino :header: "Error code", "Description", "ID" 23069447290SJavier Almansa Sobrino :widths: 2 4 1 23169447290SJavier Almansa Sobrino 23269447290SJavier Almansa Sobrino ``E_RMM_OK``,No errors detected,0 23369447290SJavier Almansa Sobrino ``E_RMM_UNK``,Unknown/Generic error,-1 23469447290SJavier Almansa Sobrino ``E_RMM_BAD_ADDR``,The value of an address used as argument was invalid,-2 23569447290SJavier Almansa Sobrino ``E_RMM_BAD_PAS``,Incorrect PAS,-3 23669447290SJavier Almansa Sobrino ``E_RMM_NOMEM``,Not enough memory to perform an operation,-4 23769447290SJavier Almansa Sobrino ``E_RMM_INVAL``,The value of an argument was invalid,-5 23869447290SJavier Almansa Sobrino 23969447290SJavier Almansa SobrinoIf multiple failure conditions are detected in an RMM to EL3 command, then EL3 24069447290SJavier Almansa Sobrinois allowed to return an error code corresponding to any of the failure 24169447290SJavier Almansa Sobrinoconditions. 24269447290SJavier Almansa Sobrino 24369447290SJavier Almansa SobrinoRMM-EL3 runtime services 24469447290SJavier Almansa Sobrino~~~~~~~~~~~~~~~~~~~~~~~~ 24569447290SJavier Almansa Sobrino 24669447290SJavier Almansa SobrinoThe following table summarizes the RMM runtime services that need to be 24769447290SJavier Almansa Sobrinoimplemented by EL3 Firmware. 24869447290SJavier Almansa Sobrino 24969447290SJavier Almansa Sobrino.. csv-table:: 25069447290SJavier Almansa Sobrino :header: "FID", "Command" 25169447290SJavier Almansa Sobrino :widths: 2 5 25269447290SJavier Almansa Sobrino 253e50fedbcSJavier Almansa Sobrino 0xC400018F,``RMM_RMI_REQ_COMPLETE`` 254e50fedbcSJavier Almansa Sobrino 0xC40001B0,``RMM_GTSI_DELEGATE`` 255e50fedbcSJavier Almansa Sobrino 0xC40001B1,``RMM_GTSI_UNDELEGATE`` 25669447290SJavier Almansa Sobrino 0xC40001B2,``RMM_ATTEST_GET_REALM_KEY`` 25769447290SJavier Almansa Sobrino 0xC40001B3,``RMM_ATTEST_GET_PLAT_TOKEN`` 25869447290SJavier Almansa Sobrino 259e50fedbcSJavier Almansa SobrinoRMM_RMI_REQ_COMPLETE command 260e50fedbcSJavier Almansa Sobrino============================ 261e50fedbcSJavier Almansa Sobrino 262e50fedbcSJavier Almansa SobrinoNotifies the completion of an RMI call to the Non-Secure world. 263e50fedbcSJavier Almansa Sobrino 264e50fedbcSJavier Almansa SobrinoThis call is the only function currently in RMM-EL3 runtime interface which 265e50fedbcSJavier Almansa Sobrinoresults in a world switch to NS. This call is the reply to the original RMI 266e50fedbcSJavier Almansa Sobrinocall and it is forwarded by EL3 to the NS world. 267e50fedbcSJavier Almansa Sobrino 268e50fedbcSJavier Almansa SobrinoFID 269e50fedbcSJavier Almansa Sobrino--- 270e50fedbcSJavier Almansa Sobrino 271e50fedbcSJavier Almansa Sobrino``0xC400018F`` 272e50fedbcSJavier Almansa Sobrino 273e50fedbcSJavier Almansa SobrinoInput values 274e50fedbcSJavier Almansa Sobrino------------ 275e50fedbcSJavier Almansa Sobrino 276e50fedbcSJavier Almansa Sobrino.. csv-table:: 277e50fedbcSJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 278e50fedbcSJavier Almansa Sobrino :widths: 1 1 1 1 5 279e50fedbcSJavier Almansa Sobrino 280e50fedbcSJavier Almansa Sobrino fid,x0,[63:0],UInt64,Command FID 281e50fedbcSJavier Almansa Sobrino 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 282e50fedbcSJavier Almansa Sobrino 283e50fedbcSJavier Almansa SobrinoOutput values 284e50fedbcSJavier Almansa Sobrino------------- 285e50fedbcSJavier Almansa Sobrino 286e50fedbcSJavier Almansa SobrinoThis call does not return. 287e50fedbcSJavier Almansa Sobrino 288e50fedbcSJavier Almansa SobrinoFailure conditions 289e50fedbcSJavier Almansa Sobrino------------------ 290e50fedbcSJavier Almansa Sobrino 291e50fedbcSJavier Almansa SobrinoSince this call does not return to RMM, there is no failure condition which 292e50fedbcSJavier Almansa Sobrinocan be notified back to RMM. 293e50fedbcSJavier Almansa Sobrino 294e50fedbcSJavier Almansa SobrinoRMM_GTSI_DELEGATE command 295e50fedbcSJavier Almansa Sobrino========================= 296e50fedbcSJavier Almansa Sobrino 297e50fedbcSJavier Almansa SobrinoDelegate a memory granule by changing its PAS from Non-Secure to Realm. 298e50fedbcSJavier Almansa Sobrino 299e50fedbcSJavier Almansa SobrinoFID 300e50fedbcSJavier Almansa Sobrino--- 301e50fedbcSJavier Almansa Sobrino 302e50fedbcSJavier Almansa Sobrino``0xC40001B0`` 303e50fedbcSJavier Almansa Sobrino 304e50fedbcSJavier Almansa SobrinoInput values 305e50fedbcSJavier Almansa Sobrino------------ 306e50fedbcSJavier Almansa Sobrino 307e50fedbcSJavier Almansa Sobrino.. csv-table:: 308e50fedbcSJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 309e50fedbcSJavier Almansa Sobrino :widths: 1 1 1 1 5 310e50fedbcSJavier Almansa Sobrino 311e50fedbcSJavier Almansa Sobrino fid,x0,[63:0],UInt64,Command FID 312e50fedbcSJavier Almansa Sobrino base_pa,x1,[63:0],Address,PA of the start of the granule to be delegated 313e50fedbcSJavier Almansa Sobrino 314e50fedbcSJavier Almansa SobrinoOutput values 315e50fedbcSJavier Almansa Sobrino------------- 316e50fedbcSJavier Almansa Sobrino 317e50fedbcSJavier Almansa Sobrino.. csv-table:: 318e50fedbcSJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 319e50fedbcSJavier Almansa Sobrino :widths: 1 1 1 2 4 320e50fedbcSJavier Almansa Sobrino 321e50fedbcSJavier Almansa Sobrino Result,x0,[63:0],Error Code,Command return status 322e50fedbcSJavier Almansa Sobrino 323e50fedbcSJavier Almansa SobrinoFailure conditions 324e50fedbcSJavier Almansa Sobrino------------------ 325e50fedbcSJavier Almansa Sobrino 326e50fedbcSJavier Almansa SobrinoThe table below shows all the possible error codes returned in ``Result`` upon 327e50fedbcSJavier Almansa Sobrinoa failure. The errors are ordered by condition check. 328e50fedbcSJavier Almansa Sobrino 329e50fedbcSJavier Almansa Sobrino.. csv-table:: 330e50fedbcSJavier Almansa Sobrino :header: "ID", "Condition" 331e50fedbcSJavier Almansa Sobrino :widths: 1 5 332e50fedbcSJavier Almansa Sobrino 333e50fedbcSJavier Almansa Sobrino ``E_RMM_BAD_ADDR``,``PA`` does not correspond to a valid granule address 334e50fedbcSJavier Almansa Sobrino ``E_RMM_BAD_PAS``,The granule pointed by ``PA`` does not belong to Non-Secure PAS 335e50fedbcSJavier Almansa Sobrino ``E_RMM_OK``,No errors detected 336e50fedbcSJavier Almansa Sobrino 337e50fedbcSJavier Almansa SobrinoRMM_GTSI_UNDELEGATE command 338e50fedbcSJavier Almansa Sobrino=========================== 339e50fedbcSJavier Almansa Sobrino 340e50fedbcSJavier Almansa SobrinoUndelegate a memory granule by changing its PAS from Realm to Non-Secure. 341e50fedbcSJavier Almansa Sobrino 342e50fedbcSJavier Almansa SobrinoFID 343e50fedbcSJavier Almansa Sobrino--- 344e50fedbcSJavier Almansa Sobrino 345e50fedbcSJavier Almansa Sobrino``0xC40001B1`` 346e50fedbcSJavier Almansa Sobrino 347e50fedbcSJavier Almansa SobrinoInput values 348e50fedbcSJavier Almansa Sobrino------------ 349e50fedbcSJavier Almansa Sobrino 350e50fedbcSJavier Almansa Sobrino.. csv-table:: 351e50fedbcSJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 352e50fedbcSJavier Almansa Sobrino :widths: 1 1 1 1 5 353e50fedbcSJavier Almansa Sobrino 354e50fedbcSJavier Almansa Sobrino fid,x0,[63:0],UInt64,Command FID 355e50fedbcSJavier Almansa Sobrino base_pa,x1,[63:0],Address,PA of the start of the granule to be undelegated 356e50fedbcSJavier Almansa Sobrino 357e50fedbcSJavier Almansa SobrinoOutput values 358e50fedbcSJavier Almansa Sobrino------------- 359e50fedbcSJavier Almansa Sobrino 360e50fedbcSJavier Almansa Sobrino.. csv-table:: 361e50fedbcSJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 362e50fedbcSJavier Almansa Sobrino :widths: 1 1 1 2 4 363e50fedbcSJavier Almansa Sobrino 364e50fedbcSJavier Almansa Sobrino Result,x0,[63:0],Error Code,Command return status 365e50fedbcSJavier Almansa Sobrino 366e50fedbcSJavier Almansa SobrinoFailure conditions 367e50fedbcSJavier Almansa Sobrino------------------ 368e50fedbcSJavier Almansa Sobrino 369e50fedbcSJavier Almansa SobrinoThe table below shows all the possible error codes returned in ``Result`` upon 370e50fedbcSJavier Almansa Sobrinoa failure. The errors are ordered by condition check. 371e50fedbcSJavier Almansa Sobrino 372e50fedbcSJavier Almansa Sobrino.. csv-table:: 373e50fedbcSJavier Almansa Sobrino :header: "ID", "Condition" 374e50fedbcSJavier Almansa Sobrino :widths: 1 5 375e50fedbcSJavier Almansa Sobrino 376e50fedbcSJavier Almansa Sobrino ``E_RMM_BAD_ADDR``,``PA`` does not correspond to a valid granule address 377e50fedbcSJavier Almansa Sobrino ``E_RMM_BAD_PAS``,The granule pointed by ``PA`` does not belong to Realm PAS 378e50fedbcSJavier Almansa Sobrino ``E_RMM_OK``,No errors detected 379e50fedbcSJavier Almansa Sobrino 38069447290SJavier Almansa SobrinoRMM_ATTEST_GET_REALM_KEY command 38169447290SJavier Almansa Sobrino================================ 38269447290SJavier Almansa Sobrino 38369447290SJavier Almansa SobrinoRetrieve the Realm Attestation Token Signing key from EL3. 38469447290SJavier Almansa Sobrino 38569447290SJavier Almansa SobrinoFID 38669447290SJavier Almansa Sobrino--- 38769447290SJavier Almansa Sobrino 38869447290SJavier Almansa Sobrino``0xC40001B2`` 38969447290SJavier Almansa Sobrino 39069447290SJavier Almansa SobrinoInput values 39169447290SJavier Almansa Sobrino------------ 39269447290SJavier Almansa Sobrino 39369447290SJavier Almansa Sobrino.. csv-table:: 39469447290SJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 39569447290SJavier Almansa Sobrino :widths: 1 1 1 1 5 39669447290SJavier Almansa Sobrino 39769447290SJavier Almansa Sobrino fid,x0,[63:0],UInt64,Command FID 39869447290SJavier Almansa Sobrino 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 39969447290SJavier Almansa Sobrino buf_size,x2,[63:0],Size,Size in bytes of the Realm Attestation Key buffer. ``bufPa + bufSize`` must lie within the shared buffer 40069447290SJavier Almansa Sobrino ecc_curve,x3,[63:0],Enum,Type of the elliptic curve to which the requested attestation key belongs to. See :ref:`ecc_curves` 40169447290SJavier Almansa Sobrino 40269447290SJavier Almansa SobrinoOutput values 40369447290SJavier Almansa Sobrino------------- 40469447290SJavier Almansa Sobrino 40569447290SJavier Almansa Sobrino.. csv-table:: 40669447290SJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 40769447290SJavier Almansa Sobrino :widths: 1 1 1 1 5 40869447290SJavier Almansa Sobrino 40969447290SJavier Almansa Sobrino Result,x0,[63:0],Error Code,Command return status 41069447290SJavier Almansa Sobrino keySize,x1,[63:0],Size,Size of the Realm Attestation Key 41169447290SJavier Almansa Sobrino 41269447290SJavier Almansa SobrinoFailure conditions 41369447290SJavier Almansa Sobrino------------------ 41469447290SJavier Almansa Sobrino 41569447290SJavier Almansa SobrinoThe table below shows all the possible error codes returned in ``Result`` upon 41669447290SJavier Almansa Sobrinoa failure. The errors are ordered by condition check. 41769447290SJavier Almansa Sobrino 41869447290SJavier Almansa Sobrino.. csv-table:: 41969447290SJavier Almansa Sobrino :header: "ID", "Condition" 42069447290SJavier Almansa Sobrino :widths: 1 5 42169447290SJavier Almansa Sobrino 42269447290SJavier Almansa Sobrino ``E_RMM_BAD_ADDR``,``PA`` is outside the shared buffer 42369447290SJavier Almansa Sobrino ``E_RMM_INVAL``,``PA + BSize`` is outside the shared buffer 42469447290SJavier Almansa Sobrino ``E_RMM_INVAL``,``Curve`` is not one of the listed in :ref:`ecc_curves` 42569447290SJavier Almansa Sobrino ``E_RMM_UNK``,An unknown error occurred whilst processing the command 42669447290SJavier Almansa Sobrino ``E_RMM_OK``,No errors detected 42769447290SJavier Almansa Sobrino 42869447290SJavier Almansa Sobrino.. _ecc_curves: 42969447290SJavier Almansa Sobrino 43069447290SJavier Almansa SobrinoSupported ECC Curves 43169447290SJavier Almansa Sobrino-------------------- 43269447290SJavier Almansa Sobrino 43369447290SJavier Almansa Sobrino.. csv-table:: 43469447290SJavier Almansa Sobrino :header: "ID", "Curve" 43569447290SJavier Almansa Sobrino :widths: 1 5 43669447290SJavier Almansa Sobrino 43769447290SJavier Almansa Sobrino 0,ECC SECP384R1 43869447290SJavier Almansa Sobrino 43969447290SJavier Almansa SobrinoRMM_ATTEST_GET_PLAT_TOKEN command 44069447290SJavier Almansa Sobrino================================= 44169447290SJavier Almansa Sobrino 44269447290SJavier Almansa SobrinoRetrieve the Platform Token from EL3. 44369447290SJavier Almansa Sobrino 44469447290SJavier Almansa SobrinoFID 44569447290SJavier Almansa Sobrino--- 44669447290SJavier Almansa Sobrino 44769447290SJavier Almansa Sobrino``0xC40001B3`` 44869447290SJavier Almansa Sobrino 44969447290SJavier Almansa SobrinoInput values 45069447290SJavier Almansa Sobrino------------ 45169447290SJavier Almansa Sobrino 45269447290SJavier Almansa Sobrino.. csv-table:: 45369447290SJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 45469447290SJavier Almansa Sobrino :widths: 1 1 1 1 5 45569447290SJavier Almansa Sobrino 45669447290SJavier Almansa Sobrino fid,x0,[63:0],UInt64,Command FID 45769447290SJavier Almansa Sobrino 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 45869447290SJavier Almansa Sobrino buf_size,x2,[63:0],Size,Size in bytes of the platform attestation token buffer. ``bufPa + bufSize`` must lie within the shared buffer 45969447290SJavier Almansa Sobrino 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 46069447290SJavier Almansa Sobrino 46169447290SJavier Almansa SobrinoOutput values 46269447290SJavier Almansa Sobrino------------- 46369447290SJavier Almansa Sobrino 46469447290SJavier Almansa Sobrino.. csv-table:: 46569447290SJavier Almansa Sobrino :header: "Name", "Register", "Field", "Type", "Description" 46669447290SJavier Almansa Sobrino :widths: 1 1 1 1 5 46769447290SJavier Almansa Sobrino 46869447290SJavier Almansa Sobrino Result,x0,[63:0],Error Code,Command return status 46969447290SJavier Almansa Sobrino tokenSize,x1,[63:0],Size,Size of the platform token 47069447290SJavier Almansa Sobrino 47169447290SJavier Almansa SobrinoFailure conditions 47269447290SJavier Almansa Sobrino------------------ 47369447290SJavier Almansa Sobrino 47469447290SJavier Almansa SobrinoThe table below shows all the possible error codes returned in ``Result`` upon 47569447290SJavier Almansa Sobrinoa failure. The errors are ordered by condition check. 47669447290SJavier Almansa Sobrino 47769447290SJavier Almansa Sobrino.. csv-table:: 47869447290SJavier Almansa Sobrino :header: "ID", "Condition" 47969447290SJavier Almansa Sobrino :widths: 1 5 48069447290SJavier Almansa Sobrino 48169447290SJavier Almansa Sobrino ``E_RMM_BAD_ADDR``,``PA`` is outside the shared buffer 48269447290SJavier Almansa Sobrino ``E_RMM_INVAL``,``PA + BSize`` is outside the shared buffer 48369447290SJavier Almansa Sobrino ``E_RMM_INVAL``,``CSize`` does not represent the size of a supported SHA algorithm 48469447290SJavier Almansa Sobrino ``E_RMM_UNK``,An unknown error occurred whilst processing the command 48569447290SJavier Almansa Sobrino ``E_RMM_OK``,No errors detected 48669447290SJavier Almansa Sobrino 48769447290SJavier Almansa SobrinoRMM-EL3 world switch register save restore convention 48869447290SJavier Almansa Sobrino_____________________________________________________ 48969447290SJavier Almansa Sobrino 49069447290SJavier Almansa SobrinoAs part of NS world switch, EL3 is expected to maintain a register context 49169447290SJavier Almansa Sobrinospecific to each world and will save and restore the registers 49269447290SJavier Almansa Sobrinoappropriately. This section captures the contract between EL3 and RMM on the 49369447290SJavier Almansa Sobrinoregister set to be saved and restored. 49469447290SJavier Almansa Sobrino 49569447290SJavier Almansa SobrinoEL3 must maintain a separate register context for the following: 49669447290SJavier Almansa Sobrino 49769447290SJavier Almansa Sobrino #. General purpose registers (x0-x30) and ``sp_el0``, ``sp_el2`` stack pointers 49869447290SJavier Almansa Sobrino #. 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. 49969447290SJavier Almansa Sobrino 5008e51cccaSAlexeiFedorovAs part of SMC forwarding between the NS world and Realm world, EL3 allows x0-x7 to be passed 5018e51cccaSAlexeiFedorovas arguments to Realm and x0-x4 to be used for return arguments back to Non Secure. 5028e51cccaSAlexeiFedorovAs per SMCCCv1.2, x4 must be preserved if not being used as return argument by the SMC function 5038e51cccaSAlexeiFedorovand it is the responsibility of RMM to preserve this or use this as a return argument. 5048e51cccaSAlexeiFedorovEL3 will always copy x0-x4 from Realm context to NS Context. 50569447290SJavier Almansa Sobrino 506*13cc1aa7SShruti GuptaEL3 must save and restore the following as part of world switch: 507*13cc1aa7SShruti Gupta #. EL2 system registers with the exception of ``zcr_el2`` register. 508*13cc1aa7SShruti Gupta #. PAuth key registers (APIA, APIB, APDA, APDB, APGA). 509*13cc1aa7SShruti Gupta 51069447290SJavier Almansa SobrinoEL3 will not save some registers as mentioned in the below list. It is the 51169447290SJavier Almansa Sobrinoresponsibility of RMM to ensure that these are appropriately saved if the 51269447290SJavier Almansa SobrinoRealm World makes use of them: 51369447290SJavier Almansa Sobrino 51469447290SJavier Almansa Sobrino #. FP/SIMD registers 51569447290SJavier Almansa Sobrino #. SVE registers 51669447290SJavier Almansa Sobrino #. SME registers 517*13cc1aa7SShruti Gupta #. EL1/0 registers with the exception of PAuth key registers as mentioned above. 518*13cc1aa7SShruti Gupta #. zcr_el2 register. 51969447290SJavier Almansa Sobrino 520*13cc1aa7SShruti GuptaIt is essential that EL3 honors this contract to maintain the Confidentiality and integrity 521*13cc1aa7SShruti Guptaof the Realm world. 5228e51cccaSAlexeiFedorov 52369447290SJavier Almansa SobrinoSMCCC v1.3 allows NS world to specify whether SVE context is in use. In this 52469447290SJavier Almansa Sobrinocase, RMM could choose to not save the incoming SVE context but must ensure 52569447290SJavier Almansa Sobrinoto clear SVE registers if they have been used in Realm World. The same applies 52669447290SJavier Almansa Sobrinoto SME registers. 52769447290SJavier Almansa Sobrino 52869447290SJavier Almansa SobrinoTypes 52969447290SJavier Almansa Sobrino_____ 53069447290SJavier Almansa Sobrino 53169447290SJavier Almansa Sobrino.. _rmm_el3_manifest_struct: 53269447290SJavier Almansa Sobrino 533dc0ca64eSJavier Almansa SobrinoRMM-EL3 Boot Manifest structure 534dc0ca64eSJavier Almansa Sobrino~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 53569447290SJavier Almansa Sobrino 5361db295cfSAlexeiFedorovThe RMM-EL3 Boot Manifest v0.2 structure contains platform boot information passed 5371db295cfSAlexeiFedorovfrom EL3 to RMM. The size of the Boot Manifest is 40 bytes. 53869447290SJavier Almansa Sobrino 53969447290SJavier Almansa SobrinoThe members of the RMM-EL3 Boot Manifest structure are shown in the following 54069447290SJavier Almansa Sobrinotable: 54169447290SJavier Almansa Sobrino 5421db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5431db295cfSAlexeiFedorov| Name | Offset | Type | Description | 5441db295cfSAlexeiFedorov+===========+========+================+========================================+ 5451db295cfSAlexeiFedorov| version | 0 | uint32_t | Boot Manifest version | 5461db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5471db295cfSAlexeiFedorov| padding | 4 | uint32_t | Reserved, set to 0 | 5481db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5491db295cfSAlexeiFedorov| plat_data | 8 | uintptr_t | Pointer to Platform Data section | 5501db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5511db295cfSAlexeiFedorov| plat_dram | 16 | ns_dram_info | NS DRAM Layout Info structure | 5521db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 55369447290SJavier Almansa Sobrino 5541db295cfSAlexeiFedorov.. _ns_dram_info_struct: 5551db295cfSAlexeiFedorov 5561db295cfSAlexeiFedorovNS DRAM Layout Info structure 5571db295cfSAlexeiFedorov~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581db295cfSAlexeiFedorov 5591db295cfSAlexeiFedorovNS DRAM Layout Info structure contains information about platform Non-secure 5601db295cfSAlexeiFedorovDRAM layout. The members of this structure are shown in the table below: 5611db295cfSAlexeiFedorov 5621db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5631db295cfSAlexeiFedorov| Name | Offset | Type | Description | 5641db295cfSAlexeiFedorov+===========+========+================+========================================+ 5651db295cfSAlexeiFedorov| num_banks | 0 | uint64_t | Number of NS DRAM banks | 5661db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5671db295cfSAlexeiFedorov| banks | 8 | ns_dram_bank * | Pointer to 'ns_dram_bank'[] array | 5681db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5691db295cfSAlexeiFedorov| checksum | 16 | uint64_t | Checksum | 5701db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5711db295cfSAlexeiFedorov 5721db295cfSAlexeiFedorovChecksum is calculated as two's complement sum of 'num_banks', 'banks' pointer 5731db295cfSAlexeiFedorovand DRAM banks data array pointed by it. 5741db295cfSAlexeiFedorov 5751db295cfSAlexeiFedorov.. _ns_dram_bank_struct: 5761db295cfSAlexeiFedorov 5771db295cfSAlexeiFedorovNS DRAM Bank structure 5781db295cfSAlexeiFedorov~~~~~~~~~~~~~~~~~~~~~~ 5791db295cfSAlexeiFedorov 5801db295cfSAlexeiFedorovNS DRAM Bank structure contains information about each Non-secure DRAM bank: 5811db295cfSAlexeiFedorov 5821db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5831db295cfSAlexeiFedorov| Name | Offset | Type | Description | 5841db295cfSAlexeiFedorov+===========+========+================+========================================+ 5851db295cfSAlexeiFedorov| base | 0 | uintptr_t | Base address | 5861db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5871db295cfSAlexeiFedorov| size | 8 | uint64_t | Size of bank in bytes | 5881db295cfSAlexeiFedorov+-----------+--------+----------------+----------------------------------------+ 5891db295cfSAlexeiFedorov 5901db295cfSAlexeiFedorov 5911db295cfSAlexeiFedorov 592