Skip to content

KVM: nSVM: Disallow bad L1 EFER for KVM_SET_NESTED_STATE

Sean Christopherson kvm lkml sashiko-reviews 2 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 6 repliesApplied
  2. v14 patches 19 repliesSuperseded

Changes in v2 from the cover letter

- Check walker->max_level, not w->cpu_role.base.level, to play nice with PAE paging on 32-bit hosts. [Sashiko]
- Force EFER.LMA=0 in nested_vmcb02_prepare_save() if EFER.LME=0 to avoid confusing MMU code.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/5KVM: nSVM: Reject KVM_SET_NESTED_STATE if L1 has EFER.LMA=1 && EFER.LME=0arch/x86/kvm/svm/nested.c+1 -00 replies
2/5KVM: nSVM: Ignore EFER.LMA if EFER.LME=0 when preparing L2 statearch/x86/kvm/svm/nested.c+4 -05 replies
3/5KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU hasarch/x86/kvm/mmu/paging_tmpl.h+7 -60 replies
4/5KVM: x86/mmu: Bug the VM if KVM calcs a CPU role with EFER.LMA=1 && CR4.PAE=0arch/x86/kvm/mmu/mmu.c+3 -00 replies
5/5KVM: x86/mmu: Convert MMU walker's bounds check from BUG_ON() to KVM_BUG_ON()arch/x86/kvm/mmu/paging_tmpl.h+3 -10 replies

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/5] KVM: nSVM: Disallow bad L1 EFER for KVM_SET_NESTED_STATE

Fix a bug where KVM allows userspace to set an impossible EFER for L1 via KVM_SET_NESTED_STATE, which ultimately can lead to KVM misconfiguring L2's MMU (yay, NPT!) and overflowing the guest_walker arrays. Then, harden the MMU against similar bugs (hopefully it works this time; nVMX also had a similar bug, but the "NPT uses L1's EFER/CR4" wrinkle rendered the existing hardening useless).

v2:
- Check walker->max_level, not w->cpu_role.base.level, to play nice with PAE paging on 32-bit hosts. [Sashiko]
- Force EFER.LMA=0 in nested_vmcb02_prepare_save() if EFER.LME=0 to avoid confusing MMU code.

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

Sean Christopherson (5):
KVM: nSVM: Reject KVM_SET_NESTED_STATE if L1 has EFER.LMA=1 &&

    EFER.LME=0
  KVM: nSVM: Ignore EFER.LMA if EFER.LME=0 when preparing L2 state
  KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the
    MMU has
  KVM: x86/mmu: Bug the VM if KVM calcs a CPU role with EFER.LMA=1 &&
    CR4.PAE=0
  KVM: x86/mmu: Convert MMU walker's bounds check from BUG_ON() to
    KVM_BUG_ON()
 arch/x86/kvm/mmu/mmu.c         |  3 +++
 arch/x86/kvm/mmu/paging_tmpl.h | 17 ++++++++++-------
 arch/x86/kvm/svm/nested.c      |  5 +++++
 3 files changed, 18 insertions(+), 7 deletions(-)

base-commit: 76671054f9a1ff6abb976583cd8da37650acdc97

Signature · 1 line
2.55.0.970.g62bdec98f9-goog