logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

psp-sev.h (7332B)


  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Userspace interface for AMD Secure Encrypted Virtualization (SEV)
  4. * platform management commands.
  5. *
  6. * Copyright (C) 2016-2017 Advanced Micro Devices, Inc.
  7. *
  8. * Author: Brijesh Singh <brijesh.singh@amd.com>
  9. *
  10. * SEV API specification is available at: https://developer.amd.com/sev/
  11. */
  12. #ifndef __PSP_SEV_USER_H__
  13. #define __PSP_SEV_USER_H__
  14. #include <linux/types.h>
  15. /**
  16. * SEV platform commands
  17. */
  18. enum {
  19. SEV_FACTORY_RESET = 0,
  20. SEV_PLATFORM_STATUS,
  21. SEV_PEK_GEN,
  22. SEV_PEK_CSR,
  23. SEV_PDH_GEN,
  24. SEV_PDH_CERT_EXPORT,
  25. SEV_PEK_CERT_IMPORT,
  26. SEV_GET_ID, /* This command is deprecated, use SEV_GET_ID2 */
  27. SEV_GET_ID2,
  28. SNP_PLATFORM_STATUS,
  29. SNP_COMMIT,
  30. SNP_SET_CONFIG,
  31. SNP_VLEK_LOAD,
  32. SEV_MAX,
  33. };
  34. /**
  35. * SEV Firmware status code
  36. */
  37. typedef enum {
  38. /*
  39. * This error code is not in the SEV spec. Its purpose is to convey that
  40. * there was an error that prevented the SEV firmware from being called.
  41. * The SEV API error codes are 16 bits, so the -1 value will not overlap
  42. * with possible values from the specification.
  43. */
  44. SEV_RET_NO_FW_CALL = -1,
  45. SEV_RET_SUCCESS = 0,
  46. SEV_RET_INVALID_PLATFORM_STATE,
  47. SEV_RET_INVALID_GUEST_STATE,
  48. SEV_RET_INAVLID_CONFIG,
  49. SEV_RET_INVALID_CONFIG = SEV_RET_INAVLID_CONFIG,
  50. SEV_RET_INVALID_LEN,
  51. SEV_RET_ALREADY_OWNED,
  52. SEV_RET_INVALID_CERTIFICATE,
  53. SEV_RET_POLICY_FAILURE,
  54. SEV_RET_INACTIVE,
  55. SEV_RET_INVALID_ADDRESS,
  56. SEV_RET_BAD_SIGNATURE,
  57. SEV_RET_BAD_MEASUREMENT,
  58. SEV_RET_ASID_OWNED,
  59. SEV_RET_INVALID_ASID,
  60. SEV_RET_WBINVD_REQUIRED,
  61. SEV_RET_DFFLUSH_REQUIRED,
  62. SEV_RET_INVALID_GUEST,
  63. SEV_RET_INVALID_COMMAND,
  64. SEV_RET_ACTIVE,
  65. SEV_RET_HWSEV_RET_PLATFORM,
  66. SEV_RET_HWSEV_RET_UNSAFE,
  67. SEV_RET_UNSUPPORTED,
  68. SEV_RET_INVALID_PARAM,
  69. SEV_RET_RESOURCE_LIMIT,
  70. SEV_RET_SECURE_DATA_INVALID,
  71. SEV_RET_INVALID_KEY = 0x27,
  72. SEV_RET_INVALID_PAGE_SIZE,
  73. SEV_RET_INVALID_PAGE_STATE,
  74. SEV_RET_INVALID_MDATA_ENTRY,
  75. SEV_RET_INVALID_PAGE_OWNER,
  76. SEV_RET_INVALID_PAGE_AEAD_OFLOW,
  77. SEV_RET_RMP_INIT_REQUIRED,
  78. SEV_RET_MAX,
  79. } sev_ret_code;
  80. /**
  81. * struct sev_user_data_status - PLATFORM_STATUS command parameters
  82. *
  83. * @major: major API version
  84. * @minor: minor API version
  85. * @state: platform state
  86. * @flags: platform config flags
  87. * @build: firmware build id for API version
  88. * @guest_count: number of active guests
  89. */
  90. struct sev_user_data_status {
  91. __u8 api_major; /* Out */
  92. __u8 api_minor; /* Out */
  93. __u8 state; /* Out */
  94. __u32 flags; /* Out */
  95. __u8 build; /* Out */
  96. __u32 guest_count; /* Out */
  97. } __attribute__((packed));
  98. #define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
  99. /**
  100. * struct sev_user_data_pek_csr - PEK_CSR command parameters
  101. *
  102. * @address: PEK certificate chain
  103. * @length: length of certificate
  104. */
  105. struct sev_user_data_pek_csr {
  106. __u64 address; /* In */
  107. __u32 length; /* In/Out */
  108. } __attribute__((packed));
  109. /**
  110. * struct sev_user_data_cert_import - PEK_CERT_IMPORT command parameters
  111. *
  112. * @pek_address: PEK certificate chain
  113. * @pek_len: length of PEK certificate
  114. * @oca_address: OCA certificate chain
  115. * @oca_len: length of OCA certificate
  116. */
  117. struct sev_user_data_pek_cert_import {
  118. __u64 pek_cert_address; /* In */
  119. __u32 pek_cert_len; /* In */
  120. __u64 oca_cert_address; /* In */
  121. __u32 oca_cert_len; /* In */
  122. } __attribute__((packed));
  123. /**
  124. * struct sev_user_data_pdh_cert_export - PDH_CERT_EXPORT command parameters
  125. *
  126. * @pdh_address: PDH certificate address
  127. * @pdh_len: length of PDH certificate
  128. * @cert_chain_address: PDH certificate chain
  129. * @cert_chain_len: length of PDH certificate chain
  130. */
  131. struct sev_user_data_pdh_cert_export {
  132. __u64 pdh_cert_address; /* In */
  133. __u32 pdh_cert_len; /* In/Out */
  134. __u64 cert_chain_address; /* In */
  135. __u32 cert_chain_len; /* In/Out */
  136. } __attribute__((packed));
  137. /**
  138. * struct sev_user_data_get_id - GET_ID command parameters (deprecated)
  139. *
  140. * @socket1: Buffer to pass unique ID of first socket
  141. * @socket2: Buffer to pass unique ID of second socket
  142. */
  143. struct sev_user_data_get_id {
  144. __u8 socket1[64]; /* Out */
  145. __u8 socket2[64]; /* Out */
  146. } __attribute__((packed));
  147. /**
  148. * struct sev_user_data_get_id2 - GET_ID command parameters
  149. * @address: Buffer to store unique ID
  150. * @length: length of the unique ID
  151. */
  152. struct sev_user_data_get_id2 {
  153. __u64 address; /* In */
  154. __u32 length; /* In/Out */
  155. } __attribute__((packed));
  156. /**
  157. * struct sev_user_data_snp_status - SNP status
  158. *
  159. * @api_major: API major version
  160. * @api_minor: API minor version
  161. * @state: current platform state
  162. * @is_rmp_initialized: whether RMP is initialized or not
  163. * @rsvd: reserved
  164. * @build_id: firmware build id for the API version
  165. * @mask_chip_id: whether chip id is present in attestation reports or not
  166. * @mask_chip_key: whether attestation reports are signed or not
  167. * @vlek_en: VLEK (Version Loaded Endorsement Key) hashstick is loaded
  168. * @rsvd1: reserved
  169. * @guest_count: the number of guest currently managed by the firmware
  170. * @current_tcb_version: current TCB version
  171. * @reported_tcb_version: reported TCB version
  172. */
  173. struct sev_user_data_snp_status {
  174. __u8 api_major; /* Out */
  175. __u8 api_minor; /* Out */
  176. __u8 state; /* Out */
  177. __u8 is_rmp_initialized:1; /* Out */
  178. __u8 rsvd:7;
  179. __u32 build_id; /* Out */
  180. __u32 mask_chip_id:1; /* Out */
  181. __u32 mask_chip_key:1; /* Out */
  182. __u32 vlek_en:1; /* Out */
  183. __u32 rsvd1:29;
  184. __u32 guest_count; /* Out */
  185. __u64 current_tcb_version; /* Out */
  186. __u64 reported_tcb_version; /* Out */
  187. } __attribute__((packed));
  188. /**
  189. * struct sev_user_data_snp_config - system wide configuration value for SNP.
  190. *
  191. * @reported_tcb: the TCB version to report in the guest attestation report.
  192. * @mask_chip_id: whether chip id is present in attestation reports or not
  193. * @mask_chip_key: whether attestation reports are signed or not
  194. * @rsvd: reserved
  195. * @rsvd1: reserved
  196. */
  197. struct sev_user_data_snp_config {
  198. __u64 reported_tcb ; /* In */
  199. __u32 mask_chip_id:1; /* In */
  200. __u32 mask_chip_key:1; /* In */
  201. __u32 rsvd:30; /* In */
  202. __u8 rsvd1[52];
  203. } __attribute__((packed));
  204. /**
  205. * struct sev_data_snp_vlek_load - SNP_VLEK_LOAD structure
  206. *
  207. * @len: length of the command buffer read by the PSP
  208. * @vlek_wrapped_version: version of wrapped VLEK hashstick (Must be 0h)
  209. * @rsvd: reserved
  210. * @vlek_wrapped_address: address of a wrapped VLEK hashstick
  211. * (struct sev_user_data_snp_wrapped_vlek_hashstick)
  212. */
  213. struct sev_user_data_snp_vlek_load {
  214. __u32 len; /* In */
  215. __u8 vlek_wrapped_version; /* In */
  216. __u8 rsvd[3]; /* In */
  217. __u64 vlek_wrapped_address; /* In */
  218. } __attribute__((packed));
  219. /**
  220. * struct sev_user_data_snp_vlek_wrapped_vlek_hashstick - Wrapped VLEK data
  221. *
  222. * @data: Opaque data provided by AMD KDS (as described in SEV-SNP Firmware ABI
  223. * 1.54, SNP_VLEK_LOAD)
  224. */
  225. struct sev_user_data_snp_wrapped_vlek_hashstick {
  226. __u8 data[432]; /* In */
  227. } __attribute__((packed));
  228. /**
  229. * struct sev_issue_cmd - SEV ioctl parameters
  230. *
  231. * @cmd: SEV commands to execute
  232. * @opaque: pointer to the command structure
  233. * @error: SEV FW return code on failure
  234. */
  235. struct sev_issue_cmd {
  236. __u32 cmd; /* In */
  237. __u64 data; /* In */
  238. __u32 error; /* Out */
  239. } __attribute__((packed));
  240. #define SEV_IOC_TYPE 'S'
  241. #define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
  242. #endif /* __PSP_USER_SEV_H */