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 SEV_RET_SUCCESS = 0,
40 SEV_RET_INVALID_PLATFORM_STATE,
41 SEV_RET_INVALID_GUEST_STATE,
42 SEV_RET_INAVLID_CONFIG,
43 SEV_RET_INVALID_LEN,
44 SEV_RET_ALREADY_OWNED,
45 SEV_RET_INVALID_CERTIFICATE,
46 SEV_RET_POLICY_FAILURE,
47 SEV_RET_INACTIVE,
48 SEV_RET_INVALID_ADDRESS,
49 SEV_RET_BAD_SIGNATURE,
50 SEV_RET_BAD_MEASUREMENT,
51 SEV_RET_ASID_OWNED,
52 SEV_RET_INVALID_ASID,
53 SEV_RET_WBINVD_REQUIRED,
54 SEV_RET_DFFLUSH_REQUIRED,
55 SEV_RET_INVALID_GUEST,
56 SEV_RET_INVALID_COMMAND,
57 SEV_RET_ACTIVE,
58 SEV_RET_HWSEV_RET_PLATFORM,
59 SEV_RET_HWSEV_RET_UNSAFE,
60 SEV_RET_UNSUPPORTED,
61 SEV_RET_MAX,
62} sev_ret_code;
63
64
65
66
67
68
69
70
71
72
73
74struct sev_user_data_status {
75 __u8 api_major;
76 __u8 api_minor;
77 __u8 state;
78 __u32 flags;
79 __u8 build;
80 __u32 guest_count;
81} __attribute__((packed));
82
83
84
85
86
87
88
89struct sev_user_data_pek_csr {
90 __u64 address;
91 __u32 length;
92} __attribute__((packed));
93
94
95
96
97
98
99
100
101
102struct sev_user_data_pek_cert_import {
103 __u64 pek_cert_address;
104 __u32 pek_cert_len;
105 __u64 oca_cert_address;
106 __u32 oca_cert_len;
107} __attribute__((packed));
108
109
110
111
112
113
114
115
116
117struct sev_user_data_pdh_cert_export {
118 __u64 pdh_cert_address;
119 __u32 pdh_cert_len;
120 __u64 cert_chain_address;
121 __u32 cert_chain_len;
122} __attribute__((packed));
123
124
125
126
127
128
129
130struct sev_user_data_get_id {
131 __u8 socket1[64];
132 __u8 socket2[64];
133} __attribute__((packed));
134
135
136
137
138
139
140struct sev_user_data_get_id2 {
141 __u64 address;
142 __u32 length;
143} __attribute__((packed));
144
145
146
147
148
149
150
151
152struct sev_issue_cmd {
153 __u32 cmd;
154 __u64 data;
155 __u32 error;
156} __attribute__((packed));
157
158#define SEV_IOC_TYPE 'S'
159#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
160
161#endif
162