Skip to content

KVM: nVMX: Fix ept=n bugs where KVM runs L2 with guest CR3

Sean Christopherson kvm lkml sashiko-reviews 2 versions – Applied

Status from this message: Applied to kvm-x86 fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 2 repliesApplied
  2. v12 patches 4 repliesSuperseded

Changes in v2 from the cover letter

- Use kvm_read_cr3() to read vcpu->arch.cr3. [Sashiko]
- Skip consistency check if reading vTPR fails. [Jim]

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/2KVM: nVMX: Move vTPR vs. TPR Threshold consistency check into "normal" checksarch/x86/kvm/vmx/nested.c+29 -370 replies
2/2KVM: nVMX: Don't use vmcs01.GUEST_CR3 to snapshot L1's CR3 when EPT is disabledarch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/vmx.h+15 -131 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] KVM: nVMX: Fix ept=n bugs where KVM runs L2 with guest CR3

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.

v2:
- Use kvm_read_cr3() to read vcpu->arch.cr3. [Sashiko]
- Skip consistency check if reading vTPR fails. [Jim]

v1: https://lore.kernel.org/all/[email protected]

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 | 87 +++++++++++++++++----------------------
 arch/x86/kvm/vmx/vmx.h    |  7 ++++
 2 files changed, 44 insertions(+), 50 deletions(-)

base-commit: de3a35be92d2391ece4bf3143ef2887192625fd0

Signature · 1 line
2.54.0.1136.gdb2ca164c4-goog