]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: x86/mmu: Zap SPTEs when CR0.CD is toggled iff guest MTRRs are honored
authorYan Zhao <yan.y.zhao@intel.com>
Fri, 14 Jul 2023 06:51:22 +0000 (14:51 +0800)
committerSean Christopherson <seanjc@google.com>
Mon, 9 Oct 2023 21:35:13 +0000 (14:35 -0700)
Zap SPTEs when CR0.CD is toggled if and only if KVM's MMU is honoring
guest MTRRs, which is the only time that KVM incorporates the guest's
CR0.CD into the final memtype.

Suggested-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Link: https://lore.kernel.org/r/20230714065122.20315-1-yan.y.zhao@intel.com
[sean: rephrase shortlog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c

index 9f18b06bbda66bf411bb492fa4ab4c5fd9e90080..dc88b510db56d18d905a3ed163fc6388ffad1008 100644 (file)
@@ -962,7 +962,7 @@ void kvm_post_set_cr0(struct kvm_vcpu *vcpu, unsigned long old_cr0, unsigned lon
                kvm_mmu_reset_context(vcpu);
 
        if (((cr0 ^ old_cr0) & X86_CR0_CD) &&
-           kvm_arch_has_noncoherent_dma(vcpu->kvm) &&
+           kvm_mmu_honors_guest_mtrrs(vcpu->kvm) &&
            !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED))
                kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL);
 }