blob: 7274081af0eea62d0036096e2432167272690b8b [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 Ferris63fcca42024-09-26 01:12:10 +000023 SNP_VLEK_LOAD,
Christopher Ferris76a1d452018-06-27 14:12:29 -070024 SEV_MAX,
25};
26typedef enum {
Christopher Ferris37c3f3c2023-07-10 10:59:05 -070027 SEV_RET_NO_FW_CALL = - 1,
Christopher Ferris76a1d452018-06-27 14:12:29 -070028 SEV_RET_SUCCESS = 0,
29 SEV_RET_INVALID_PLATFORM_STATE,
30 SEV_RET_INVALID_GUEST_STATE,
31 SEV_RET_INAVLID_CONFIG,
Christopher Ferris63fcca42024-09-26 01:12:10 +000032 SEV_RET_INVALID_CONFIG = SEV_RET_INAVLID_CONFIG,
Christopher Ferris76a1d452018-06-27 14:12:29 -070033 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 Ferrisd32ca142020-02-04 16:16:51 -080051 SEV_RET_INVALID_PARAM,
52 SEV_RET_RESOURCE_LIMIT,
53 SEV_RET_SECURE_DATA_INVALID,
Christopher Ferris0f795212024-01-17 14:17:28 -080054 SEV_RET_INVALID_KEY = 0x27,
Christopher Ferris7f4c8372024-06-03 14:22:19 -070055 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 Ferris76a1d452018-06-27 14:12:29 -070061 SEV_RET_MAX,
62} sev_ret_code;
63struct 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 Cross4ac33222022-12-15 15:45:35 -080070} __attribute__((__packed__));
Christopher Ferris8177cdf2020-08-03 11:53:55 -070071#define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
Christopher Ferris76a1d452018-06-27 14:12:29 -070072struct sev_user_data_pek_csr {
73 __u64 address;
74 __u32 length;
Colin Cross4ac33222022-12-15 15:45:35 -080075} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -070076struct 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 Cross4ac33222022-12-15 15:45:35 -080081} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -070082struct 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 Cross4ac33222022-12-15 15:45:35 -080087} __attribute__((__packed__));
Christopher Ferris9ce28842018-10-25 12:11:39 -070088struct sev_user_data_get_id {
89 __u8 socket1[64];
90 __u8 socket2[64];
Colin Cross4ac33222022-12-15 15:45:35 -080091} __attribute__((__packed__));
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -070092struct sev_user_data_get_id2 {
93 __u64 address;
94 __u32 length;
Colin Cross4ac33222022-12-15 15:45:35 -080095} __attribute__((__packed__));
Christopher Ferris7f4c8372024-06-03 14:22:19 -070096struct 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__));
111struct 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 Ferris63fcca42024-09-26 01:12:10 +0000118struct 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__));
124struct sev_user_data_snp_wrapped_vlek_hashstick {
125 __u8 data[432];
126} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700127struct sev_issue_cmd {
128 __u32 cmd;
129 __u64 data;
130 __u32 error;
Colin Cross4ac33222022-12-15 15:45:35 -0800131} __attribute__((__packed__));
Christopher Ferris76a1d452018-06-27 14:12:29 -0700132#define SEV_IOC_TYPE 'S'
133#define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
134#endif