blob: 82fcbf1ffcc808ec341a120736efcef16de70db5 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 Ferris76a1d452018-06-27 14:12:29 -07007#ifndef __PSP_SEV_USER_H__
8#define __PSP_SEV_USER_H__
9#include <linux/types.h>
10enum {
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 Ferris9ce28842018-10-25 12:11:39 -070018 SEV_GET_ID,
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -070019 SEV_GET_ID2,
Christopher Ferris7f4c8372024-06-03 14:22:19 -070020 SNP_PLATFORM_STATUS,
21 SNP_COMMIT,
22 SNP_SET_CONFIG,
Christopher Ferris76a1d452018-06-27 14:12:29 -070023 SEV_MAX,
24};
25typedef enum {
Christopher Ferris37c3f3c2023-07-10 10:59:05 -070026 SEV_RET_NO_FW_CALL = - 1,
Christopher Ferris76a1d452018-06-27 14:12:29 -070027 SEV_RET_SUCCESS = 0,
28 SEV_RET_INVALID_PLATFORM_STATE,
29 SEV_RET_INVALID_GUEST_STATE,
30 SEV_RET_INAVLID_CONFIG,
31 SEV_RET_INVALID_LEN,
32 SEV_RET_ALREADY_OWNED,
33 SEV_RET_INVALID_CERTIFICATE,
34 SEV_RET_POLICY_FAILURE,
35 SEV_RET_INACTIVE,
36 SEV_RET_INVALID_ADDRESS,
37 SEV_RET_BAD_SIGNATURE,
38 SEV_RET_BAD_MEASUREMENT,
39 SEV_RET_ASID_OWNED,
40 SEV_RET_INVALID_ASID,
41 SEV_RET_WBINVD_REQUIRED,
42 SEV_RET_DFFLUSH_REQUIRED,
43 SEV_RET_INVALID_GUEST,
44 SEV_RET_INVALID_COMMAND,
45 SEV_RET_ACTIVE,
46 SEV_RET_HWSEV_RET_PLATFORM,
47 SEV_RET_HWSEV_RET_UNSAFE,
48 SEV_RET_UNSUPPORTED,
Christopher Ferrisd32ca142020-02-04 16:16:51 -080049 SEV_RET_INVALID_PARAM,
50 SEV_RET_RESOURCE_LIMIT,
51 SEV_RET_SECURE_DATA_INVALID,
Christopher Ferris0f795212024-01-17 14:17:28 -080052 SEV_RET_INVALID_KEY = 0x27,
Christopher Ferris7f4c8372024-06-03 14:22:19 -070053 SEV_RET_INVALID_PAGE_SIZE,
54 SEV_RET_INVALID_PAGE_STATE,
55 SEV_RET_INVALID_MDATA_ENTRY,
56 SEV_RET_INVALID_PAGE_OWNER,
57 SEV_RET_INVALID_PAGE_AEAD_OFLOW,
58 SEV_RET_RMP_INIT_REQUIRED,
Christopher Ferris76a1d452018-06-27 14:12:29 -070059 SEV_RET_MAX,
60} sev_ret_code;
61struct sev_user_data_status {
62 __u8 api_major;
63 __u8 api_minor;
64 __u8 state;
65 __u32 flags;
66 __u8 build;
67 __u32 guest_count;
Colin Cross4ac33222022-12-15 15:45:35 -080068} __attribute__((__packed__));
Christopher Ferris8177cdf2020-08-03 11:53:55 -070069#define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
Christopher Ferris76a1d452018-06-27 14:12:29 -070070struct sev_user_data_pek_csr {
71 __u64 address;
72 __u32 length;
Colin Cross4ac33222022-12-15 15:45:35 -080073} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -070074struct sev_user_data_pek_cert_import {
75 __u64 pek_cert_address;
76 __u32 pek_cert_len;
77 __u64 oca_cert_address;
78 __u32 oca_cert_len;
Colin Cross4ac33222022-12-15 15:45:35 -080079} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -070080struct sev_user_data_pdh_cert_export {
81 __u64 pdh_cert_address;
82 __u32 pdh_cert_len;
83 __u64 cert_chain_address;
84 __u32 cert_chain_len;
Colin Cross4ac33222022-12-15 15:45:35 -080085} __attribute__((__packed__));
Christopher Ferris9ce28842018-10-25 12:11:39 -070086struct sev_user_data_get_id {
87 __u8 socket1[64];
88 __u8 socket2[64];
Colin Cross4ac33222022-12-15 15:45:35 -080089} __attribute__((__packed__));
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -070090struct sev_user_data_get_id2 {
91 __u64 address;
92 __u32 length;
Colin Cross4ac33222022-12-15 15:45:35 -080093} __attribute__((__packed__));
Christopher Ferris7f4c8372024-06-03 14:22:19 -070094struct sev_user_data_snp_status {
95 __u8 api_major;
96 __u8 api_minor;
97 __u8 state;
98 __u8 is_rmp_initialized : 1;
99 __u8 rsvd : 7;
100 __u32 build_id;
101 __u32 mask_chip_id : 1;
102 __u32 mask_chip_key : 1;
103 __u32 vlek_en : 1;
104 __u32 rsvd1 : 29;
105 __u32 guest_count;
106 __u64 current_tcb_version;
107 __u64 reported_tcb_version;
108} __attribute__((__packed__));
109struct sev_user_data_snp_config {
110 __u64 reported_tcb;
111 __u32 mask_chip_id : 1;
112 __u32 mask_chip_key : 1;
113 __u32 rsvd : 30;
114 __u8 rsvd1[52];
115} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700116struct sev_issue_cmd {
117 __u32 cmd;
118 __u64 data;
119 __u32 error;
Colin Cross4ac33222022-12-15 15:45:35 -0800120} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700121#define SEV_IOC_TYPE 'S'
122#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
123#endif