* [PATCH] iommu/vt-d: fix RCU-list bugs in intel_iommu_init
@ 2020-03-05 20:00 Qian Cai
2020-03-07 11:52 ` Lu Baolu
2020-03-10 9:31 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Qian Cai @ 2020-03-05 20:00 UTC (permalink / raw)
To: jroedel; +Cc: iommu, linux-kernel
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: d8190dc63886 ("iommu/vt-d: Enable DMA remapping after rmrr mapped")
Signed-off-by: Qian Cai <cai@lca.pw>
---
drivers/iommu/intel-iommu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 6fa6de2b6ad5..bc138ceb07bc 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5193,6 +5193,7 @@ int __init intel_iommu_init(void)
init_iommu_pm_ops();
+ down_read(&dmar_global_lock);
for_each_active_iommu(iommu, drhd) {
iommu_device_sysfs_add(&iommu->iommu, NULL,
intel_iommu_groups,
@@ -5200,6 +5201,7 @@ int __init intel_iommu_init(void)
iommu_device_set_ops(&iommu->iommu, &intel_iommu_ops);
iommu_device_register(&iommu->iommu);
}
+ up_read(&dmar_global_lock);
bus_set_iommu(&pci_bus_type, &intel_iommu_ops);
if (si_domain && !hw_pass_through)
@@ -5210,7 +5212,6 @@ int __init intel_iommu_init(void)
down_read(&dmar_global_lock);
if (probe_acpi_namespace_devices())
pr_warn("ACPI name space devices didn't probe correctly\n");
- up_read(&dmar_global_lock);
/* Finally, we enable the DMA remapping hardware. */
for_each_iommu(iommu, drhd) {
@@ -5219,6 +5220,8 @@ int __init intel_iommu_init(void)
iommu_disable_protect_mem_regions(iommu);
}
+ up_read(&dmar_global_lock);
+
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
intel_iommu_enabled = 1;
--
1.8.3.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/vt-d: fix RCU-list bugs in intel_iommu_init
2020-03-05 20:00 [PATCH] iommu/vt-d: fix RCU-list bugs in intel_iommu_init Qian Cai
@ 2020-03-07 11:52 ` Lu Baolu
2020-03-10 9:31 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2020-03-07 11:52 UTC (permalink / raw)
To: Qian Cai, jroedel; +Cc: iommu, linux-kernel
Hi,
On 2020/3/6 4:00, Qian Cai wrote:
> 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: d8190dc63886 ("iommu/vt-d: Enable DMA remapping after rmrr mapped")
> Signed-off-by: Qian Cai <cai@lca.pw>
Thanks for the fix.
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
> ---
> drivers/iommu/intel-iommu.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 6fa6de2b6ad5..bc138ceb07bc 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -5193,6 +5193,7 @@ int __init intel_iommu_init(void)
>
> init_iommu_pm_ops();
>
> + down_read(&dmar_global_lock);
> for_each_active_iommu(iommu, drhd) {
> iommu_device_sysfs_add(&iommu->iommu, NULL,
> intel_iommu_groups,
> @@ -5200,6 +5201,7 @@ int __init intel_iommu_init(void)
> iommu_device_set_ops(&iommu->iommu, &intel_iommu_ops);
> iommu_device_register(&iommu->iommu);
> }
> + up_read(&dmar_global_lock);
>
> bus_set_iommu(&pci_bus_type, &intel_iommu_ops);
> if (si_domain && !hw_pass_through)
> @@ -5210,7 +5212,6 @@ int __init intel_iommu_init(void)
> down_read(&dmar_global_lock);
> if (probe_acpi_namespace_devices())
> pr_warn("ACPI name space devices didn't probe correctly\n");
> - up_read(&dmar_global_lock);
>
> /* Finally, we enable the DMA remapping hardware. */
> for_each_iommu(iommu, drhd) {
> @@ -5219,6 +5220,8 @@ int __init intel_iommu_init(void)
>
> iommu_disable_protect_mem_regions(iommu);
> }
> + up_read(&dmar_global_lock);
> +
> pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
>
> intel_iommu_enabled = 1;
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/vt-d: fix RCU-list bugs in intel_iommu_init
2020-03-05 20:00 [PATCH] iommu/vt-d: fix RCU-list bugs in intel_iommu_init Qian Cai
2020-03-07 11:52 ` Lu Baolu
@ 2020-03-10 9:31 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2020-03-10 9:31 UTC (permalink / raw)
To: Qian Cai; +Cc: iommu, linux-kernel
On Thu, Mar 05, 2020 at 03:00:46PM -0500, Qian Cai wrote:
> drivers/iommu/intel-iommu.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied, thanks.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-10 9:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05 20:00 [PATCH] iommu/vt-d: fix RCU-list bugs in intel_iommu_init Qian Cai
2020-03-07 11:52 ` Lu Baolu
2020-03-10 9:31 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).