xref: /linux/drivers/virt/coco/sev-guest/sev-guest.h (revision 2da68a77)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2021 Advanced Micro Devices, Inc.
4  *
5  * Author: Brijesh Singh <brijesh.singh@amd.com>
6  *
7  * SEV-SNP API spec is available at https://developer.amd.com/sev
8  */
9 
10 #ifndef __VIRT_SEVGUEST_H__
11 #define __VIRT_SEVGUEST_H__
12 
13 #include <linux/types.h>
14 
15 #define MAX_AUTHTAG_LEN		32
16 
17 /* See SNP spec SNP_GUEST_REQUEST section for the structure */
18 enum msg_type {
19 	SNP_MSG_TYPE_INVALID = 0,
20 	SNP_MSG_CPUID_REQ,
21 	SNP_MSG_CPUID_RSP,
22 	SNP_MSG_KEY_REQ,
23 	SNP_MSG_KEY_RSP,
24 	SNP_MSG_REPORT_REQ,
25 	SNP_MSG_REPORT_RSP,
26 	SNP_MSG_EXPORT_REQ,
27 	SNP_MSG_EXPORT_RSP,
28 	SNP_MSG_IMPORT_REQ,
29 	SNP_MSG_IMPORT_RSP,
30 	SNP_MSG_ABSORB_REQ,
31 	SNP_MSG_ABSORB_RSP,
32 	SNP_MSG_VMRK_REQ,
33 	SNP_MSG_VMRK_RSP,
34 
35 	SNP_MSG_TYPE_MAX
36 };
37 
38 enum aead_algo {
39 	SNP_AEAD_INVALID,
40 	SNP_AEAD_AES_256_GCM,
41 };
42 
43 struct snp_guest_msg_hdr {
44 	u8 authtag[MAX_AUTHTAG_LEN];
45 	u64 msg_seqno;
46 	u8 rsvd1[8];
47 	u8 algo;
48 	u8 hdr_version;
49 	u16 hdr_sz;
50 	u8 msg_type;
51 	u8 msg_version;
52 	u16 msg_sz;
53 	u32 rsvd2;
54 	u8 msg_vmpck;
55 	u8 rsvd3[35];
56 } __packed;
57 
58 struct snp_guest_msg {
59 	struct snp_guest_msg_hdr hdr;
60 	u8 payload[4000];
61 } __packed;
62 
63 #endif /* __VIRT_SEVGUEST_H__ */
64