1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
3 * Userspace interface for AMD Secure Encrypted Virtualization (SEV)
4 * platform management commands.
6 * Copyright (C) 2016-2017 Advanced Micro Devices, Inc.
8 * Author: Brijesh Singh <brijesh.singh@amd.com>
10 * SEV API specification is available at: https://developer.amd.com/sev/
13 #ifndef __PSP_SEV_USER_H__
14 #define __PSP_SEV_USER_H__
16 #include <linux/types.h>
19 * SEV platform commands
22 SEV_FACTORY_RESET
= 0,
29 SEV_GET_ID
, /* This command is deprecated, use SEV_GET_ID2 */
36 * SEV Firmware status code
40 * This error code is not in the SEV spec. Its purpose is to convey that
41 * there was an error that prevented the SEV firmware from being called.
42 * The SEV API error codes are 16 bits, so the -1 value will not overlap
43 * with possible values from the specification.
45 SEV_RET_NO_FW_CALL
= -1,
47 SEV_RET_INVALID_PLATFORM_STATE
,
48 SEV_RET_INVALID_GUEST_STATE
,
49 SEV_RET_INAVLID_CONFIG
,
51 SEV_RET_ALREADY_OWNED
,
52 SEV_RET_INVALID_CERTIFICATE
,
53 SEV_RET_POLICY_FAILURE
,
55 SEV_RET_INVALID_ADDRESS
,
56 SEV_RET_BAD_SIGNATURE
,
57 SEV_RET_BAD_MEASUREMENT
,
60 SEV_RET_WBINVD_REQUIRED
,
61 SEV_RET_DFFLUSH_REQUIRED
,
62 SEV_RET_INVALID_GUEST
,
63 SEV_RET_INVALID_COMMAND
,
65 SEV_RET_HWSEV_RET_PLATFORM
,
66 SEV_RET_HWSEV_RET_UNSAFE
,
68 SEV_RET_INVALID_PARAM
,
69 SEV_RET_RESOURCE_LIMIT
,
70 SEV_RET_SECURE_DATA_INVALID
,
75 * struct sev_user_data_status - PLATFORM_STATUS command parameters
77 * @major: major API version
78 * @minor: minor API version
79 * @state: platform state
80 * @flags: platform config flags
81 * @build: firmware build id for API version
82 * @guest_count: number of active guests
84 struct sev_user_data_status
{
85 __u8 api_major
; /* Out */
86 __u8 api_minor
; /* Out */
88 __u32 flags
; /* Out */
90 __u32 guest_count
; /* Out */
91 } __attribute__((packed
));
93 #define SEV_STATUS_FLAGS_CONFIG_ES 0x0100
96 * struct sev_user_data_pek_csr - PEK_CSR command parameters
98 * @address: PEK certificate chain
99 * @length: length of certificate
101 struct sev_user_data_pek_csr
{
102 __u64 address
; /* In */
103 __u32 length
; /* In/Out */
104 } __attribute__((packed
));
107 * struct sev_user_data_cert_import - PEK_CERT_IMPORT command parameters
109 * @pek_address: PEK certificate chain
110 * @pek_len: length of PEK certificate
111 * @oca_address: OCA certificate chain
112 * @oca_len: length of OCA certificate
114 struct sev_user_data_pek_cert_import
{
115 __u64 pek_cert_address
; /* In */
116 __u32 pek_cert_len
; /* In */
117 __u64 oca_cert_address
; /* In */
118 __u32 oca_cert_len
; /* In */
119 } __attribute__((packed
));
122 * struct sev_user_data_pdh_cert_export - PDH_CERT_EXPORT command parameters
124 * @pdh_address: PDH certificate address
125 * @pdh_len: length of PDH certificate
126 * @cert_chain_address: PDH certificate chain
127 * @cert_chain_len: length of PDH certificate chain
129 struct sev_user_data_pdh_cert_export
{
130 __u64 pdh_cert_address
; /* In */
131 __u32 pdh_cert_len
; /* In/Out */
132 __u64 cert_chain_address
; /* In */
133 __u32 cert_chain_len
; /* In/Out */
134 } __attribute__((packed
));
137 * struct sev_user_data_get_id - GET_ID command parameters (deprecated)
139 * @socket1: Buffer to pass unique ID of first socket
140 * @socket2: Buffer to pass unique ID of second socket
142 struct sev_user_data_get_id
{
143 __u8 socket1
[64]; /* Out */
144 __u8 socket2
[64]; /* Out */
145 } __attribute__((packed
));
148 * struct sev_user_data_get_id2 - GET_ID command parameters
149 * @address: Buffer to store unique ID
150 * @length: length of the unique ID
152 struct sev_user_data_get_id2
{
153 __u64 address
; /* In */
154 __u32 length
; /* In/Out */
155 } __attribute__((packed
));
158 * struct sev_issue_cmd - SEV ioctl parameters
160 * @cmd: SEV commands to execute
161 * @opaque: pointer to the command structure
162 * @error: SEV FW return code on failure
164 struct sev_issue_cmd
{
167 __u32 error
; /* Out */
168 } __attribute__((packed
));
170 #define SEV_IOC_TYPE 'S'
171 #define SEV_ISSUE_CMD _IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
173 #endif /* __PSP_USER_SEV_H */