1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef __PSP_SEV_USER_H__
14#define __PSP_SEV_USER_H__
15
16#include <linux/types.h>
17
18
19
20
21enum {
22 SEV_FACTORY_RESET = 0,
23 SEV_PLATFORM_STATUS,
24 SEV_PEK_GEN,
25 SEV_PEK_CSR,
26 SEV_PDH_GEN,
27 SEV_PDH_CERT_EXPORT,
28 SEV_PEK_CERT_IMPORT,
29 SEV_GET_ID,
30 SEV_GET_ID2,
31
32 SEV_MAX,
33};
34
35
36
37
38typedef enum {
39
40
41
42
43
44
45 SEV_RET_NO_FW_CALL = -1,
46 SEV_RET_SUCCESS = 0,
47 SEV_RET_INVALID_PLATFORM_STATE,
48 SEV_RET_INVALID_GUEST_STATE,
49 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_MAX,
72} sev_ret_code;
73
74
75
76
77
78
79
80
81
82
83
84struct sev_user_data_status {
85 __u8 api_major;
86 __u8 api_minor;
87 __u8 state;
88 __u32 flags;
89 __u8 build;
90 __u32 guest_count;
91} __attribute__((packed));
92
93#define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
94
95
96
97
98
99
100
101struct sev_user_data_pek_csr {
102 __u64 address;
103 __u32 length;
104} __attribute__((packed));
105
106
107
108
109
110
111
112
113
114struct sev_user_data_pek_cert_import {
115 __u64 pek_cert_address;
116 __u32 pek_cert_len;
117 __u64 oca_cert_address;
118 __u32 oca_cert_len;
119} __attribute__((packed));
120
121
122
123
124
125
126
127
128
129struct sev_user_data_pdh_cert_export {
130 __u64 pdh_cert_address;
131 __u32 pdh_cert_len;
132 __u64 cert_chain_address;
133 __u32 cert_chain_len;
134} __attribute__((packed));
135
136
137
138
139
140
141
142struct sev_user_data_get_id {
143 __u8 socket1[64];
144 __u8 socket2[64];
145} __attribute__((packed));
146
147
148
149
150
151
152struct sev_user_data_get_id2 {
153 __u64 address;
154 __u32 length;
155} __attribute__((packed));
156
157
158
159
160
161
162
163
164struct sev_issue_cmd {
165 __u32 cmd;
166 __u64 data;
167 __u32 error;
168} __attribute__((packed));
169
170#define SEV_IOC_TYPE 'S'
171#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
172
173#endif
174