KVM: x86/mmu: Add helpers to return if KVM honors guest MTRRs
authorYan Zhao <yan.y.zhao@intel.com>
Fri, 14 Jul 2023 06:50:06 +0000 (14:50 +0800)
committerSean Christopherson <seanjc@google.com>
Mon, 9 Oct 2023 21:34:57 +0000 (14:34 -0700)
commit1affe455d66de4e1743514afdeb99cb598a25aa2
tree8eb07edc00105cd7a46986ea50fe5c8b1251d8fb
parent5804c19b80bf625c6a9925317f845e497434d6d3
KVM: x86/mmu: Add helpers to return if KVM honors guest MTRRs

Add helpers to check if KVM honors guest MTRRs instead of open coding the
logic in kvm_tdp_page_fault().  Future fixes and cleanups will also need
to determine if KVM should honor guest MTRRs, e.g. for CR0.CD toggling and
and non-coherent DMA transitions.

Provide an inner helper, __kvm_mmu_honors_guest_mtrrs(), so that KVM can
check if guest MTRRs were honored when stopping non-coherent DMA.

Note, there is no need to explicitly check that TDP is enabled, KVM clears
shadow_memtype_mask when TDP is disabled, i.e. it's non-zero if and only
if EPT is enabled.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Link: https://lore.kernel.org/r/20230714065006.20201-1-yan.y.zhao@intel.com
Link: https://lore.kernel.org/r/20230714065043.20258-1-yan.y.zhao@intel.com
[sean: squash into a one patch, drop explicit TDP check massage changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu.h
arch/x86/kvm/mmu/mmu.c