On Tue, Mar 04, 2025 at 01:06:46AM -0500, Paolo Bonzini wrote: > The IGNORE_GUEST_PAT quirk is inapplicable, and thus always-disabled, > if shadow_memtype_mask is zero. As long as vmx_get_mt_mask is not For shadow paging case, current KVM always ignores guest PAT, i.e., the quirk is always-enabled. However, this might be negligible, as non-coherent DMA is unlikely to function well with shadow paging anyway, if I don't miss anything. > called for the shadow paging case, there is no need to consult > shadow_memtype_mask and it can be removed altogether. ... > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 5b45fca3ddfa..8bf50cecc75c 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -13544,8 +13544,10 @@ static void kvm_noncoherent_dma_assignment_start_or_stop(struct kvm *kvm) > * due to toggling the "ignore PAT" bit. Zap all SPTEs when the first > * (or last) non-coherent device is (un)registered to so that new SPTEs > * with the correct "ignore guest PAT" setting are created. > + * > + * If KVM always honors guest PAT, however, there is nothing to do. > */ > - if (kvm_mmu_may_ignore_guest_pat(kvm)) > + if (kvm_check_has_quirk(kvm, KVM_X86_QUIRK_IGNORE_GUEST_PAT)) > kvm_zap_gfn_range(kvm, gpa_to_gfn(0), gpa_to_gfn(~0ULL)); > } > > -- > 2.43.5 > >