• Jason Gunthorpe's avatar
    vfio: Move the Intel no-snoop control off of IOMMU_CACHE · 71cfafda
    Jason Gunthorpe authored
    IOMMU_CACHE means "normal DMA to this iommu_domain's IOVA should be cache
    coherent" and is used by the DMA API. The definition allows for special
    non-coherent DMA to exist - ie processing of the no-snoop flag in PCIe
    TLPs - so long as this behavior is opt-in by the device driver.
    
    The flag is mainly used by the DMA API to synchronize the IOMMU setting
    with the expected cache behavior of the DMA master. eg based on
    dev_is_dma_coherent() in some case.
    
    For Intel IOMMU IOMMU_CACHE was redefined to mean 'force all DMA to be
    cache coherent' which has the practical effect of causing the IOMMU to
    ignore the no-snoop bit in a PCIe TLP.
    
    x86 platforms are always IOMMU_CACHE, so Intel should ignore this flag.
    
    Instead use the new domain op enforce_cache_coherency() which causes every
    IOPTE created in the domain to have the no-snoop blocking behavior.
    
    Reconfigure VFIO to always use IOMMU_CACHE and call
    enforce_cache_coherency() to operate the special Intel behavior.
    
    Remove the IOMMU_CACHE test from Intel IOMMU.
    
    Ultimately VFIO plumbs the result of enforce_cache_coherency() back into
    the x86 platform code through kvm_arch_register_noncoherent_dma() which
    controls if the WBINVD instruction is available in the guest.  No other
    archs implement kvm_arch_register_noncoherent_dma() nor are there any
    other known consumers of VFIO_DMA_CC_IOMMU that might be affected by the
    user visible result change on non-x86 archs.
    Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
    Reviewed-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
    Acked-by: default avatarAlex Williamson <alex.williamson@redhat.com>
    Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
    Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
    Link: https://lore.kernel.org/r/2-v3-2cf356649677+a32-intel_no_snoop_jgg@nvidia.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
    71cfafda
iommu.c 129 KB