[tip: x86/urgent] x86/sev: Set up RMPOPT only on an active SNP host
From: tip-bot2 for Ashish Kalra
Date: Wed Nov 04 2026 - 21:35:29 EST
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: dc2334c1752b3c5f58af74f1e7ad6769b38e1f33
Gitweb: https://git.kernel.org/tip/dc2334c1752b3c5f58af74f1e7ad6769b38e1f33
Author: Ashish Kalra <ashish.kalra@xxxxxxx>
AuthorDate: Wed, 28 Oct 2026 19:49:38
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Wed, 04 Nov 2026 17:15:05 -08:00
x86/sev: Set up RMPOPT only on an active SNP host
rmpopt_init() setup work is gated only on X86_FEATURE_RMPOPT - a CPUID bit advertised
independently of whether SNP is active. As a device_initcall it runs on every system
with that bit, so on a host where SNP is not enabled (disabled in the BIOS, or AMD
IOMMU initialization fails to bring it up) 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.
Rather than add an explicit SNP-host gate to the initcall, set RMPOPT up where the
host SNP state is established. Call rmpopt_init() from the tail of
snp_rmptable_init(), which runs only once the host RMP table has been set up and
CC_ATTR_HOST_SEV_SNP is guaranteed, and drop the device_initcall.
This is soft initialization only - the workqueue and the announcement; the actual
RMPOPT_BASE programming is still done later by snp_enable_rmpopt(), which re-checks
X86_FEATURE_RMPOPT, CC_ATTR_HOST_SEV_SNP and rmpopt_soft_init. An rmpopt_init()
failure is non-fatal to SNP and is intentionally ignored by snp_rmptable_init().
[ bp: Massage commit message. ]
Fixes: c6c6f156d192 ("x86/sev: Perform RMP optimizations asynchronously")
Suggested-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Reviewed-by: Pankaj Gupta <pankaj.gupta@xxxxxxx>
Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
Link: https://patch.msgid.link/331aeb2f29710865ec064bacf9edacaadde2b094.1793216372.git.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 417e6a4..4de9681 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -662,7 +662,6 @@ static int __init rmpopt_init(void)
return 0;
}
-device_initcall(rmpopt_init);
void snp_enable_rmpopt(void)
{
@@ -726,6 +725,8 @@ int __init snp_rmptable_init(void)
*/
crash_kexec_post_notifiers = true;
+ rmpopt_init();
+
return 0;
}