From: "Kalra, Ashish" <ashish.kalra@amd.com>
To: tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
seanjc@google.com, peterz@infradead.org, thomas.lendacky@amd.com,
herbert@gondor.apana.org.au, davem@davemloft.net,
ardb@kernel.org
Cc: pbonzini@redhat.com, aik@amd.com, Michael.Roth@amd.com,
KPrateek.Nayak@amd.com, Tycho.Andersen@amd.com,
Nathan.Fontenot@amd.com, jackyli@google.com, pgonda@google.com,
rientjes@google.com, jacobhxu@google.com, xin@zytor.com,
pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com,
dyoung@redhat.com, nikunj@amd.com, john.allen@amd.com,
darwi@linutronix.de, linux-kernel@vger.kernel.org,
linux-crypto@vger.kernel.org, kvm@vger.kernel.org,
linux-coco@lists.linux.dev
Subject: Re: [PATCH v4 0/7] Add RMPOPT support.
Date: Wed, 29 Apr 2026 18:07:41 -0500 [thread overview]
Message-ID: <e8ceeb35-b300-4f7e-8b91-775b141a89c4@amd.com> (raw)
In-Reply-To: <cover.1775874970.git.ashish.kalra@amd.com>
Hello Dave, Sean,
Looking forward to your feedback, comments, thoughts on RMPOPT v4 patch series.
Thanks,
Ashish
On 4/13/2026 2:42 PM, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
>
> In the SEV-SNP architecture, hypervisor and non-SNP guests are subject
> to RMP checks on writes to provide integrity of SEV-SNP guest memory.
>
> The RMPOPT architecture enables optimizations whereby the RMP checks
> can be skipped if 1GB regions of memory are known to not contain any
> SNP guest memory.
>
> RMPOPT is a new instruction designed to minimize the performance
> overhead of RMP checks for the hypervisor and non-SNP guests.
>
> RMPOPT instruction currently supports two functions. In case of the
> verify and report status function the CPU will read the RMP contents,
> verify the entire 1GB region starting at the provided SPA is HV-owned.
> For the entire 1GB region it checks that all RMP entries in this region
> are HV-owned (i.e, not in assigned state) and then accordingly updates
> the RMPOPT table to indicate if optimization has been enabled and
> provide indication to software if the optimization was successful.
>
> In case of report status function, the CPU returns the optimization
> status for the 1GB region.
>
> The RMPOPT table is managed by a combination of software and hardware.
> Software uses the RMPOPT instruction to set bits in the table,
> indicating that regions of memory are entirely HV-owned. Hardware
> automatically clears bits in the RMPOPT table when RMP contents are
> changed during RMPUPDATE instruction.
>
> For more information on the RMPOPT instruction, see the AMD64 RMPOPT
> technical documentation.
>
> As SNP is enabled by default the hypervisor and non-SNP guests are
> subject to RMP write checks to provide integrity of SNP guest memory.
>
> This patch-series adds support to enable RMP optimizations for up to
> 2TB of system RAM across the system and allow RMPUPDATE to disable
> those optimizations as SNP guests are launched.
>
> Support for RAM larger than 2 TB will be added in follow-on series.
>
> This series also introduces support to re-enable RMP optimizations
> during SNP guest termination, after guest pages have been converted
> back to shared.
>
> RMP optimizations are performed asynchronously by queuing work on a
> dedicated workqueue after a 10 second delay.
>
> Delaying work allows batching of multiple SNP guest terminations.
>
> Once 1GB hugetlb guest_memfd support is merged, support for
> re-enabling RMPOPT optimizations during 1GB page cleanup will be added
> in follow-on series.
>
> Additionally add debugfs interface to report per-CPU RMPOPT status
> across all system RAM.
>
> v4:
> - Add new wrmsrq_on_cpus() helper to write same u64 value to a
> per-CPU MSR across a cpumask without per-cpu struct allocation
> overhead.
> - Rename configure_and_enable_rmpopt() to snp_setup_rmpopt().
> - Use wrmsrq_on_cpus() instead of wrmsrq_on_cpu() loop for
> programming RMPOPT_BASE MSRs.
> - Add setup_clear_cpu_cap(X86_FEATURE_RMPOPT) if segmented RMP
> setup fails or workqueue allocation fails.
> - Add X86_FEATURE_RMPOPT feature clear logic in amd_cc_platform_clear()
> for CC_ATTR_HOST_SEV_SNP.
> - All of the above allow checking for only X86_FEATURE_RMPOPT for both
> RMPOPT setup/enable and RMP re-optimizations.
> - Rename snp_perform_rmp_optimization() to snp_rmpopt_all_physmem().
> - Split rmpopt() into rmpopt() and rmpopt_smp() for SMP callback use.
> - Introduce separate rmpopt_report_cpumask for debugfs reporting,
> distinct from rmpopt_cpumask used for primary thread tracking.
> - Remove snp_perform_rmp_optimization() call from __sev_snp_init_locked()
> and instead setup and enable RMPOPT after SNP is enabled and
> initialized.
>
> v3:
> - Drop all RMPOPT kthread support and introduce adding custom and
> dedicated workqueue to schedule delayed and asynchronous RMPOPT work.
> - Drop the guest_memfd inode cleanup interface and add support to
> re-enable RMP optimizations during guest shutdown using the
> asynchronous and delayed workqueue interface.
> - Introduce new __rmpopt() helper and rmpopt() and
> rmpopt_report_status() wrappers on top which use rax and rcx
> parameters to closely match RMPOPT specs.
> - Use new optimized RMPOPT loop to issue RMPOPT instructions on all
> system RAM upto 2TB and all CPUs, by optimizing each range on one CPU
> first, then let other CPUs execute RMPOPT in parallel so they can skip
> most work as the range has already been optimized.
> - Also add support for running the optimized RMPOPT loop only on
> one thread per core.
> - Replace all PUD_SIZE references with SZ_1G to conform to 1GB regions
> as specified by RMPOPT specifications and not be dependent on PUD_SIZE
> which makes the RMPOPT patch-set independent of x86 page table sizes.
> - Use wrmsrq_on_cpu() to program the RMPOPT_BASE MSR registers on
> all CPUs that removes all ugly casting to use on_each_cpu_mask().
> - Fix inline commits and patch commit messages
>
>
> v2:
> - Drop all NUMA and Socket configuration and enablement support and
> enable RMPOPT support for up to 2TB of system RAM.
> - Drop get_cpumask_of_primary_threads() and enable per-core RMPOPT
> base MSRs and issue RMPOPT instruction on all CPUs.
> - Drop the configfs interface to manually re-enable RMP optimizations.
> - Add new guest_memfd cleanup interface to automatically re-enable
> RMP optimizations during guest shutdown.
> - Include references to the public RMPOPT documentation.
> - Move debugfs directory for RMPOPT under architecuture specific
> parent directory.
>
> Ashish Kalra (7):
> x86/cpufeatures: Add X86_FEATURE_AMD_RMPOPT feature flag
> x86/msr: add wrmsrq_on_cpus helper
> x86/sev: Initialize RMPOPT configuration MSRs
> x86/sev: Add support to perform RMP optimizations asynchronously
> x86/sev: Add interface to re-enable RMP optimizations.
> KVM: SEV: Perform RMP optimizations on SNP guest shutdown
> x86/sev: Add debugfs support for RMPOPT
>
> arch/x86/coco/core.c | 1 +
> arch/x86/include/asm/cpufeatures.h | 2 +-
> arch/x86/include/asm/msr-index.h | 3 +
> arch/x86/include/asm/msr.h | 5 +
> arch/x86/include/asm/sev.h | 4 +
> arch/x86/kernel/cpu/scattered.c | 1 +
> arch/x86/kvm/svm/sev.c | 2 +
> arch/x86/lib/msr-smp.c | 20 +++
> arch/x86/virt/svm/sev.c | 271 ++++++++++++++++++++++++++++-
> drivers/crypto/ccp/sev-dev.c | 3 +
> 10 files changed, 310 insertions(+), 2 deletions(-)
>
> --
> 2.43.0
>
>
prev parent reply other threads:[~2026-04-29 23:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 19:42 [PATCH v4 0/7] Add RMPOPT support Ashish Kalra
2026-04-13 19:42 ` [PATCH v4 1/7] x86/cpufeatures: Add X86_FEATURE_AMD_RMPOPT feature flag Ashish Kalra
2026-05-01 16:37 ` Ackerley Tng
2026-04-13 19:42 ` [PATCH v4 2/7] x86/msr: add wrmsrq_on_cpus helper Ashish Kalra
2026-05-01 18:33 ` Ackerley Tng
2026-04-13 19:43 ` [PATCH v4 3/7] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-05-01 18:12 ` Ackerley Tng
2026-05-05 20:04 ` Kalra, Ashish
2026-04-13 19:43 ` [PATCH v4 4/7] x86/sev: Add support to perform RMP optimizations asynchronously Ashish Kalra
2026-05-01 18:57 ` Ackerley Tng
2026-05-05 20:30 ` Kalra, Ashish
2026-04-13 19:43 ` [PATCH v4 5/7] x86/sev: Add interface to re-enable RMP optimizations Ashish Kalra
2026-05-01 19:04 ` Ackerley Tng
2026-04-13 19:44 ` [PATCH v4 6/7] KVM: SEV: Perform RMP optimizations on SNP guest shutdown Ashish Kalra
2026-05-01 19:12 ` Ackerley Tng
2026-05-05 20:34 ` Kalra, Ashish
2026-04-13 19:44 ` [PATCH v4 7/7] x86/sev: Add debugfs support for RMPOPT Ashish Kalra
2026-04-29 23:07 ` Kalra, Ashish [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8ceeb35-b300-4f7e-8b91-775b141a89c4@amd.com \
--to=ashish.kalra@amd.com \
--cc=KPrateek.Nayak@amd.com \
--cc=Michael.Roth@amd.com \
--cc=Nathan.Fontenot@amd.com \
--cc=Tycho.Andersen@amd.com \
--cc=aik@amd.com \
--cc=ardb@kernel.org \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=darwi@linutronix.de \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dyoung@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=jackyli@google.com \
--cc=jacobhxu@google.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=pgonda@google.com \
--cc=rientjes@google.com \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
--cc=xin@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox