[GIT PULL] KVM: x86: MMU changes for 6.7

From: Sean Christopherson
Date: Fri Oct 27 2023 - 16:49:56 EST


This is mostly the first half of a series by Yan to optimize KVM's handling of
guest MTRR changes for VMs with non-coherent DMA. Yan had to put more complex
changes that actually realize the optimizations on hold, but the patches here
are all nice cleanups on their own.

The following changes since commit 5804c19b80bf625c6a9925317f845e497434d6d3:

Merge tag 'kvm-riscv-fixes-6.6-1' of https://github.com/kvm-riscv/linux into HEAD (2023-09-23 05:35:55 -0400)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-mmu-6.7

for you to fetch changes up to 1de9992f9de0a92b6e11133aba0e2be833c11084:

KVM: x86/mmu: Remove unnecessary ‘NULL’ values from sptep (2023-10-18 14:34:28 -0700)

----------------------------------------------------------------
KVM x86 MMU changes for 6.7:

- Clean up code that deals with honoring guest MTRRs when the VM has
non-coherent DMA and host MTRRs are ignored, i.e. EPT is enabled.

- Zap EPT entries when non-coherent DMA assignment stops/start to prevent
using stale entries with the wrong memtype.

- Don't ignore guest PAT for CR0.CD=1 && KVM_X86_QUIRK_CD_NW_CLEARED=y, as
there's zero reason to ignore guest PAT if the effective MTRR memtype is WB.
This will also allow for future optimizations of handling guest MTRR updates
for VMs with non-coherent DMA and the quirk enabled.

- Harden the fast page fault path to guard against encountering an invalid
root when walking SPTEs.

----------------------------------------------------------------
Li zeming (1):
KVM: x86/mmu: Remove unnecessary ‘NULL’ values from sptep

Yan Zhao (5):
KVM: x86/mmu: Add helpers to return if KVM honors guest MTRRs
KVM: x86/mmu: Zap SPTEs when CR0.CD is toggled iff guest MTRRs are honored
KVM: x86/mmu: Zap SPTEs on MTRR update iff guest MTRRs are honored
KVM: x86/mmu: Zap KVM TDP when noncoherent DMA assignment starts/stops
KVM: VMX: drop IPAT in memtype when CD=1 for KVM_X86_QUIRK_CD_NW_CLEARED

arch/x86/kvm/mmu.h | 7 +++++++
arch/x86/kvm/mmu/mmu.c | 37 ++++++++++++++++++++++++++-----------
arch/x86/kvm/mtrr.c | 2 +-
arch/x86/kvm/vmx/vmx.c | 9 +++------
arch/x86/kvm/x86.c | 21 ++++++++++++++++++---
5 files changed, 55 insertions(+), 21 deletions(-)