1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
3 * Userspace interface for AMD SEV and SNP guest driver.
5 * Copyright (C) 2021 Advanced Micro Devices, Inc.
7 * Author: Brijesh Singh <brijesh.singh@amd.com>
9 * SEV API specification is available at: https://developer.amd.com/sev/
12 #ifndef __UAPI_LINUX_SEV_GUEST_H_
13 #define __UAPI_LINUX_SEV_GUEST_H_
15 #include <linux/types.h>
17 struct snp_report_req {
18 /* user data that should be included in the report */
21 /* The vmpl level to be included in the report */
24 /* Must be zero filled */
28 struct snp_report_resp {
29 /* response data, see SEV-SNP spec for the format */
33 struct snp_derived_key_req {
34 __u32 root_key_select;
36 __u64 guest_field_select;
42 struct snp_derived_key_resp {
43 /* response data, see SEV-SNP spec for the format */
47 struct snp_guest_request_ioctl {
48 /* message version number (must be non-zero) */
51 /* Request and response structure address */
55 /* bits[63:32]: VMM error code, bits[31:0] firmware error code (see psp-sev.h) */
65 struct snp_ext_report_req {
66 struct snp_report_req data;
68 /* where to copy the certificate blob */
71 /* length of the certificate blob */
75 #define SNP_GUEST_REQ_IOC_TYPE 'S'
77 /* Get SNP attestation report */
78 #define SNP_GET_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x0, struct snp_guest_request_ioctl)
80 /* Get a derived key from the root */
81 #define SNP_GET_DERIVED_KEY _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x1, struct snp_guest_request_ioctl)
83 /* Get SNP extended report as defined in the GHCB specification version 2. */
84 #define SNP_GET_EXT_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x2, struct snp_guest_request_ioctl)
86 /* Guest message request EXIT_INFO_2 constants */
87 #define SNP_GUEST_FW_ERR_MASK GENMASK_ULL(31, 0)
88 #define SNP_GUEST_VMM_ERR_SHIFT 32
89 #define SNP_GUEST_VMM_ERR(x) (((u64)x) << SNP_GUEST_VMM_ERR_SHIFT)
91 #define SNP_GUEST_VMM_ERR_INVALID_LEN 1
92 #define SNP_GUEST_VMM_ERR_BUSY 2
94 #endif /* __UAPI_LINUX_SEV_GUEST_H_ */