]> www.infradead.org Git - nvme.git/commitdiff
x86/sev: Move sev_guest.h into common SEV header
authorMichael Roth <michael.roth@amd.com>
Mon, 1 Jul 2024 22:31:47 +0000 (17:31 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Jul 2024 15:44:00 +0000 (11:44 -0400)
sev_guest.h currently contains various definitions relating to the
format of SNP_GUEST_REQUEST commands to SNP firmware. Currently only the
sev-guest driver makes use of them, but when the KVM side of this is
implemented there's a need to parse the SNP_GUEST_REQUEST header to
determine whether additional information needs to be provided to the
guest. Prepare for this by moving those definitions to a common header
that's shared by host/guest code so that KVM can also make use of them.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Liam Merwick <liam.merwick@oracle.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Message-ID: <20240701223148.3798365-3-michael.roth@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/sev.h
drivers/virt/coco/sev-guest/sev-guest.c
drivers/virt/coco/sev-guest/sev-guest.h [deleted file]

index 14394407245ce22434699e4e4bae6955f1138bd7..d000f8c4c9452ef077615aa63815532ee5398cf1 100644 (file)
@@ -119,6 +119,54 @@ struct snp_req_data {
        unsigned int data_npages;
 };
 
+#define MAX_AUTHTAG_LEN                32
+
+/* See SNP spec SNP_GUEST_REQUEST section for the structure */
+enum msg_type {
+       SNP_MSG_TYPE_INVALID = 0,
+       SNP_MSG_CPUID_REQ,
+       SNP_MSG_CPUID_RSP,
+       SNP_MSG_KEY_REQ,
+       SNP_MSG_KEY_RSP,
+       SNP_MSG_REPORT_REQ,
+       SNP_MSG_REPORT_RSP,
+       SNP_MSG_EXPORT_REQ,
+       SNP_MSG_EXPORT_RSP,
+       SNP_MSG_IMPORT_REQ,
+       SNP_MSG_IMPORT_RSP,
+       SNP_MSG_ABSORB_REQ,
+       SNP_MSG_ABSORB_RSP,
+       SNP_MSG_VMRK_REQ,
+       SNP_MSG_VMRK_RSP,
+
+       SNP_MSG_TYPE_MAX
+};
+
+enum aead_algo {
+       SNP_AEAD_INVALID,
+       SNP_AEAD_AES_256_GCM,
+};
+
+struct snp_guest_msg_hdr {
+       u8 authtag[MAX_AUTHTAG_LEN];
+       u64 msg_seqno;
+       u8 rsvd1[8];
+       u8 algo;
+       u8 hdr_version;
+       u16 hdr_sz;
+       u8 msg_type;
+       u8 msg_version;
+       u16 msg_sz;
+       u32 rsvd2;
+       u8 msg_vmpck;
+       u8 rsvd3[35];
+} __packed;
+
+struct snp_guest_msg {
+       struct snp_guest_msg_hdr hdr;
+       u8 payload[4000];
+} __packed;
+
 struct sev_guest_platform_data {
        u64 secrets_gpa;
 };
index 87f241825bc360fcc8af7d6f48e10d2b68d0fcb0..41e185ad0681d7d5514b403e85f0aff3d73ba328 100644 (file)
@@ -29,8 +29,6 @@
 #include <asm/svm.h>
 #include <asm/sev.h>
 
-#include "sev-guest.h"
-
 #define DEVICE_NAME    "sev-guest"
 #define AAD_LEN                48
 #define MSG_HDR_VER    1
diff --git a/drivers/virt/coco/sev-guest/sev-guest.h b/drivers/virt/coco/sev-guest/sev-guest.h
deleted file mode 100644 (file)
index 21bda26..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2021 Advanced Micro Devices, Inc.
- *
- * Author: Brijesh Singh <brijesh.singh@amd.com>
- *
- * SEV-SNP API spec is available at https://developer.amd.com/sev
- */
-
-#ifndef __VIRT_SEVGUEST_H__
-#define __VIRT_SEVGUEST_H__
-
-#include <linux/types.h>
-
-#define MAX_AUTHTAG_LEN                32
-
-/* See SNP spec SNP_GUEST_REQUEST section for the structure */
-enum msg_type {
-       SNP_MSG_TYPE_INVALID = 0,
-       SNP_MSG_CPUID_REQ,
-       SNP_MSG_CPUID_RSP,
-       SNP_MSG_KEY_REQ,
-       SNP_MSG_KEY_RSP,
-       SNP_MSG_REPORT_REQ,
-       SNP_MSG_REPORT_RSP,
-       SNP_MSG_EXPORT_REQ,
-       SNP_MSG_EXPORT_RSP,
-       SNP_MSG_IMPORT_REQ,
-       SNP_MSG_IMPORT_RSP,
-       SNP_MSG_ABSORB_REQ,
-       SNP_MSG_ABSORB_RSP,
-       SNP_MSG_VMRK_REQ,
-       SNP_MSG_VMRK_RSP,
-
-       SNP_MSG_TYPE_MAX
-};
-
-enum aead_algo {
-       SNP_AEAD_INVALID,
-       SNP_AEAD_AES_256_GCM,
-};
-
-struct snp_guest_msg_hdr {
-       u8 authtag[MAX_AUTHTAG_LEN];
-       u64 msg_seqno;
-       u8 rsvd1[8];
-       u8 algo;
-       u8 hdr_version;
-       u16 hdr_sz;
-       u8 msg_type;
-       u8 msg_version;
-       u16 msg_sz;
-       u32 rsvd2;
-       u8 msg_vmpck;
-       u8 rsvd3[35];
-} __packed;
-
-struct snp_guest_msg {
-       struct snp_guest_msg_hdr hdr;
-       u8 payload[4000];
-} __packed;
-
-#endif /* __VIRT_SEVGUEST_H__ */