Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is auto-generated. Modifications will be lost. |
| 3 | * |
| 4 | * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ |
| 5 | * for more information. |
| 6 | */ |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 7 | #ifndef __PSP_SEV_USER_H__ |
| 8 | #define __PSP_SEV_USER_H__ |
| 9 | #include <linux/types.h> |
| 10 | enum { |
| 11 | SEV_FACTORY_RESET = 0, |
| 12 | SEV_PLATFORM_STATUS, |
| 13 | SEV_PEK_GEN, |
| 14 | SEV_PEK_CSR, |
| 15 | SEV_PDH_GEN, |
| 16 | SEV_PDH_CERT_EXPORT, |
| 17 | SEV_PEK_CERT_IMPORT, |
Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 18 | SEV_GET_ID, |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 19 | SEV_GET_ID2, |
Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 20 | SNP_PLATFORM_STATUS, |
| 21 | SNP_COMMIT, |
| 22 | SNP_SET_CONFIG, |
Christopher Ferris | 63fcca4 | 2024-09-26 01:12:10 +0000 | [diff] [blame^] | 23 | SNP_VLEK_LOAD, |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 24 | SEV_MAX, |
| 25 | }; |
| 26 | typedef enum { |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame] | 27 | SEV_RET_NO_FW_CALL = - 1, |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 28 | SEV_RET_SUCCESS = 0, |
| 29 | SEV_RET_INVALID_PLATFORM_STATE, |
| 30 | SEV_RET_INVALID_GUEST_STATE, |
| 31 | SEV_RET_INAVLID_CONFIG, |
Christopher Ferris | 63fcca4 | 2024-09-26 01:12:10 +0000 | [diff] [blame^] | 32 | SEV_RET_INVALID_CONFIG = SEV_RET_INAVLID_CONFIG, |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 33 | SEV_RET_INVALID_LEN, |
| 34 | SEV_RET_ALREADY_OWNED, |
| 35 | SEV_RET_INVALID_CERTIFICATE, |
| 36 | SEV_RET_POLICY_FAILURE, |
| 37 | SEV_RET_INACTIVE, |
| 38 | SEV_RET_INVALID_ADDRESS, |
| 39 | SEV_RET_BAD_SIGNATURE, |
| 40 | SEV_RET_BAD_MEASUREMENT, |
| 41 | SEV_RET_ASID_OWNED, |
| 42 | SEV_RET_INVALID_ASID, |
| 43 | SEV_RET_WBINVD_REQUIRED, |
| 44 | SEV_RET_DFFLUSH_REQUIRED, |
| 45 | SEV_RET_INVALID_GUEST, |
| 46 | SEV_RET_INVALID_COMMAND, |
| 47 | SEV_RET_ACTIVE, |
| 48 | SEV_RET_HWSEV_RET_PLATFORM, |
| 49 | SEV_RET_HWSEV_RET_UNSAFE, |
| 50 | SEV_RET_UNSUPPORTED, |
Christopher Ferris | d32ca14 | 2020-02-04 16:16:51 -0800 | [diff] [blame] | 51 | SEV_RET_INVALID_PARAM, |
| 52 | SEV_RET_RESOURCE_LIMIT, |
| 53 | SEV_RET_SECURE_DATA_INVALID, |
Christopher Ferris | 0f79521 | 2024-01-17 14:17:28 -0800 | [diff] [blame] | 54 | SEV_RET_INVALID_KEY = 0x27, |
Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 55 | SEV_RET_INVALID_PAGE_SIZE, |
| 56 | SEV_RET_INVALID_PAGE_STATE, |
| 57 | SEV_RET_INVALID_MDATA_ENTRY, |
| 58 | SEV_RET_INVALID_PAGE_OWNER, |
| 59 | SEV_RET_INVALID_PAGE_AEAD_OFLOW, |
| 60 | SEV_RET_RMP_INIT_REQUIRED, |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 61 | SEV_RET_MAX, |
| 62 | } sev_ret_code; |
| 63 | struct sev_user_data_status { |
| 64 | __u8 api_major; |
| 65 | __u8 api_minor; |
| 66 | __u8 state; |
| 67 | __u32 flags; |
| 68 | __u8 build; |
| 69 | __u32 guest_count; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 70 | } __attribute__((__packed__)); |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 71 | #define SEV_STATUS_FLAGS_CONFIG_ES 0x0100 |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 72 | struct sev_user_data_pek_csr { |
| 73 | __u64 address; |
| 74 | __u32 length; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 75 | } __attribute__((__packed__)); |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 76 | struct sev_user_data_pek_cert_import { |
| 77 | __u64 pek_cert_address; |
| 78 | __u32 pek_cert_len; |
| 79 | __u64 oca_cert_address; |
| 80 | __u32 oca_cert_len; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 81 | } __attribute__((__packed__)); |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 82 | struct sev_user_data_pdh_cert_export { |
| 83 | __u64 pdh_cert_address; |
| 84 | __u32 pdh_cert_len; |
| 85 | __u64 cert_chain_address; |
| 86 | __u32 cert_chain_len; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 87 | } __attribute__((__packed__)); |
Christopher Ferris | 9ce2884 | 2018-10-25 12:11:39 -0700 | [diff] [blame] | 88 | struct sev_user_data_get_id { |
| 89 | __u8 socket1[64]; |
| 90 | __u8 socket2[64]; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 91 | } __attribute__((__packed__)); |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 92 | struct sev_user_data_get_id2 { |
| 93 | __u64 address; |
| 94 | __u32 length; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 95 | } __attribute__((__packed__)); |
Christopher Ferris | 7f4c837 | 2024-06-03 14:22:19 -0700 | [diff] [blame] | 96 | struct sev_user_data_snp_status { |
| 97 | __u8 api_major; |
| 98 | __u8 api_minor; |
| 99 | __u8 state; |
| 100 | __u8 is_rmp_initialized : 1; |
| 101 | __u8 rsvd : 7; |
| 102 | __u32 build_id; |
| 103 | __u32 mask_chip_id : 1; |
| 104 | __u32 mask_chip_key : 1; |
| 105 | __u32 vlek_en : 1; |
| 106 | __u32 rsvd1 : 29; |
| 107 | __u32 guest_count; |
| 108 | __u64 current_tcb_version; |
| 109 | __u64 reported_tcb_version; |
| 110 | } __attribute__((__packed__)); |
| 111 | struct sev_user_data_snp_config { |
| 112 | __u64 reported_tcb; |
| 113 | __u32 mask_chip_id : 1; |
| 114 | __u32 mask_chip_key : 1; |
| 115 | __u32 rsvd : 30; |
| 116 | __u8 rsvd1[52]; |
| 117 | } __attribute__((__packed__)); |
Christopher Ferris | 63fcca4 | 2024-09-26 01:12:10 +0000 | [diff] [blame^] | 118 | struct sev_user_data_snp_vlek_load { |
| 119 | __u32 len; |
| 120 | __u8 vlek_wrapped_version; |
| 121 | __u8 rsvd[3]; |
| 122 | __u64 vlek_wrapped_address; |
| 123 | } __attribute__((__packed__)); |
| 124 | struct sev_user_data_snp_wrapped_vlek_hashstick { |
| 125 | __u8 data[432]; |
| 126 | } __attribute__((__packed__)); |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 127 | struct sev_issue_cmd { |
| 128 | __u32 cmd; |
| 129 | __u64 data; |
| 130 | __u32 error; |
Colin Cross | 4ac3322 | 2022-12-15 15:45:35 -0800 | [diff] [blame] | 131 | } __attribute__((__packed__)); |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 132 | #define SEV_IOC_TYPE 'S' |
| 133 | #define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd) |
| 134 | #endif |