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.
Co-developed-by: Eric Van Tassell <Eric.VanTassell@amd.com>
Signed-off-by: Eric Van Tassell <Eric.VanTassell@amd.com>
Signed-off-by: Pavan Kumar Paluri <papaluri@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
Documentation/arch/x86/x86_64/boot-options.rst | 5 +++++
arch/x86/virt/svm/cmdline.c | 7 +++++++
2 files changed, 12 insertions(+)
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..13e04547f4df 100644
--- a/arch/x86/virt/svm/cmdline.c
+++ b/arch/x86/virt/svm/cmdline.c
@@ -10,6 +10,7 @@
#include <linux/string.h>
#include <linux/printk.h>
#include <linux/cache.h>
+#include <linux/cpufeature.h>
#include <asm/sev-common.h>
@@ -25,6 +26,12 @@ static int __init init_sev_config(char *str)
continue;
}
+ if (!strcmp(s, "nosnp")) {
+ setup_clear_cpu_cap(X86_FEATURE_SEV_SNP);
+ cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
+ continue;
+ }
+
pr_info("SEV command-line option '%s' was not recognized\n", s);
}
--
2.34.1
On Mon, Oct 14, 2024 at 08:09:48AM -0500, Pavan Kumar Paluri wrote: > @@ -25,6 +26,12 @@ static int __init init_sev_config(char *str) > continue; > } > > + if (!strcmp(s, "nosnp")) { > + setup_clear_cpu_cap(X86_FEATURE_SEV_SNP); > + cc_platform_clear(CC_ATTR_HOST_SEV_SNP); > + continue; > + } Well, if it is a HV-only option, then it better be such: @@ -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); } -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Hello Boris, On 10/14/2024 10:40 AM, Borislav Petkov wrote: > On Mon, Oct 14, 2024 at 08:09:48AM -0500, Pavan Kumar Paluri wrote: >> @@ -25,6 +26,12 @@ static int __init init_sev_config(char *str) >> continue; >> } >> >> + if (!strcmp(s, "nosnp")) { >> + setup_clear_cpu_cap(X86_FEATURE_SEV_SNP); >> + cc_platform_clear(CC_ATTR_HOST_SEV_SNP); >> + continue; >> + } > > Well, if it is a HV-only option, then it better be such: > > @@ -25,6 +26,17 @@ static int __init init_sev_config(char *str) > continue; > } > > + if (!strcmp(s, "nosnp")) { > + if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) { Sure, it does make sense to add this check since nosnp is only a HV option. Thanks, Pavan > + 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); > } > >
The following commit has been merged into the x86/sev branch of tip:
Commit-ID: 2db67aaca578ec4998b78dc85e2af214bc2e2770
Gitweb: https://git.kernel.org/tip/2db67aaca578ec4998b78dc85e2af214bc2e2770
Author: Pavan Kumar Paluri <papaluri@amd.com>
AuthorDate: Mon, 14 Oct 2024 08:09:48 -05:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 15 Oct 2024 20:22:18 +02:00
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 <Eric.VanTassell@amd.com>
Signed-off-by: Eric Van Tassell <Eric.VanTassell@amd.com>
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-3-papaluri@amd.com
---
Documentation/arch/x86/x86_64/boot-options.rst | 5 +++++
arch/x86/virt/svm/cmdline.c | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Documentation/arch/x86/x86_64/boot-options.rst
index 98d4805..d69e3cf 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 add4bae..affa275 100644
--- a/arch/x86/virt/svm/cmdline.c
+++ b/arch/x86/virt/svm/cmdline.c
@@ -10,6 +10,7 @@
#include <linux/string.h>
#include <linux/printk.h>
#include <linux/cache.h>
+#include <linux/cpufeature.h>
#include <asm/sev-common.h>
@@ -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);
}
© 2016 - 2024 Red Hat, Inc.