Re: [PATCH 0/6] Add RMPOPT support.
From: Kalra, Ashish
Date: Tue Feb 17 2026 - 23:13:23 EST
Hello Dave,
On 2/17/2026 4:11 PM, Dave Hansen wrote:
> On 2/17/26 12:09, Ashish Kalra wrote:
>> RMPOPT is a new instruction designed to minimize the performance
>> overhead of RMP checks for the hypervisor and non-SNP guests.
>
> This needs a little theory of operation for the new instruction. It
> seems like it will enable optimizations all by itself. You just call it,
> and it figures out when the CPU can optimize things. The CPU also
> figures out when the optimization must be flipped off.
Yes, i will add more theory of operation for the new instruction.
RMPOPT instruction with the verify and report status operation, in this operation
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 update the RMPOPT table to indicate if optimization has been enabled
and provide indication to software if the optimization was successful.
RMPUPDATE instruction that mark new pages as assigned will automatically clear the
optimizations and the appropriate bit in the RMPOPT table.
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.
>
> That's not awful.
>
> To be honest, though, I think this is misdesigned. Shouldn't the CPU
> *boot* in a state where it is optimized? Why should software have to
> tell it that coming out of reset, there is no SEV-SNP memory?
When the CPU boots, the RMP checks are not done and therefore the CPU
is booting in a state where it is optimized.
The RMP checks are not enabled till SEV-SNP is enabled and SNP is enabled
during kernel boot (as part of iommu_snp_enable() -> snp_rmptable_init()).
Once SNP is enabled as part of kernel boot, hypervisor and non-SNP guests are
subject to RMP checks on writes to provide integrity of SEV-SNP guest memory.
Therefore, we need to enable these RMP optimizations after SNP has been
enabled to indicate which 1GB regions of memory are known to not contain any
SEV-SNP guest memory.
I will add the above details to the cover letter for the next revision of this
patch series.
Thanks,
Ashish