* [PATCH] KVM: x86: Fix ERAPS RAP clear on INVPCID single-context invalidation
@ 2026-05-18 13:59 Emily Ehlert
2026-05-27 18:09 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Emily Ehlert @ 2026-05-18 13:59 UTC (permalink / raw)
To: seanjc, pbonzini
Cc: amit.shah, tglx, mingo, bp, dave.hansen, hpa, x86, kvm,
linux-kernel, nh-open-source, graf, nsaenz, Emily Ehlert
Use kvm_register_mark_dirty() instead of kvm_register_is_dirty() to
actually mark VCPU_EXREG_ERAPS as dirty when emulating
INVPCID_TYPE_SINGLE_CTXT. kvm_register_is_dirty() is a read-only
predicate whose return value is discarded, making the call a no-op.
Without this fix, a single-context INVPCID will not trigger a RAP clear
on the next VMRUN, breaking the ERAPS security guarantee.
Fixes: db5e82496492 ("KVM: SVM: Virtualize and advertise support for ERAPS")
Signed-off-by: Emily Ehlert <ehemily@amazon.de>
---
Hi,
we recently discovered a SVM bug where ERAPS are not properly cleared,
this may have security implications. I attached an AI assisted security
analysis.
The bug is reachable when INVPCID is intercepted while ERAPS is exposed
to the guest. When NPT is disabled then INVPCID is always intercepted
when shadow paging is acive. ERAPS can I think be active while NPT is
disabled (commit does not guard against it). So when triggered the
consequence is that the guest retains stale RAP entries after the
INVPCID call. A malicious guest could exploit this to speculatively
influence return predictions of another process within the same guest
underminding the ERAP security gurantee that the RAP is cleared in the
PCID invalidation.
Severity: Low-Medium. Exploitation requires either an unusual host
configuration (npt=0, which is primarily a debugging mode) or a nested
virtualization setup with a cooperative L1 hypervisor. The attack is
intra-guest (guest process vs. guest kernel), not guest-to-host, since
ERAPS hardware tagging still separates host and guest RAP entries.
arch/x86/kvm/x86.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fd1c4a36b5936..181a78c30260d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -14207,7 +14207,7 @@ int kvm_handle_invpcid(struct kvm_vcpu *vcpu, unsigned long type, gva_t gva)
* the RAP (Return Address Predicator).
*/
if (guest_cpu_cap_has(vcpu, X86_FEATURE_ERAPS))
- kvm_register_is_dirty(vcpu, VCPU_EXREG_ERAPS);
+ kvm_register_mark_dirty(vcpu, VCPU_EXREG_ERAPS);
kvm_invalidate_pcid(vcpu, operand.pcid);
return kvm_skip_emulated_instruction(vcpu);
--
2.47.3
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86: Fix ERAPS RAP clear on INVPCID single-context invalidation
2026-05-18 13:59 [PATCH] KVM: x86: Fix ERAPS RAP clear on INVPCID single-context invalidation Emily Ehlert
@ 2026-05-27 18:09 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2026-05-27 18:09 UTC (permalink / raw)
To: Sean Christopherson, pbonzini, Emily Ehlert
Cc: amit.shah, mingo, bp, dave.hansen, hpa, x86, kvm, linux-kernel,
nh-open-source, graf, nsaenz, Thomas Gleixner
On Mon, 18 May 2026 13:59:56 +0000, Emily Ehlert wrote:
> Use kvm_register_mark_dirty() instead of kvm_register_is_dirty() to
> actually mark VCPU_EXREG_ERAPS as dirty when emulating
> INVPCID_TYPE_SINGLE_CTXT. kvm_register_is_dirty() is a read-only
> predicate whose return value is discarded, making the call a no-op.
> Without this fix, a single-context INVPCID will not trigger a RAP clear
> on the next VMRUN, breaking the ERAPS security guarantee.
>
> [...]
Applied to kvm-x86 fixes, thanks!
[1/1] KVM: x86: Fix ERAPS RAP clear on INVPCID single-context invalidation
https://github.com/kvm-x86/linux/commit/b60621c5121c
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-27 18:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-18 13:59 [PATCH] KVM: x86: Fix ERAPS RAP clear on INVPCID single-context invalidation Emily Ehlert
2026-05-27 18:09 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®