Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[linux-2.6-microblaze.git] / include / uapi / linux / sev-guest.h
1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2 /*
3  * Userspace interface for AMD SEV and SNP guest driver.
4  *
5  * Copyright (C) 2021 Advanced Micro Devices, Inc.
6  *
7  * Author: Brijesh Singh <brijesh.singh@amd.com>
8  *
9  * SEV API specification is available at: https://developer.amd.com/sev/
10  */
11
12 #ifndef __UAPI_LINUX_SEV_GUEST_H_
13 #define __UAPI_LINUX_SEV_GUEST_H_
14
15 #include <linux/types.h>
16
17 struct snp_report_req {
18         /* user data that should be included in the report */
19         __u8 user_data[64];
20
21         /* The vmpl level to be included in the report */
22         __u32 vmpl;
23
24         /* Must be zero filled */
25         __u8 rsvd[28];
26 };
27
28 struct snp_report_resp {
29         /* response data, see SEV-SNP spec for the format */
30         __u8 data[4000];
31 };
32
33 struct snp_derived_key_req {
34         __u32 root_key_select;
35         __u32 rsvd;
36         __u64 guest_field_select;
37         __u32 vmpl;
38         __u32 guest_svn;
39         __u64 tcb_version;
40 };
41
42 struct snp_derived_key_resp {
43         /* response data, see SEV-SNP spec for the format */
44         __u8 data[64];
45 };
46
47 struct snp_guest_request_ioctl {
48         /* message version number (must be non-zero) */
49         __u8 msg_version;
50
51         /* Request and response structure address */
52         __u64 req_data;
53         __u64 resp_data;
54
55         /* firmware error code on failure (see psp-sev.h) */
56         __u64 fw_err;
57 };
58
59 struct snp_ext_report_req {
60         struct snp_report_req data;
61
62         /* where to copy the certificate blob */
63         __u64 certs_address;
64
65         /* length of the certificate blob */
66         __u32 certs_len;
67 };
68
69 #define SNP_GUEST_REQ_IOC_TYPE  'S'
70
71 /* Get SNP attestation report */
72 #define SNP_GET_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x0, struct snp_guest_request_ioctl)
73
74 /* Get a derived key from the root */
75 #define SNP_GET_DERIVED_KEY _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x1, struct snp_guest_request_ioctl)
76
77 /* Get SNP extended report as defined in the GHCB specification version 2. */
78 #define SNP_GET_EXT_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x2, struct snp_guest_request_ioctl)
79
80 #endif /* __UAPI_LINUX_SEV_GUEST_H_ */