1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/iommu
Lu Baolu b150654f74 iommu/vt-d: Fix suspicious RCU usage
Commit <d74169ceb0d2> ("iommu/vt-d: Allocate DMAR fault interrupts
locally") moved the call to enable_drhd_fault_handling() to a code
path that does not hold any lock while traversing the drhd list. Fix
it by ensuring the dmar_global_lock lock is held when traversing the
drhd list.

Without this fix, the following warning is triggered:
 =============================
 WARNING: suspicious RCU usage
 6.14.0-rc3  Not tainted
 -----------------------------
 drivers/iommu/intel/dmar.c:2046 RCU-list traversed in non-reader section!!
               other info that might help us debug this:
               rcu_scheduler_active = 1, debug_locks = 1
 2 locks held by cpuhp/1/23:
 : ffffffff84a67c50 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x87/0x2c0
 : ffffffff84a6a380 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x87/0x2c0
 stack backtrace:
 CPU: 1 UID: 0 PID: 23 Comm: cpuhp/1 Not tainted 6.14.0-rc3 
 Call Trace:
  <TASK>
  dump_stack_lvl+0xb7/0xd0
  lockdep_rcu_suspicious+0x159/0x1f0
  ? __pfx_enable_drhd_fault_handling+0x10/0x10
  enable_drhd_fault_handling+0x151/0x180
  cpuhp_invoke_callback+0x1df/0x990
  cpuhp_thread_fun+0x1ea/0x2c0
  smpboot_thread_fn+0x1f5/0x2e0
  ? __pfx_smpboot_thread_fn+0x10/0x10
  kthread+0x12a/0x2d0
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x4a/0x60
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>

Holding the lock in enable_drhd_fault_handling() triggers a lockdep splat
about a possible deadlock between dmar_global_lock and cpu_hotplug_lock.
This is avoided by not holding dmar_global_lock when calling
iommu_device_register(), which initiates the device probe process.

Fixes: d74169ceb0 ("iommu/vt-d: Allocate DMAR fault interrupts locally")
Reported-and-tested-by: Ido Schimmel <idosch@nvidia.com>
Closes: https://lore.kernel.org/linux-iommu/Zx9OwdLIc_VoQ0-a@shredder.mtl.com/
Tested-by: Breno Leitao <leitao@debian.org>
Cc: stable@vger.kernel.org
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20250218022422.2315082-1-baolu.lu@linux.intel.com
Tested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
2025-02-28 12:19:01 +01:00
..
amd iommu/amd: Preserve default DTE fields when updating Host Page Table Root 2025-02-28 12:18:00 +01:00
arm iommufd 6.14 merge window pull 2025-01-24 12:04:35 -08:00
intel iommu/vt-d: Fix suspicious RCU usage 2025-02-28 12:19:01 +01:00
iommufd iommufd: Fix struct iommu_hwpt_pgfault init and padding 2025-01-21 13:55:49 -04:00
riscv iommu/riscv: Fixup compile warning 2025-01-17 08:58:06 +01:00
apple-dart.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
dma-iommu.c dma-mapping: fix vmap and mmap of noncontiougs allocations 2024-09-22 18:47:51 +02:00
dma-iommu.h iommu/dma: Centralise iommu_setup_dma_ops() 2024-04-26 12:07:26 +02:00
exynos-iommu.c iommu/exynos: Fix typos 2025-02-14 09:12:46 +01: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 iommu/fsl_pamu: hardcode the window address and size in pamu_config_ppaace 2021-04-07 10:56:52 +02:00
fsl_pamu_domain.c iommu: Use of_property_present() 2024-09-04 11:31:01 +02:00
fsl_pamu_domain.h iommu/fsl_pamu: remove the snoop_id field 2021-04-07 10:56:52 +02:00
hyperv-iommu.c iommu/hyper-v: Don't assume cpu_possible_mask is dense 2025-01-10 00:54:21 +00:00
io-pgfault.c iommu: Fix potential memory leak in iopf_queue_remove_device() 2025-02-10 14:49:30 +01:00
io-pgtable-arm-v7s.c iommu/io-pgtable-arm-v7s: Remove split on unmap behavior 2024-11-06 15:42:36 +00:00
io-pgtable-arm.c iommu/io-pgtable-arm: Add way to debug pgtable walk 2025-01-07 15:44:20 +00:00
io-pgtable-arm.h iommu/io-pgtable-arm: Move some definitions to a header 2020-09-28 23:48:06 +01:00
io-pgtable-dart.c iommu: Do not return 0 from map_pages if it doesn't do anything 2024-08-26 09:16:13 +02:00
io-pgtable.c iommu: Allow passing custom allocators to pgtable drivers 2023-11-27 11:10:12 +01:00
iommu-debugfs.c iommu: Fix IOMMU debugfs fallout 2019-02-26 11:15:58 +01:00
iommu-pages.h iommu: account IOMMU allocated memory 2024-04-15 14:31:48 +02:00
iommu-priv.h Merge branch 'iommu/iommufd/attach-handles' into iommu/next 2024-07-12 16:57:42 +01:00
iommu-sva.c Merge branch 'iommu/iommufd/attach-handles' into iommu/next 2024-07-12 16:57:42 +01:00
iommu-sysfs.c iommu/sysfs: constify the class struct 2024-10-29 09:50:24 +01:00
iommu-traces.c iommu: Remove detach_dev callback 2023-01-13 16:39:18 +01:00
iommu.c iommu: Fix a spelling error 2025-02-14 09:12:46 +01:00
iova.c - The series "zram: optimal post-processing target selection" from 2024-11-23 09:58:07 -08:00
ipmmu-vmsa.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
irq_remapping.c IOMMU Updates for Linux v6.10 2024-05-18 10:55:13 -07:00
irq_remapping.h iommu/vt-d: Allocate DMAR fault interrupts locally 2024-04-26 11:57:36 +02:00
Kconfig iommu/arm-smmu: Re-enable context caching in smmu reset operation 2025-01-07 13:26:28 +00:00
Makefile iommu/riscv: Add RISC-V IOMMU platform device driver 2024-10-29 09:46:23 +01:00
msm_iommu.c iommu/msm: Use helper function devm_clk_get_prepared() 2025-01-06 12:41:00 +01:00
msm_iommu.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 267 2019-06-05 17:30:29 +02:00
msm_iommu_hw-8xxx.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 267 2019-06-05 17:30:29 +02:00
mtk_iommu.c iommu: Use str_enable_disable-like helpers 2025-01-17 09:00:37 +01:00
mtk_iommu_v1.c iommu: Use str_enable_disable-like helpers 2025-01-17 09:00:37 +01:00
of_iommu.c iommu: Manage driver probe deferral better 2024-12-09 22:46:54 +00:00
omap-iommu-debug.c iommu/omap: Fix buffer overflow in debugfs 2022-09-07 10:42:28 +02:00
omap-iommu.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
omap-iommu.h iommu/omap: Convert to generic_single_device_group() 2023-09-25 11:52:08 +02:00
omap-iopgtable.h iommu/omap: Fix -Woverflow warnings when compiling on 64-bit architectures 2020-03-04 16:24:46 +01:00
rockchip-iommu.c iommu: Use str_enable_disable-like helpers 2025-01-17 09:00:37 +01:00
s390-iommu.c iommu/s390: Implement blocking domain 2024-10-15 10:19:07 +02:00
sprd-iommu.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
sun50i-iommu.c iommu: sun50i: Add H616 compatible string 2024-06-25 14:02:47 +02:00
tegra-smmu.c Merge branch 'iommu/fwspec-ops-removal' into iommu/next 2024-07-12 16:55:43 +01:00
virtio-iommu.c virtio: rename virtio_find_vqs_info() to virtio_find_vqs() 2024-07-17 05:20:58 -04:00