rmm-el3-comms-spec.rst 36 KB

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