]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/virt: Move SEV-specific parsing into arch/x86/virt/svm
authorPavan Kumar Paluri <papaluri@amd.com>
Mon, 14 Oct 2024 13:09:47 +0000 (08:09 -0500)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 15 Oct 2024 17:54:42 +0000 (19:54 +0200)
Move SEV-specific kernel command line option parsing support from
arch/x86/coco/sev/core.c to arch/x86/virt/svm/cmdline.c so that both
host and guest related SEV command line options can be supported.

No functional changes intended.

Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20241014130948.1476946-2-papaluri@amd.com
arch/x86/coco/sev/core.c
arch/x86/include/asm/sev-common.h
arch/x86/virt/svm/Makefile
arch/x86/virt/svm/cmdline.c [new file with mode: 0644]

index de1df0cb45dab2fe8716ee9c4303f032bba5dd5c..ff19e805e7a167c58a566584338a3ea88ba35836 100644 (file)
@@ -141,33 +141,6 @@ static DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
 static DEFINE_PER_CPU(struct svsm_ca *, svsm_caa);
 static DEFINE_PER_CPU(u64, svsm_caa_pa);
 
-struct sev_config {
-       __u64 debug             : 1,
-
-             /*
-              * Indicates when the per-CPU GHCB has been created and registered
-              * and thus can be used by the BSP instead of the early boot GHCB.
-              *
-              * For APs, the per-CPU GHCB is created before they are started
-              * and registered upon startup, so this flag can be used globally
-              * for the BSP and APs.
-              */
-             ghcbs_initialized : 1,
-
-             /*
-              * Indicates when the per-CPU SVSM CA is to be used instead of the
-              * boot SVSM CA.
-              *
-              * For APs, the per-CPU SVSM CA is created as part of the AP
-              * bringup, so this flag can be used globally for the BSP and APs.
-              */
-             use_cas           : 1,
-
-             __reserved        : 61;
-};
-
-static struct sev_config sev_cfg __read_mostly;
-
 static __always_inline bool on_vc_stack(struct pt_regs *regs)
 {
        unsigned long sp = regs->sp;
@@ -2374,23 +2347,6 @@ static int __init report_snp_info(void)
 }
 arch_initcall(report_snp_info);
 
-static int __init init_sev_config(char *str)
-{
-       char *s;
-
-       while ((s = strsep(&str, ","))) {
-               if (!strcmp(s, "debug")) {
-                       sev_cfg.debug = true;
-                       continue;
-               }
-
-               pr_info("SEV command-line option '%s' was not recognized\n", s);
-       }
-
-       return 1;
-}
-__setup("sev=", init_sev_config);
-
 static void update_attest_input(struct svsm_call *call, struct svsm_attest_call *input)
 {
        /* If (new) lengths have been returned, propagate them up */
index 98726c2b04f8525d8d08fb819bd06fc9347b7629..50f5666938c09768772e34c44758548f6fbe5184 100644 (file)
@@ -220,4 +220,31 @@ struct snp_psc_desc {
 #define GHCB_ERR_INVALID_INPUT         5
 #define GHCB_ERR_INVALID_EVENT         6
 
+struct sev_config {
+       __u64 debug             : 1,
+
+             /*
+              * Indicates when the per-CPU GHCB has been created and registered
+              * and thus can be used by the BSP instead of the early boot GHCB.
+              *
+              * For APs, the per-CPU GHCB is created before they are started
+              * and registered upon startup, so this flag can be used globally
+              * for the BSP and APs.
+              */
+             ghcbs_initialized : 1,
+
+             /*
+              * Indicates when the per-CPU SVSM CA is to be used instead of the
+              * boot SVSM CA.
+              *
+              * For APs, the per-CPU SVSM CA is created as part of the AP
+              * bringup, so this flag can be used globally for the BSP and APs.
+              */
+             use_cas           : 1,
+
+             __reserved        : 61;
+};
+
+extern struct sev_config sev_cfg;
+
 #endif
index ef2a31bdcc7044d093283393d7f5bbe88054efd8..eca6d71355facd7b166cd3159153440bd082b490 100644 (file)
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_KVM_AMD_SEV) += sev.o
+obj-$(CONFIG_CPU_SUP_AMD) += cmdline.o
diff --git a/arch/x86/virt/svm/cmdline.c b/arch/x86/virt/svm/cmdline.c
new file mode 100644 (file)
index 0000000..add4bae
--- /dev/null
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * AMD SVM-SEV command line parsing support
+ *
+ * Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc.
+ *
+ * Author: Michael Roth <michael.roth@amd.com>
+ */
+
+#include <linux/string.h>
+#include <linux/printk.h>
+#include <linux/cache.h>
+
+#include <asm/sev-common.h>
+
+struct sev_config sev_cfg __read_mostly;
+
+static int __init init_sev_config(char *str)
+{
+       char *s;
+
+       while ((s = strsep(&str, ","))) {
+               if (!strcmp(s, "debug")) {
+                       sev_cfg.debug = true;
+                       continue;
+               }
+
+               pr_info("SEV command-line option '%s' was not recognized\n", s);
+       }
+
+       return 1;
+}
+__setup("sev=", init_sev_config);