linux-stable/drivers/iommu
Yian Chen 2dc85f33d9 iommu/vt-d: Fix PCI bus rescan device hot add
commit 316f92a705 upstream.

Notifier calling chain uses priority to determine the execution
order of the notifiers or listeners registered to the chain.
PCI bus device hot add utilizes the notification mechanism.

The current code sets low priority (INT_MIN) to Intel
dmar_pci_bus_notifier and postpones DMAR decoding after adding
new device into IOMMU. The result is that struct device pointer
cannot be found in DRHD search for the new device's DMAR/IOMMU.
Subsequently, the device is put under the "catch-all" IOMMU
instead of the correct one. This could cause system hang when
device TLB invalidation is sent to the wrong IOMMU. Invalidation
timeout error and hard lockup have been observed and data
inconsistency/crush may occur as well.

This patch fixes the issue by setting a positive priority(1) for
dmar_pci_bus_notifier while the priority of IOMMU bus notifier
uses the default value(0), therefore DMAR decoding will be in
advance of DRHD search for a new device to find the correct IOMMU.

Following is a 2-step example that triggers the bug by simulating
PCI device hot add behavior in Intel Sapphire Rapids server.

echo 1 > /sys/bus/pci/devices/0000:6a:01.0/remove
echo 1 > /sys/bus/pci/rescan

Fixes: 59ce0515cd ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope")
Cc: stable@vger.kernel.org # v3.15+
Reported-by: Zhang, Bernice <bernice.zhang@intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Yian Chen <yian.chen@intel.com>
Link: https://lore.kernel.org/r/20220521002115.1624069-1-yian.chen@intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-12 16:27:28 +02:00
..
amd_iommu.c iommu/amd: Fix sleeping in atomic in increase_address_space() 2021-03-11 13:51:05 +01:00
amd_iommu_init.c iommu/amd: Increase timeout waiting for GA log enablement 2022-06-14 16:53:52 +02:00
amd_iommu_proto.h
amd_iommu_types.h iommu/amd: Set DTE[IntTabLen] to represent 512 IRTEs 2020-12-11 13:39:06 +01:00
amd_iommu_v2.c
arm-smmu-regs.h
arm-smmu-v3.c iommu/arm-smmu-v3: fix event handling soft lockup 2022-04-20 09:08:27 +02:00
arm-smmu.c
dma-iommu.c iommu/dma: Fix MSI reservation allocation 2020-03-20 10:54:18 +01:00
dmar.c iommu/vt-d: Fix PCI bus rescan device hot add 2022-07-12 16:27:28 +02:00
exynos-iommu.c iommu/exynos: add missing put_device() call in exynos_iommu_of_xlate() 2020-10-14 09:51:08 +02:00
fsl_pamu.c
fsl_pamu.h
fsl_pamu_domain.c
fsl_pamu_domain.h
intel-iommu.c iommu/vt-d: Do not use flush-queue when caching-mode is on 2021-02-10 09:12:10 +01:00
intel-svm.c iommu/vt-d: Fix mm reference leak 2020-04-24 08:01:21 +02:00
intel_irq_remapping.c iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() 2022-02-08 18:16:28 +01:00
io-pgtable-arm-v7s.c
io-pgtable-arm.c
io-pgtable.c
io-pgtable.h
iommu-sysfs.c
iommu-traces.c
iommu.c iommu: Fix reference count leak in iommu_group_alloc. 2020-06-03 08:18:03 +02:00
iova.c iommu/iova: Fix race between FQ timeout and teardown 2022-01-27 09:00:53 +01:00
ipmmu-vmsa.c
irq_remapping.c
irq_remapping.h
Kconfig
Makefile
msm_iommu.c iommu/msm: Fix an incorrect NULL check on list iterator 2022-06-14 16:53:54 +02:00
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c iommu/mediatek: Add list_del in mtk_iommu_remove 2022-06-14 16:53:51 +02:00
mtk_iommu.h
mtk_iommu_v1.c
of_iommu.c
omap-iommu-debug.c iommu/omap: Check for failure of a call to omap_iommu_dump_ctx 2020-08-21 09:48:21 +02:00
omap-iommu.c
omap-iommu.h
omap-iopgtable.h
qcom_iommu.c iommu/qcom: Fix local_base status check 2020-05-05 19:15:51 +02:00
rockchip-iommu.c
s390-iommu.c
tegra-gart.c
tegra-smmu.c iommu/tegra-smmu: Fix page tables in > 4 GiB memory 2020-01-04 13:59:36 +01:00