WSL2-Linux-Kernel/drivers/iommu
Nadav Amit 29b3283972 iommu/vt-d: Do not use flush-queue when caching-mode is on
When an Intel IOMMU is virtualized, and a physical device is
passed-through to the VM, changes of the virtual IOMMU need to be
propagated to the physical IOMMU. The hypervisor therefore needs to
monitor PTE mappings in the IOMMU page-tables. Intel specifications
provide "caching-mode" capability that a virtual IOMMU uses to report
that the IOMMU is virtualized and a TLB flush is needed after mapping to
allow the hypervisor to propagate virtual IOMMU mappings to the physical
IOMMU. To the best of my knowledge no real physical IOMMU reports
"caching-mode" as turned on.

Synchronizing the virtual and the physical IOMMU tables is expensive if
the hypervisor is unaware which PTEs have changed, as the hypervisor is
required to walk all the virtualized tables and look for changes.
Consequently, domain flushes are much more expensive than page-specific
flushes on virtualized IOMMUs with passthrough devices. The kernel
therefore exploited the "caching-mode" indication to avoid domain
flushing and use page-specific flushing in virtualized environments. See
commit 78d5f0f500 ("intel-iommu: Avoid global flushes with caching
mode.")

This behavior changed after commit 13cf017446 ("iommu/vt-d: Make use
of iova deferred flushing"). Now, when batched TLB flushing is used (the
default), full TLB domain flushes are performed frequently, requiring
the hypervisor to perform expensive synchronization between the virtual
TLB and the physical one.

Getting batched TLB flushes to use page-specific invalidations again in
such circumstances is not easy, since the TLB invalidation scheme
assumes that "full" domain TLB flushes are performed for scalability.

Disable batched TLB flushes when caching-mode is on, as the performance
benefit from using batched TLB invalidations is likely to be much
smaller than the overhead of the virtual-to-physical IOMMU page-tables
synchronization.

Fixes: 13cf017446 ("iommu/vt-d: Make use of iova deferred flushing")
Signed-off-by: Nadav Amit <namit@vmware.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Will Deacon <will@kernel.org>
Cc: stable@vger.kernel.org

Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20210127175317.1600473-1-namit@vmware.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2021-01-28 13:59:02 +01:00
..
amd iommu/amd: Use IVHD EFR for early initialization of IOMMU features 2021-01-28 11:57:08 +01:00
arm iommu: arm-smmu-qcom: Add sdm630/msm8998 compatibles for qcom quirks 2021-01-12 15:49:25 +00:00
intel iommu/vt-d: Do not use flush-queue when caching-mode is on 2021-01-28 13:59:02 +01:00
Kconfig iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind() 2020-11-23 14:16:55 +00:00
Makefile iommu/sva: Add PASID helpers 2020-11-23 14:16:55 +00:00
dma-iommu.c Revert "iommu: Add quirk for Intel graphic devices in map_sg" 2021-01-07 13:27:14 +00:00
exynos-iommu.c
fsl_pamu.c
fsl_pamu.h
fsl_pamu_domain.c
fsl_pamu_domain.h
hyperv-iommu.c iommu/hyper-v: Remove I/O-APIC ID check from hyperv_irq_remapping_select() 2020-12-02 11:22:55 +01:00
io-pgtable-arm-v7s.c iommu/io-pgtable: Remove tlb_flush_leaf 2020-12-08 15:23:37 +00:00
io-pgtable-arm.c IOMMU updates for 5.11 2020-12-16 13:58:47 -08:00
io-pgtable-arm.h
io-pgtable.c
ioasid.c iommu/ioasid: Add ioasid references 2020-11-23 14:16:55 +00:00
iommu-debugfs.c
iommu-sva-lib.c iommu/sva: Add PASID helpers 2020-11-23 14:16:55 +00:00
iommu-sva-lib.h iommu/sva: Add PASID helpers 2020-11-23 14:16:55 +00:00
iommu-sysfs.c
iommu-traces.c
iommu.c Merge branch 'for-next/iommu/fixes' into for-next/iommu/core 2020-12-08 15:21:49 +00:00
iova.c iommu/iova: fix 'domain' typos 2021-01-05 18:48:57 +00:00
ipmmu-vmsa.c iommu/io-pgtable: Remove tlb_flush_leaf 2020-12-08 15:23:37 +00:00
irq_remapping.c
irq_remapping.h
msm_iommu.c iommu/io-pgtable: Remove tlb_flush_leaf 2020-12-08 15:23:37 +00:00
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c iommu/io-pgtable: Remove tlb_flush_leaf 2020-12-08 15:23:37 +00:00
mtk_iommu.h
mtk_iommu_v1.c
of_iommu.c
omap-iommu-debug.c
omap-iommu.c
omap-iommu.h
omap-iopgtable.h
rockchip-iommu.c
s390-iommu.c
sun50i-iommu.c
tegra-gart.c
tegra-smmu.c iommu/tegra-smmu: Add PCI support 2020-11-25 11:04:41 +00:00
virtio-iommu.c