linux-stable/drivers/iommu
Lu Baolu fba8ca3e6f iommu/vt-d: Fix WARN_ON in iommu probe path
[ Upstream commit 89436f4f54 ]

Commit 1a75cc710b ("iommu/vt-d: Use rbtree to track iommu probed
devices") adds all devices probed by the iommu driver in a rbtree
indexed by the source ID of each device. It assumes that each device
has a unique source ID. This assumption is incorrect and the VT-d
spec doesn't state this requirement either.

The reason for using a rbtree to track devices is to look up the device
with PCI bus and devfunc in the paths of handling ATS invalidation time
out error and the PRI I/O page faults. Both are PCI ATS feature related.

Only track the devices that have PCI ATS capabilities in the rbtree to
avoid unnecessary WARN_ON in the iommu probe path. Otherwise, on some
platforms below kernel splat will be displayed and the iommu probe results
in failure.

 WARNING: CPU: 3 PID: 166 at drivers/iommu/intel/iommu.c:158 intel_iommu_probe_device+0x319/0xd90
 Call Trace:
  <TASK>
  ? __warn+0x7e/0x180
  ? intel_iommu_probe_device+0x319/0xd90
  ? report_bug+0x1f8/0x200
  ? handle_bug+0x3c/0x70
  ? exc_invalid_op+0x18/0x70
  ? asm_exc_invalid_op+0x1a/0x20
  ? intel_iommu_probe_device+0x319/0xd90
  ? debug_mutex_init+0x37/0x50
  __iommu_probe_device+0xf2/0x4f0
  iommu_probe_device+0x22/0x70
  iommu_bus_notifier+0x1e/0x40
  notifier_call_chain+0x46/0x150
  blocking_notifier_call_chain+0x42/0x60
  bus_notify+0x2f/0x50
  device_add+0x5ed/0x7e0
  platform_device_add+0xf5/0x240
  mfd_add_devices+0x3f9/0x500
  ? preempt_count_add+0x4c/0xa0
  ? up_write+0xa2/0x1b0
  ? __debugfs_create_file+0xe3/0x150
  intel_lpss_probe+0x49f/0x5b0
  ? pci_conf1_write+0xa3/0xf0
  intel_lpss_pci_probe+0xcf/0x110 [intel_lpss_pci]
  pci_device_probe+0x95/0x120
  really_probe+0xd9/0x370
  ? __pfx___driver_attach+0x10/0x10
  __driver_probe_device+0x73/0x150
  driver_probe_device+0x19/0xa0
  __driver_attach+0xb6/0x180
  ? __pfx___driver_attach+0x10/0x10
  bus_for_each_dev+0x77/0xd0
  bus_add_driver+0x114/0x210
  driver_register+0x5b/0x110
  ? __pfx_intel_lpss_pci_driver_init+0x10/0x10 [intel_lpss_pci]
  do_one_initcall+0x57/0x2b0
  ? kmalloc_trace+0x21e/0x280
  ? do_init_module+0x1e/0x210
  do_init_module+0x5f/0x210
  load_module+0x1d37/0x1fc0
  ? init_module_from_file+0x86/0xd0
  init_module_from_file+0x86/0xd0
  idempotent_init_module+0x17c/0x230
  __x64_sys_finit_module+0x56/0xb0
  do_syscall_64+0x6e/0x140
  entry_SYSCALL_64_after_hwframe+0x71/0x79

Fixes: 1a75cc710b ("iommu/vt-d: Use rbtree to track iommu probed devices")
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10689
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20240407011429.136282-1-baolu.lu@linux.intel.com
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-17 11:23:35 +02:00
..
amd iommu/amd: Mark interrupt as managed 2024-03-26 18:16:44 -04:00
arm iommu/arm-smmu-v3: Hold arm_smmu_asid_lock during all of attach_dev 2024-04-13 13:10:01 +02:00
intel iommu/vt-d: Fix WARN_ON in iommu probe path 2024-04-17 11:23:35 +02:00
iommufd iommufd/selftest: Don't check map/unmap pairing with HUGE_PAGES 2024-02-26 16:59:12 -04:00
apple-dart.c Merge branches 'apple/dart', 'arm/rockchip', 'arm/smmu', 'virtio', 'x86/vt-d', 'x86/amd' and 'core' into next 2024-01-03 09:59:32 +01:00
dma-iommu.c iommu/dma: Force swiotlb_max_mapping_size on an untrusted device 2024-04-03 15:32:33 +02:00
dma-iommu.h iommu: Optimise PCI SAC address trick 2023-07-14 16:14:17 +02:00
exynos-iommu.c iommu/exynos: Update to {map,unmap}_pages 2023-09-25 12:04:36 +02:00
fsl_pamu.c iommu/fsl: fix all kernel-doc warnings in fsl_pamu.c 2023-03-22 14:50:15 +01:00
fsl_pamu.h
fsl_pamu_domain.c iommu/fsl_pamu: Implement a PLATFORM domain 2023-09-25 11:40:54 +02:00
fsl_pamu_domain.h
hyperv-iommu.c x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup() 2023-08-06 14:15:09 +02:00
io-pgfault.c
io-pgtable-arm-v7s.c
io-pgtable-arm.c iommu: Extend LPAE page table format to support custom allocators 2023-11-27 11:10:12 +01:00
io-pgtable-arm.h
io-pgtable-dart.c
io-pgtable.c iommu: Allow passing custom allocators to pgtable drivers 2023-11-27 11:10:12 +01:00
iommu-debugfs.c
iommu-priv.h iommu: Move dev_iommu_ops() to private header 2023-08-18 12:52:15 -03:00
iommu-sva.c iommu/sva: Fix SVA handle sharing in multi device case 2024-03-01 13:53:58 +01:00
iommu-sva.h iommu: Remove ioasid infrastructure 2023-03-31 10:03:31 +02:00
iommu-sysfs.c iommu: Do not export iommu_device_link/unlink() 2023-07-14 16:14:15 +02:00
iommu-traces.c
iommu.c iommu: Validate the PASID in iommu_attach_device_pasid() 2024-04-10 16:37:59 +02:00
iova.c iommu/iova: Manage the depot list size 2023-09-25 12:07:44 +02:00
ipmmu-vmsa.c iommu/ipmmu-vmsa: Convert to generic_single_device_group() 2023-09-25 11:51:07 +02:00
irq_remapping.c iommu: Fix compilation without CONFIG_IOMMU_INTEL 2024-03-26 18:16:55 -04:00
irq_remapping.h
Kconfig iommu: Fix compilation without CONFIG_IOMMU_INTEL 2024-03-26 18:16:55 -04:00
Makefile iommu/tegra-gart: Remove tegra-gart 2023-09-25 11:40:54 +02:00
msm_iommu.c iommu: Allow .iotlb_sync_map to fail and handle s390's -ENOMEM return 2023-10-02 08:42:57 +02:00
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c iommu: Clean up open-coded ownership checks 2023-11-27 11:03:16 +01:00
mtk_iommu_v1.c iommu: Clean up open-coded ownership checks 2023-11-27 11:03:16 +01:00
of_iommu.c Merge branches 'apple/dart', 'arm/rockchip', 'arm/smmu', 'virtio', 'x86/vt-d', 'x86/amd' and 'core' into next 2024-01-03 09:59:32 +01:00
omap-iommu-debug.c
omap-iommu.c iommu: Mark dev_iommu_priv_set() with a lockdep 2023-12-12 10:18:49 +01:00
omap-iommu.h iommu/omap: Convert to generic_single_device_group() 2023-09-25 11:52:08 +02:00
omap-iopgtable.h
rockchip-iommu.c iommu/rockchip: Update to {map,unmap}_pages 2023-09-25 12:04:37 +02:00
s390-iommu.c iommu/dma: Allow a single FQ in addition to per-CPU FQs 2023-10-02 08:43:03 +02:00
sprd-iommu.c iommu: Clean up open-coded ownership checks 2023-11-27 11:03:16 +01:00
sun50i-iommu.c iommu: Allow .iotlb_sync_map to fail and handle s390's -ENOMEM return 2023-10-02 08:42:57 +02:00
tegra-smmu.c Merge branches 'iommu/fixes', 'arm/tegra', 'arm/smmu', 'virtio', 'x86/vt-d', 'x86/amd', 'core' and 's390' into next 2023-10-27 09:13:40 +02:00
virtio-iommu.c Merge branches 'apple/dart', 'arm/rockchip', 'arm/smmu', 'virtio', 'x86/vt-d', 'x86/amd' and 'core' into next 2024-01-03 09:59:32 +01:00