linux-stable/drivers/iommu
Daniel Drake 7967fef2c6 iommu/vt-d: Ignore devices with out-of-spec domain number
commit da72a379b2 upstream.

VMD subdevices are created with a PCI domain ID of 0x10000 or
higher.

These subdevices are also handled like all other PCI devices by
dmar_pci_bus_notifier().

However, when dmar_alloc_pci_notify_info() take records of such devices,
it will truncate the domain ID to a u16 value (in info->seg).
The device at (e.g.) 10000:00:02.0 is then treated by the DMAR code as if
it is 0000:00:02.0.

In the unlucky event that a real device also exists at 0000:00:02.0 and
also has a device-specific entry in the DMAR table,
dmar_insert_dev_scope() will crash on:
   BUG_ON(i >= devices_cnt);

That's basically a sanity check that only one PCI device matches a
single DMAR entry; in this case we seem to have two matching devices.

Fix this by ignoring devices that have a domain number higher than
what can be looked up in the DMAR table.

This problem was carefully diagnosed by Jian-Hong Pan.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
Fixes: 59ce0515cd ("iommu/vt-d: Update DRHD/RMRR/ATSR device scope caches when PCI hotplug happens")
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-03-18 07:14:24 +01:00
..
amd_iommu.c iommu/amd: Support multiple PCI DMA aliases in IRQ Remapping 2020-02-01 09:37:10 +00:00
amd_iommu.h iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-10-05 13:09:59 +02:00
amd_iommu_debugfs.c
amd_iommu_init.c iommu/amd: Make iommu_disable safer 2020-01-27 14:50:59 +01:00
amd_iommu_proto.h
amd_iommu_quirks.c iommu/amd: Apply the same IVRS IOAPIC workaround to Acer Aspire A315-41 2019-11-12 19:21:14 +01:00
amd_iommu_types.h iommu/amd: Reserve exclusion range in iova-domain 2019-05-04 09:20:22 +02:00
amd_iommu_v2.c
arm-smmu-regs.h
arm-smmu-v3.c iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE 2020-02-24 08:34:48 +01:00
arm-smmu.c iommu/arm-smmu: Avoid constant zero in TLBI writes 2019-06-19 08:18:00 +02:00
dma-iommu.c iommu/dma: Fix MSI reservation allocation 2020-03-18 07:14:22 +01:00
dmar.c iommu/vt-d: Ignore devices with out-of-spec domain number 2020-03-18 07:14:24 +01:00
exynos-iommu.c
fsl_pamu.c
fsl_pamu.h
fsl_pamu_domain.c
fsl_pamu_domain.h
intel-iommu.c iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page 2020-03-18 07:14:22 +01:00
intel-pasid.c
intel-pasid.h
intel-svm.c iommu/vt-d: Fix off-by-one in PASID allocation 2020-02-24 08:34:36 +01:00
intel_irq_remapping.c
io-pgtable-arm-v7s.c iommu/io-pgtable-arm-v7s: Only kmemleak_ignore L2 tables 2019-04-05 22:33:02 +02:00
io-pgtable-arm.c iommu/io-pgtable-arm: Fix race handling in split_blk_unmap() 2019-11-24 08:19:30 +01:00
io-pgtable.c
io-pgtable.h
iommu-debugfs.c iommu: Fix IOMMU debugfs fallout 2020-01-27 14:50:28 +01:00
iommu-sysfs.c
iommu-traces.c
iommu.c iommu: Use right function to get group for device 2020-01-27 14:50:51 +01:00
iova.c iommu/iova: Init the struct iova to fix the possible memleak 2020-01-12 12:17:18 +01:00
ipmmu-vmsa.c
irq_remapping.c
irq_remapping.h
Kconfig
Makefile iommu/amd: Override wrong IVRS IOAPIC on Raven Ridge systems 2019-10-05 13:09:59 +02:00
msm_iommu.c
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c iommu/mediatek: Fix iova_to_phys PA start for 4GB mode 2020-01-27 14:51:07 +01:00
mtk_iommu.h
mtk_iommu_v1.c
of_iommu.c
omap-iommu-debug.c
omap-iommu.c
omap-iommu.h
omap-iopgtable.h
qcom_iommu.c iommu/qcom: Fix bogus detach logic 2020-02-28 16:38:43 +01:00
rockchip-iommu.c iommu: rockchip: Free domain on .domain_free 2020-01-04 19:12:37 +01:00
s390-iommu.c
tegra-gart.c
tegra-smmu.c iommu/tegra-smmu: Fix page tables in > 4 GiB memory 2020-01-04 19:12:38 +01:00