Skip to content

Commit 2d48ea0

Browse files
Qian Caijoergroedel
authored andcommitted
iommu/vt-d: Fix RCU-list bugs in intel_iommu_init()
There are several places traverse RCU-list without holding any lock in intel_iommu_init(). Fix them by acquiring dmar_global_lock. WARNING: suspicious RCU usage ----------------------------- drivers/iommu/intel-iommu.c:5216 RCU-list traversed in non-reader section!! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 no locks held by swapper/0/1. Call Trace: dump_stack+0xa0/0xea lockdep_rcu_suspicious+0x102/0x10b intel_iommu_init+0x947/0xb13 pci_iommu_init+0x26/0x62 do_one_initcall+0xfe/0x500 kernel_init_freeable+0x45a/0x4f8 kernel_init+0x11/0x139 ret_from_fork+0x3a/0x50 DMAR: Intel(R) Virtualization Technology for Directed I/O Fixes: d8190dc ("iommu/vt-d: Enable DMA remapping after rmrr mapped") Signed-off-by: Qian Cai <[email protected]> Acked-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 65ac74f commit 2d48ea0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5193,13 +5193,15 @@ int __init intel_iommu_init(void)
51935193

51945194
init_iommu_pm_ops();
51955195

5196+
down_read(&dmar_global_lock);
51965197
for_each_active_iommu(iommu, drhd) {
51975198
iommu_device_sysfs_add(&iommu->iommu, NULL,
51985199
intel_iommu_groups,
51995200
"%s", iommu->name);
52005201
iommu_device_set_ops(&iommu->iommu, &intel_iommu_ops);
52015202
iommu_device_register(&iommu->iommu);
52025203
}
5204+
up_read(&dmar_global_lock);
52035205

52045206
bus_set_iommu(&pci_bus_type, &intel_iommu_ops);
52055207
if (si_domain && !hw_pass_through)
@@ -5210,7 +5212,6 @@ int __init intel_iommu_init(void)
52105212
down_read(&dmar_global_lock);
52115213
if (probe_acpi_namespace_devices())
52125214
pr_warn("ACPI name space devices didn't probe correctly\n");
5213-
up_read(&dmar_global_lock);
52145215

52155216
/* Finally, we enable the DMA remapping hardware. */
52165217
for_each_iommu(iommu, drhd) {
@@ -5219,6 +5220,8 @@ int __init intel_iommu_init(void)
52195220

52205221
iommu_disable_protect_mem_regions(iommu);
52215222
}
5223+
up_read(&dmar_global_lock);
5224+
52225225
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
52235226

52245227
intel_iommu_enabled = 1;

0 commit comments

Comments
 (0)