rsi_smc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2023 ARM Ltd.
  4. */
  5. #ifndef __ASM_RSI_SMC_H_
  6. #define __ASM_RSI_SMC_H_
  7. #include <linux/arm-smccc.h>
  8. /*
  9. * This file describes the Realm Services Interface (RSI) Application Binary
  10. * Interface (ABI) for SMC calls made from within the Realm to the RMM and
  11. * serviced by the RMM.
  12. */
  13. /*
  14. * The major version number of the RSI implementation. This is increased when
  15. * the binary format or semantics of the SMC calls change.
  16. */
  17. #define RSI_ABI_VERSION_MAJOR UL(1)
  18. /*
  19. * The minor version number of the RSI implementation. This is increased when
  20. * a bug is fixed, or a feature is added without breaking binary compatibility.
  21. */
  22. #define RSI_ABI_VERSION_MINOR UL(0)
  23. #define RSI_ABI_VERSION ((RSI_ABI_VERSION_MAJOR << 16) | \
  24. RSI_ABI_VERSION_MINOR)
  25. #define RSI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16)
  26. #define RSI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFF)
  27. #define RSI_SUCCESS UL(0)
  28. #define RSI_ERROR_INPUT UL(1)
  29. #define RSI_ERROR_STATE UL(2)
  30. #define RSI_INCOMPLETE UL(3)
  31. #define RSI_ERROR_UNKNOWN UL(4)
  32. #define SMC_RSI_FID(n) ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
  33. ARM_SMCCC_SMC_64, \
  34. ARM_SMCCC_OWNER_STANDARD, \
  35. n)
  36. /*
  37. * Returns RSI version.
  38. *
  39. * arg1 == Requested interface revision
  40. * ret0 == Status / error
  41. * ret1 == Lower implemented interface revision
  42. * ret2 == Higher implemented interface revision
  43. */
  44. #define SMC_RSI_ABI_VERSION SMC_RSI_FID(0x190)
  45. /*
  46. * Read feature register.
  47. *
  48. * arg1 == Feature register index
  49. * ret0 == Status / error
  50. * ret1 == Feature register value
  51. */
  52. #define SMC_RSI_FEATURES SMC_RSI_FID(0x191)
  53. /*
  54. * Read measurement for the current Realm.
  55. *
  56. * arg1 == Index, which measurements slot to read
  57. * ret0 == Status / error
  58. * ret1 == Measurement value, bytes: 0 - 7
  59. * ret2 == Measurement value, bytes: 8 - 15
  60. * ret3 == Measurement value, bytes: 16 - 23
  61. * ret4 == Measurement value, bytes: 24 - 31
  62. * ret5 == Measurement value, bytes: 32 - 39
  63. * ret6 == Measurement value, bytes: 40 - 47
  64. * ret7 == Measurement value, bytes: 48 - 55
  65. * ret8 == Measurement value, bytes: 56 - 63
  66. */
  67. #define SMC_RSI_MEASUREMENT_READ SMC_RSI_FID(0x192)
  68. /*
  69. * Extend Realm Extensible Measurement (REM) value.
  70. *
  71. * arg1 == Index, which measurements slot to extend
  72. * arg2 == Size of realm measurement in bytes, max 64 bytes
  73. * arg3 == Measurement value, bytes: 0 - 7
  74. * arg4 == Measurement value, bytes: 8 - 15
  75. * arg5 == Measurement value, bytes: 16 - 23
  76. * arg6 == Measurement value, bytes: 24 - 31
  77. * arg7 == Measurement value, bytes: 32 - 39
  78. * arg8 == Measurement value, bytes: 40 - 47
  79. * arg9 == Measurement value, bytes: 48 - 55
  80. * arg10 == Measurement value, bytes: 56 - 63
  81. * ret0 == Status / error
  82. */
  83. #define SMC_RSI_MEASUREMENT_EXTEND SMC_RSI_FID(0x193)
  84. /*
  85. * Initialize the operation to retrieve an attestation token.
  86. *
  87. * arg1 == Challenge value, bytes: 0 - 7
  88. * arg2 == Challenge value, bytes: 8 - 15
  89. * arg3 == Challenge value, bytes: 16 - 23
  90. * arg4 == Challenge value, bytes: 24 - 31
  91. * arg5 == Challenge value, bytes: 32 - 39
  92. * arg6 == Challenge value, bytes: 40 - 47
  93. * arg7 == Challenge value, bytes: 48 - 55
  94. * arg8 == Challenge value, bytes: 56 - 63
  95. * ret0 == Status / error
  96. * ret1 == Upper bound of token size in bytes
  97. */
  98. #define SMC_RSI_ATTESTATION_TOKEN_INIT SMC_RSI_FID(0x194)
  99. /*
  100. * Continue the operation to retrieve an attestation token.
  101. *
  102. * arg1 == The IPA of token buffer
  103. * arg2 == Offset within the granule of the token buffer
  104. * arg3 == Size of the granule buffer
  105. * ret0 == Status / error
  106. * ret1 == Length of token bytes copied to the granule buffer
  107. */
  108. #define SMC_RSI_ATTESTATION_TOKEN_CONTINUE SMC_RSI_FID(0x195)
  109. #ifndef __ASSEMBLER__
  110. struct realm_config {
  111. union {
  112. struct {
  113. unsigned long ipa_bits; /* Width of IPA in bits */
  114. unsigned long hash_algo; /* Hash algorithm */
  115. };
  116. u8 pad[0x200];
  117. };
  118. union {
  119. u8 rpv[64]; /* Realm Personalization Value */
  120. u8 pad2[0xe00];
  121. };
  122. /*
  123. * The RMM requires the configuration structure to be aligned to a 4k
  124. * boundary, ensure this happens by aligning this structure.
  125. */
  126. } __aligned(0x1000);
  127. #endif /* __ASSEMBLER__ */
  128. /*
  129. * Read configuration for the current Realm.
  130. *
  131. * arg1 == struct realm_config addr
  132. * ret0 == Status / error
  133. */
  134. #define SMC_RSI_REALM_CONFIG SMC_RSI_FID(0x196)
  135. /*
  136. * Request RIPAS of a target IPA range to be changed to a specified value.
  137. *
  138. * arg1 == Base IPA address of target region
  139. * arg2 == Top of the region
  140. * arg3 == RIPAS value
  141. * arg4 == flags
  142. * ret0 == Status / error
  143. * ret1 == Top of modified IPA range
  144. * ret2 == Whether the Host accepted or rejected the request
  145. */
  146. #define SMC_RSI_IPA_STATE_SET SMC_RSI_FID(0x197)
  147. #define RSI_NO_CHANGE_DESTROYED UL(0)
  148. #define RSI_CHANGE_DESTROYED UL(1)
  149. #define RSI_ACCEPT UL(0)
  150. #define RSI_REJECT UL(1)
  151. /*
  152. * Get RIPAS of a target IPA range.
  153. *
  154. * arg1 == Base IPA of target region
  155. * arg2 == End of target IPA region
  156. * ret0 == Status / error
  157. * ret1 == Top of IPA region which has the reported RIPAS value
  158. * ret2 == RIPAS value
  159. */
  160. #define SMC_RSI_IPA_STATE_GET SMC_RSI_FID(0x198)
  161. /*
  162. * Make a Host call.
  163. *
  164. * arg1 == IPA of host call structure
  165. * ret0 == Status / error
  166. */
  167. #define SMC_RSI_HOST_CALL SMC_RSI_FID(0x199)
  168. #endif /* __ASM_RSI_SMC_H_ */