mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/5] KVM: x86: Fix nested CR3 load bugs
@ 2026-11-17 21:09 Sean Christopherson
  2026-11-17 21:09 ` [PATCH v2 1/5] KVM: nSVM: Pre-check current (L2's) CR3 during KVM_SET_NESTED_STATE Sean Christopherson
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sean Christopherson @ 2026-11-17 21:09 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: kvm, linux-kernel, Stefan Teodorescu, Sashiko Bot, syzbot, Chris Mason

Fix a variety of bugs related to KVM's handling of CR3 loads during nested
transitions.  I originally tried to fix a svm_set_nested_state() bug by
forcing the vCPU back into L1 if a late CR3 load fails, but Sashiko rightly
hated on that patch because forcing the vCPU from L2=>L1 would still leave
vCPU state in a half-baked state.

I finally realized that Paolo's patch to always check CR3 validity is the way
to go, svm_set_nested_state() just needs to also pre-check the current CR3
(because userspace could theoretically stuff a then-legal CR3 and then swizzle
CPUID to make CR3 illegal).

Patch 5 fixes another related flaw where KVM doesn't initialize the MMU if
loading PDPTRs on nested VM-Exit fails.  Patches 3-4 are cleanups and prep
work to dedup the nSVM vs. nVMX code to avoid copy+paste and confusing code
for the final fix.

v2:
 - Pre-check the current CR3 in svm_set_nested_state(). [Sashiko]
 - Pull in Paolo's fix. [Sashiko]
 - Add patches 3-5.

v1: https://lore.kernel.org/all/20261113170405.473841-1-seanjc@google.com

Paolo Bonzini (1):
  KVM: nVMX/nSVM: check unconditionally whether CR3 is valid

Sean Christopherson (4):
  KVM: nSVM: Pre-check current (L2's) CR3 during KVM_SET_NESTED_STATE
  KVM: nSVM: Mark CR3 as dirty when loading CR3 on nested transitions
  KVM: x86: Consolidate nVMX vs. nSVM logic for loading CR3 on nested
    xfer
  KVM: x86: Initialize MMU+PGD before loading PDPTRs on nested
    transitions

 arch/x86/kvm/mmu/mmu.c    |  2 --
 arch/x86/kvm/regs.c       | 30 ++++++++++++++++++++++++++++++
 arch/x86/kvm/regs.h       |  2 ++
 arch/x86/kvm/svm/nested.c | 36 ++++++++++--------------------------
 arch/x86/kvm/vmx/nested.c | 31 ++++---------------------------
 5 files changed, 46 insertions(+), 55 deletions(-)


base-commit: d21eef2084a9af87ac2a783bc7c2b175ba114e4e
-- 
2.56.1.703.gf848ed807c-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-17 21:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 21:09 [PATCH v2 0/5] KVM: x86: Fix nested CR3 load bugs Sean Christopherson
2026-11-17 21:09 ` [PATCH v2 1/5] KVM: nSVM: Pre-check current (L2's) CR3 during KVM_SET_NESTED_STATE Sean Christopherson
2026-11-17 21:09 ` [PATCH v2 2/5] KVM: nVMX/nSVM: check unconditionally whether CR3 is valid Sean Christopherson
2026-11-17 21:09 ` [PATCH v2 3/5] KVM: nSVM: Mark CR3 as dirty when loading CR3 on nested transitions Sean Christopherson
2026-11-17 21:09 ` [PATCH v2 4/5] KVM: x86: Consolidate nVMX vs. nSVM logic for loading CR3 on nested xfer Sean Christopherson
2026-11-17 21:09 ` [PATCH v2 5/5] KVM: x86: Initialize MMU+PGD before loading PDPTRs on nested transitions 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®