From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Jim Mattson <jmattson@google.com>
Subject: [PATCH 0/2] KVM: nVMX: Fix ept=n bugs where KVM runs L2 with guest CR3
Date: Wed, 3 Jun 2026 15:34:16 -0700 [thread overview]
Message-ID: <20260603223418.1720035-1-seanjc@google.com> (raw)
Fix two bugs where KVM can run L2 with a guest-controlled CR3. The underlying
flaw dates back to commit f087a02941fe ("KVM: nVMX: Stash L1's CR3 in
vmcs01.GUEST_CR3 on nested entry w/o EPT"). Past me claimed:
Smashing vmcs01.GUEST_CR3 is safe because nested VM-Exits, and the unwind,
reset KVM's MMU, i.e. vmcs01.GUEST_CR3 is guaranteed to be overwritten with
a shadow CR3 prior to re-entering L1.
which was and is true, _if_ a nested VM-Exit or the unwind is reached. If KVM
fails directly, vmcs01.GUEST_CR3 will be left pointing at L1's actual CR3, i.e.
KVM will run with legacy shadow paging a guest-controlled CR3, which is... not
good.
Note, the vTPR fix will cause KVM-Unit-Test's TPR Threshold test to fail when
run with warn_on_missed_cc=1:
FAIL: Use TPR shadow enabled: virtual-APIC address = 8000000: vmlaunch succeeds
FAIL: Use TPR shadow enabled: virtual-APIC address = 10000000: vmlaunch succeeds
...
FAIL: Use TPR shadow enabled: virtual-APIC address = ffffffffff000: vmlaunch succeeds
due to KVM actually accessing the virtual APIC page. Given that I'm pretty
sure I'm the only person that runs with warn_on_missed_cc=1, and that IMO this
is firmly a test bug (e.g. on bare metal I'm pretty sure there's guarantee
VMLAUNCH will succeed), I don't see any reason to try and make it "work" in
KVM. I might try to figure out a way to make the KUT testcase play nice, but
for now I'll just ignore the failures in my test runs.
Sean Christopherson (2):
KVM: nVMX: Move vTPR vs. TPR Threshold consistency check into "normal"
checks
KVM: nVMX: Don't use vmcs01.GUEST_CR3 to snapshot L1's CR3 when EPT is
disabled
arch/x86/kvm/vmx/nested.c | 86 ++++++++++++++++-----------------------
arch/x86/kvm/vmx/vmx.h | 7 ++++
2 files changed, 43 insertions(+), 50 deletions(-)
base-commit: d4bfaa66fa171089b9b9fb2dc17af9245f2b9b34
--
2.54.0.1032.g2f8565e1d1-goog
next reply other threads:[~2026-06-03 22:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 22:34 Sean Christopherson [this message]
2026-06-03 22:34 ` [PATCH 1/2] KVM: nVMX: Move vTPR vs. TPR Threshold consistency check into "normal" checks Sean Christopherson
2026-06-03 22:34 ` [PATCH 2/2] KVM: nVMX: Don't use vmcs01.GUEST_CR3 to snapshot L1's CR3 when EPT is disabled Sean Christopherson
2026-06-04 6:23 ` [PATCH 0/2] KVM: nVMX: Fix ept=n bugs where KVM runs L2 with guest CR3 Jim Mattson
2026-06-04 13:15 ` Sean Christopherson
2026-06-04 14:13 ` Jim Mattson
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=20260603223418.1720035-1-seanjc@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.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
all inboxes | Powered by JetHome®