Skip to content

KVM: VMX: Fix MMIO Stale Data Mitigation

Sean Christopherson kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 10 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5KVM: x86: Avoid calling kvm_is_mmio_pfn() when kvm_x86_ops.get_mt_mask is NULLarch/x86/kvm/mmu/spte.c+3 -10 replies
2/5KVM: x86/mmu: Locally cache whether a PFN is host MMIO when making a SPTEarch/x86/kvm/mmu/spte.c+18 -40 replies
3/5KVM: VMX: Apply MMIO Stale Data mitigation if KVM maps MMIO into the guestarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu/mmu_internal.h arch/x86/kvm/mmu/spte.c +3 more+48 -55 replies
4/5Revert "kvm: detect assigned device via irqbypass manager"arch/x86/kvm/irq.c+1 -80 replies
5/5VFIO: KVM: x86: Drop kvm_arch_{start,end}_assignment()arch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c include/linux/kvm_host.h +1 more+0 -410 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

PatchPawan Gupta
SeriesT-b
1/5
2/5
3/5
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] KVM: VMX: Fix MMIO Stale Data Mitigation

Fix KVM's mitigation of the MMIO Stale Data bug, as the current approach doesn't actually detect whether or not a guest has access to MMIO. E.g. KVM_DEV_VFIO_FILE_ADD is entirely optional, and obviously only covers VFIO devices, and so is a terrible heuristic for "can this vCPU access MMIO?"

To fix the flaw (hopefully), track whether or not a vCPU has access to MMIO based on the MMU it will run with. KVM already detects host MMIO when installing PTEs in order to force host MMIO to UC (EPT bypasses MTRRs), so feeding that information into the MMU is rather straightforward.

Note, I haven't actually verified this mitigates the MMIO Stale Data bug, but I think it's safe to say no has verified the existing code works either.

All that said, and despite what the subject says, my real interest in this series it to kill off kvm_arch_{start,end}_assignment(). I.e. preciesly identifying MMIO is a means to an end. Because as evidenced by the MMIO mess and other bugs (e.g. vDPA device not getting device posted interrupts), keying off KVM_DEV_VFIO_FILE_ADD for anything is a bad idea.

The last two patches of this series depend on the stupidly large device posted interrupts rework:

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

which in turn depends on a not-tiny prep series:

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

Unless you care deeply about those patches, I honestly recommend just ignoring them. I posted them as part of this series, because post two patches that depends on *four* series seemed even more ridiculousr :-)

Side topic: Pawan, I haven't forgotten about your mmio_stale_data_clear => cpu_buf_vm_clear rename, I promise I'll review it soon.

Sean Christopherson (5):
KVM: x86: Avoid calling kvm_is_mmio_pfn() when kvm_x86_ops.get_mt_mask
is NULL
KVM: x86/mmu: Locally cache whether a PFN is host MMIO when making a
SPTE
KVM: VMX: Apply MMIO Stale Data mitigation if KVM maps MMIO into the
guest
Revert "kvm: detect assigned device via irqbypass manager"
VFIO: KVM: x86: Drop kvm_arch_{start,end}_assignment()

 arch/x86/include/asm/kvm_host.h |  3 +--
 arch/x86/kvm/irq.c              |  9 +------
 arch/x86/kvm/mmu/mmu_internal.h |  3 +++
 arch/x86/kvm/mmu/spte.c         | 43 ++++++++++++++++++++++++++++++---
 arch/x86/kvm/mmu/spte.h         | 10 ++++++++
 arch/x86/kvm/vmx/run_flags.h    | 10 +++++---
 arch/x86/kvm/vmx/vmx.c          |  8 +++++-
 arch/x86/kvm/x86.c              | 18 --------------
 include/linux/kvm_host.h        | 18 --------------
 virt/kvm/vfio.c                 |  3 ---
 10 files changed, 68 insertions(+), 57 deletions(-)

base-commit: 1f0486097459e53d292db749de70e587339267f5

Signature · 1 line
2.49.0.1151.ga128411c76-goog