On Thu, Mar 14, 2024, Dongli Zhang wrote: > On 3/12/24 10:08, Sean Christopherson wrote: > > On Mon, Mar 11, 2024, Dongli Zhang wrote: > >> Since it is also controlled by other cases, e.g., kvm_arch_has_noncoherent_dma() > >> at vmx_get_mt_mask(), it can be 'may_honor_guest_pat' too? > >> > >> Therefore, why not directly use 'shadow_memtype_mask' (without the API), or some > >> naming like "ept_enabled_for_hardware". > > > > Again, after this series, KVM will *always* honor guest PAT for CPUs with self-snoop, > > i.e. KVM will *never* ignore guest PAT. But for CPUs without self-snoop (or with > > errata), KVM conditionally honors/ignores guest PAT. > > > >> Even with the code from PATCH 5/5, we still have high chance that VM has > >> non-coherent DMA? > > > > I don't follow. On CPUs with self-snoop, whether or not the VM has non-coherent > > DMA (from VFIO!) is irrelevant. If the CPU has self-snoop, then KVM can safely > > honor guest PAT at all times. > > > Thank you very much for the explanation. > > According to my understanding of the explanation (after this series): > > 1. When static_cpu_has(X86_FEATURE_SELFSNOOP) == true, it is 100% to "honor > guest PAT". Yes. > 2. When static_cpu_has(X86_FEATURE_SELFSNOOP) == false (and > shadow_memtype_mask), although only 50% chance (depending on where there is > non-coherent DMA), at least now it is NOT 100% (to honor guest PAT) any longer. Yes, though I wouldn't assign a percent probability to the non-coherent DMA case. > Due to the fact it is not 100% (to honor guest PAT) any longer, there starts the > trend (from 100% to 50%) to "ignore guest PAT", that is: > kvm_mmu_may_ignore_guest_pat(). Yep.