From: Emily Ehlert <ehemily@amazon.de>
To: <seanjc@google.com>, <pbonzini@redhat.com>
Cc: <amit.shah@amd.com>, <tglx@linutronix.de>, <mingo@redhat.com>,
<bp@alien8.de>, <dave.hansen@linux.intel.com>, <hpa@zytor.com>,
<x86@kernel.org>, <kvm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <nh-open-source@amazon.com>,
<graf@amazon.de>, <nsaenz@kernel.org>,
"Emily Ehlert" <ehemily@amazon.de>
Subject: [PATCH] KVM: x86: Fix ERAPS RAP clear on INVPCID single-context invalidation
Date: Mon, 18 May 2026 13:59:56 +0000 [thread overview]
Message-ID: <20260518135956.82569-1-ehemily@amazon.de> (raw)
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
next reply other threads:[~2026-05-18 14:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 13:59 Emily Ehlert [this message]
2026-05-27 18:09 ` Sean Christopherson
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=20260518135956.82569-1-ehemily@amazon.de \
--to=ehemily@amazon.de \
--cc=amit.shah@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=graf@amazon.de \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nh-open-source@amazon.com \
--cc=nsaenz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®