Re: [PATCH v4 1/2] x86/sev: Clear RMPOPT when segmented RMP is disabled by firmware

From: Borislav Petkov

Date: Mon Nov 02 2026 - 00:30:07 EST


Ok,

pls check if this works too:

From: Ashish Kalra <ashish.kalra@xxxxxxx>
Date: Wed, 28 Oct 2026 19:49:22 +0000
Subject: [PATCH] x86/sev: Clear RMPOPT when segmented RMP is disabled by firmware

Segmented RMP support is advertised via X86_FEATURE_SEGMENTED_RMP, and the
firmware enables it via MSR_AMD64_RMP_CFG[SEG_RMP_ENABLED]. The latter can be
cleared in platform BIOS by the user, in which case the system runs in
contiguous RMP setting.

snp_probe_rmptable_info() does not clear X86_FEATURE_RMPOPT in the
advertised-but-firmware-disabled case.

As a result, this does not prevent snp_enable_rmpopt() from trying to program
MSR_AMD64_RMPOPT_BASE, which raises a #GP on the MSR access.

Make sure X86_FEATURE_RMPOPT is cleared in all cases where segmented RMP is
not enabled.

[ bp:
- Put the commit message on Ozempic
- Flip the logic in the function so that the segmented RMP disabled
case goes first and the flow gets simpler this way. ]

Fixes: 15d974be0a3b ("x86/sev: Initialize RMPOPT configuration MSRs")
Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://patch.msgid.link/56da047d63b22f03a7e709fc172a5543da894d67.1793216372.git.ashish.kalra@xxxxxxx
---
arch/x86/virt/svm/sev.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index bd70c4d0b774..ff6d17795054 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -817,21 +817,20 @@ static bool probe_segmented_rmptable_info(void)

bool snp_probe_rmptable_info(void)
{
- if (cpu_feature_enabled(X86_FEATURE_SEGMENTED_RMP)) {
- rdmsrq(MSR_AMD64_RMP_CFG, rmp_cfg);
+ if (!cpu_feature_enabled(X86_FEATURE_SEGMENTED_RMP)) {
+ setup_clear_cpu_cap(X86_FEATURE_RMPOPT);

- if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
- if (probe_segmented_rmptable_info())
- return true;
+ return probe_contiguous_rmptable_info();
+ }

- setup_clear_cpu_cap(X86_FEATURE_RMPOPT);
- return false;
- }
- } else {
- setup_clear_cpu_cap(X86_FEATURE_RMPOPT);
+ rdmsrq(MSR_AMD64_RMP_CFG, rmp_cfg);
+ if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
+ if (probe_segmented_rmptable_info())
+ return true;
}

- return probe_contiguous_rmptable_info();
+ setup_clear_cpu_cap(X86_FEATURE_RMPOPT);
+ return false;
}

/*
--
2.53.0

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette