Re: [PATCH v12 3/5] x86/sev: Initialize RMPOPT configuration MSRs

From: Borislav Petkov

Date: Wed Aug 26 2026 - 22:07:30 EST


On Mon, Aug 10, 2026 at 07:21:53PM +0000, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@xxxxxxx>
>
> The new RMPOPT instruction helps manage per-CPU RMP optimization
> structures inside the CPU. It takes a 1GB-aligned physical address
> and either returns the status of the optimizations or tries to enable
> the optimizations.
>
> Per-CPU RMPOPT tables support at most 2 TB of addressable memory for
> RMP optimizations.
>
> Initialize the per-CPU RMPOPT table base to the starting physical
> address. This enables RMP optimization for up to 2 TB of system RAM on
> all CPUs.
>
> Additionally, add support to setup and enable RMPOPT once SNP is
> enabled and initialized.
>
> Suggested-by: Thomas Lendacky <thomas.lendacky@xxxxxxx>
> Suggested-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Suggested-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
> Suggested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> Reviewed-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> Signed-off-by: Ashish Kalra <ashish.kalra@xxxxxxx>
> ---
> arch/x86/include/asm/msr-index.h | 3 ++
> arch/x86/include/asm/sev.h | 2 +
> arch/x86/virt/svm/sev.c | 75 +++++++++++++++++++++++++++++---
> drivers/crypto/ccp/sev-dev.c | 2 +
> 4 files changed, 77 insertions(+), 5 deletions(-)

Some cleanups ontop:

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 923b7869acd1..982753002a3c 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -558,7 +558,7 @@ int snp_prepare(void)
}
EXPORT_SYMBOL_FOR_MODULES(snp_prepare, "ccp");

-static void snp_cleanup_rmpopt(void)
+static void rmpopt_disable(void)
{
int cpu;

@@ -577,8 +577,7 @@ void snp_shutdown(void)
if (syscfg & MSR_AMD64_SYSCFG_SNP_EN)
return;

- /* Disable RMPOPT while CPU hotplug is disabled. */
- snp_cleanup_rmpopt();
+ rmpopt_disable();

clear_rmp();
on_each_cpu(mfd_reconfigure, NULL, 1);
@@ -612,8 +611,7 @@ void snp_setup_rmpopt(void)
}

/*
- * The RMPOPT_BASE MSR is per-core, so only one thread per core needs
- * to set up the RMPOPT_BASE MSR. All primary threads are online,
+ * The RMPOPT_BASE MSR has core scope. All primary threads are online,
* otherwise SNP would not have been enabled.
*/
for_each_online_cpu(cpu)

--
Regards/Gruss,
Boris.

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