[PATCH v2 2/2] x86/sev: Only announce RMPOPT optimizations when SNP is enabled

From: Ashish Kalra

Date: Wed Oct 14 2026 - 17:15:27 EST


From: Ashish Kalra <ashish.kalra@xxxxxxx>

rmpopt_init() sets up the RMPOPT workqueue and prints "RMPOPT
optimizations enabled" gated only on X86_FEATURE_RMPOPT, which is a CPUID
bit advertised independently of whether SNP is active. On a system where
SNP is disabled in the BIOS the workqueue is allocated and the message is
printed at boot even though RMPOPT is never used (snp_enable_rmpopt() bails
out on a non-SNP host).

X86_FEATURE_SEV_SNP is resolved in bsp_determine_snp(), well before this
initcall, and is cleared when the SNP host cannot be brought up (including
SNP disabled in the BIOS). Gate rmpopt_init() on it as well, so the setup
and the announcement only happen on an SNP host.

Suggested-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
Fixes: c6c6f156d192 ("x86/sev: Perform RMP optimizations asynchronously")
Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx>
---
arch/x86/virt/svm/sev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 43e4945e6cdf..81b9efd55c51 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -639,7 +639,8 @@ static void do_rmpopt_work(struct work_struct *work)

static int __init rmpopt_init(void)
{
- if (!cpu_feature_enabled(X86_FEATURE_RMPOPT))
+ if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP) ||
+ !cpu_feature_enabled(X86_FEATURE_RMPOPT))
return -ENODEV;

rmpopt_wq = alloc_workqueue("rmpopt_wq", WQ_PERCPU, 1);
--
2.43.0