From: Pavan Kumar Paluri Date: Mon, 14 Oct 2024 13:09:48 +0000 (-0500) Subject: x86/virt: Provide "nosnp" boot option for sev kernel command line X-Git-Tag: v6.13-rc1~183^2~10 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=2db67aaca578ec4998b78dc85e2af214bc2e2770;p=linux-block.git x86/virt: Provide "nosnp" boot option for sev kernel command line Provide a "nosnp" kernel command line option to prevent enabling of the RMP and SEV-SNP features in the host/hypervisor. Not initializing the RMP removes system overhead associated with RMP checks. [ bp: Actually make it a HV-only cmdline option. ] Co-developed-by: Eric Van Tassell Signed-off-by: Eric Van Tassell Signed-off-by: Pavan Kumar Paluri Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/20241014130948.1476946-3-papaluri@amd.com --- diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Documentation/arch/x86/x86_64/boot-options.rst index 98d4805f0823..d69e3cfbdba5 100644 --- a/Documentation/arch/x86/x86_64/boot-options.rst +++ b/Documentation/arch/x86/x86_64/boot-options.rst @@ -305,3 +305,8 @@ The available options are: debug Enable debug messages. + + nosnp + Do not enable SEV-SNP (applies to host/hypervisor only). Setting + 'nosnp' avoids the RMP check overhead in memory accesses when + users do not want to run SEV-SNP guests. diff --git a/arch/x86/virt/svm/cmdline.c b/arch/x86/virt/svm/cmdline.c index add4bae3ebef..affa2759fa20 100644 --- a/arch/x86/virt/svm/cmdline.c +++ b/arch/x86/virt/svm/cmdline.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -25,6 +26,17 @@ static int __init init_sev_config(char *str) continue; } + if (!strcmp(s, "nosnp")) { + if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) { + setup_clear_cpu_cap(X86_FEATURE_SEV_SNP); + cc_platform_clear(CC_ATTR_HOST_SEV_SNP); + continue; + } else { + goto warn; + } + } + +warn: pr_info("SEV command-line option '%s' was not recognized\n", s); }