1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __PSP_SEV_USER_H__
18#define __PSP_SEV_USER_H__
19
20#include <linux/types.h>
21
22
23
24
25enum {
26 SEV_FACTORY_RESET = 0,
27 SEV_PLATFORM_STATUS,
28 SEV_PEK_GEN,
29 SEV_PEK_CSR,
30 SEV_PDH_GEN,
31 SEV_PDH_CERT_EXPORT,
32 SEV_PEK_CERT_IMPORT,
33 SEV_GET_ID,
34
35 SEV_MAX,
36};
37
38
39
40
41typedef enum {
42 SEV_RET_SUCCESS = 0,
43 SEV_RET_INVALID_PLATFORM_STATE,
44 SEV_RET_INVALID_GUEST_STATE,
45 SEV_RET_INAVLID_CONFIG,
46 SEV_RET_INVALID_LEN,
47 SEV_RET_ALREADY_OWNED,
48 SEV_RET_INVALID_CERTIFICATE,
49 SEV_RET_POLICY_FAILURE,
50 SEV_RET_INACTIVE,
51 SEV_RET_INVALID_ADDRESS,
52 SEV_RET_BAD_SIGNATURE,
53 SEV_RET_BAD_MEASUREMENT,
54 SEV_RET_ASID_OWNED,
55 SEV_RET_INVALID_ASID,
56 SEV_RET_WBINVD_REQUIRED,
57 SEV_RET_DFFLUSH_REQUIRED,
58 SEV_RET_INVALID_GUEST,
59 SEV_RET_INVALID_COMMAND,
60 SEV_RET_ACTIVE,
61 SEV_RET_HWSEV_RET_PLATFORM,
62 SEV_RET_HWSEV_RET_UNSAFE,
63 SEV_RET_UNSUPPORTED,
64 SEV_RET_MAX,
65} sev_ret_code;
66
67
68
69
70
71
72
73
74
75
76
77struct sev_user_data_status {
78 __u8 api_major;
79 __u8 api_minor;
80 __u8 state;
81 __u32 flags;
82 __u8 build;
83 __u32 guest_count;
84} __attribute__((packed));
85
86
87
88
89
90
91
92struct sev_user_data_pek_csr {
93 __u64 address;
94 __u32 length;
95} __attribute__((packed));
96
97
98
99
100
101
102
103
104
105struct sev_user_data_pek_cert_import {
106 __u64 pek_cert_address;
107 __u32 pek_cert_len;
108 __u64 oca_cert_address;
109 __u32 oca_cert_len;
110} __attribute__((packed));
111
112
113
114
115
116
117
118
119
120struct sev_user_data_pdh_cert_export {
121 __u64 pdh_cert_address;
122 __u32 pdh_cert_len;
123 __u64 cert_chain_address;
124 __u32 cert_chain_len;
125} __attribute__((packed));
126
127
128
129
130
131
132
133struct sev_user_data_get_id {
134 __u8 socket1[64];
135 __u8 socket2[64];
136} __attribute__((packed));
137
138
139
140
141
142
143
144
145struct sev_issue_cmd {
146 __u32 cmd;
147 __u64 data;
148 __u32 error;
149} __attribute__((packed));
150
151#define SEV_IOC_TYPE 'S'
152#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
153
154#endif
155