Skip to content

Commit 4ae47fa

Browse files
Pavan Kumar Paluribp3tk0v
authored andcommitted
x86/virt: Move SEV-specific parsing into arch/x86/virt/svm
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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8e929cb commit 4ae47fa

File tree

4 files changed

+61
-44
lines changed

4 files changed

+61
-44
lines changed

arch/x86/coco/sev/core.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -141,33 +141,6 @@ static DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
141141
static DEFINE_PER_CPU(struct svsm_ca *, svsm_caa);
142142
static DEFINE_PER_CPU(u64, svsm_caa_pa);
143143

144-
struct sev_config {
145-
__u64 debug : 1,
146-
147-
/*
148-
* Indicates when the per-CPU GHCB has been created and registered
149-
* and thus can be used by the BSP instead of the early boot GHCB.
150-
*
151-
* For APs, the per-CPU GHCB is created before they are started
152-
* and registered upon startup, so this flag can be used globally
153-
* for the BSP and APs.
154-
*/
155-
ghcbs_initialized : 1,
156-
157-
/*
158-
* Indicates when the per-CPU SVSM CA is to be used instead of the
159-
* boot SVSM CA.
160-
*
161-
* For APs, the per-CPU SVSM CA is created as part of the AP
162-
* bringup, so this flag can be used globally for the BSP and APs.
163-
*/
164-
use_cas : 1,
165-
166-
__reserved : 61;
167-
};
168-
169-
static struct sev_config sev_cfg __read_mostly;
170-
171144
static __always_inline bool on_vc_stack(struct pt_regs *regs)
172145
{
173146
unsigned long sp = regs->sp;
@@ -2374,23 +2347,6 @@ static int __init report_snp_info(void)
23742347
}
23752348
arch_initcall(report_snp_info);
23762349

2377-
static int __init init_sev_config(char *str)
2378-
{
2379-
char *s;
2380-
2381-
while ((s = strsep(&str, ","))) {
2382-
if (!strcmp(s, "debug")) {
2383-
sev_cfg.debug = true;
2384-
continue;
2385-
}
2386-
2387-
pr_info("SEV command-line option '%s' was not recognized\n", s);
2388-
}
2389-
2390-
return 1;
2391-
}
2392-
__setup("sev=", init_sev_config);
2393-
23942350
static void update_attest_input(struct svsm_call *call, struct svsm_attest_call *input)
23952351
{
23962352
/* If (new) lengths have been returned, propagate them up */

arch/x86/include/asm/sev-common.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,31 @@ struct snp_psc_desc {
220220
#define GHCB_ERR_INVALID_INPUT 5
221221
#define GHCB_ERR_INVALID_EVENT 6
222222

223+
struct sev_config {
224+
__u64 debug : 1,
225+
226+
/*
227+
* Indicates when the per-CPU GHCB has been created and registered
228+
* and thus can be used by the BSP instead of the early boot GHCB.
229+
*
230+
* For APs, the per-CPU GHCB is created before they are started
231+
* and registered upon startup, so this flag can be used globally
232+
* for the BSP and APs.
233+
*/
234+
ghcbs_initialized : 1,
235+
236+
/*
237+
* Indicates when the per-CPU SVSM CA is to be used instead of the
238+
* boot SVSM CA.
239+
*
240+
* For APs, the per-CPU SVSM CA is created as part of the AP
241+
* bringup, so this flag can be used globally for the BSP and APs.
242+
*/
243+
use_cas : 1,
244+
245+
__reserved : 61;
246+
};
247+
248+
extern struct sev_config sev_cfg;
249+
223250
#endif

arch/x86/virt/svm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
22

33
obj-$(CONFIG_KVM_AMD_SEV) += sev.o
4+
obj-$(CONFIG_CPU_SUP_AMD) += cmdline.o

arch/x86/virt/svm/cmdline.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* AMD SVM-SEV command line parsing support
4+
*
5+
* Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc.
6+
*
7+
* Author: Michael Roth <[email protected]>
8+
*/
9+
10+
#include <linux/string.h>
11+
#include <linux/printk.h>
12+
#include <linux/cache.h>
13+
14+
#include <asm/sev-common.h>
15+
16+
struct sev_config sev_cfg __read_mostly;
17+
18+
static int __init init_sev_config(char *str)
19+
{
20+
char *s;
21+
22+
while ((s = strsep(&str, ","))) {
23+
if (!strcmp(s, "debug")) {
24+
sev_cfg.debug = true;
25+
continue;
26+
}
27+
28+
pr_info("SEV command-line option '%s' was not recognized\n", s);
29+
}
30+
31+
return 1;
32+
}
33+
__setup("sev=", init_sev_config);

0 commit comments

Comments
 (0)