summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLu Baolu <baolu.lu@linux.intel.com>2022-09-11 11:18:45 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-09-15 10:47:19 +0200
commit9516acba29e322202674d18f4dc383879f7813a5 (patch)
tree825ed606459a51710eea099ee30c1564f4b39efd /include
parent53b284a895f020c24a33181c0a7726547ae1e678 (diff)
downloadlinux-9516acba29e322202674d18f4dc383879f7813a5.tar.gz
linux-9516acba29e322202674d18f4dc383879f7813a5.tar.bz2
linux-9516acba29e322202674d18f4dc383879f7813a5.zip
iommu/vt-d: Fix possible recursive locking in intel_iommu_init()
[ Upstream commit 9cd4f1434479f1ac25c440c421fbf52069079914 ] The global rwsem dmar_global_lock was introduced by commit 3a5670e8ac932 ("iommu/vt-d: Introduce a rwsem to protect global data structures"). It is used to protect DMAR related global data from DMAR hotplug operations. The dmar_global_lock used in the intel_iommu_init() might cause recursive locking issue, for example, intel_iommu_get_resv_regions() is taking the dmar_global_lock from within a section where intel_iommu_init() already holds it via probe_acpi_namespace_devices(). Using dmar_global_lock in intel_iommu_init() could be relaxed since it is unlikely that any IO board must be hot added before the IOMMU subsystem is initialized. This eliminates the possible recursive locking issue by moving down DMAR hotplug support after the IOMMU is initialized and removing the uses of dmar_global_lock in intel_iommu_init(). Fixes: d5692d4af08cd ("iommu/vt-d: Fix suspicious RCU usage in probe_acpi_namespace_devices()") Reported-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/894db0ccae854b35c73814485569b634237b5538.1657034828.git.robin.murphy@arm.com Link: https://lore.kernel.org/r/20220718235325.3952426-1-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/dmar.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index cbd714a198a0..f3a3d95df532 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -69,6 +69,7 @@ struct dmar_pci_notify_info {
extern struct rw_semaphore dmar_global_lock;
extern struct list_head dmar_drhd_units;
+extern int intel_iommu_enabled;
#define for_each_drhd_unit(drhd) \
list_for_each_entry_rcu(drhd, &dmar_drhd_units, list, \
@@ -92,7 +93,8 @@ extern struct list_head dmar_drhd_units;
static inline bool dmar_rcu_check(void)
{
return rwsem_is_locked(&dmar_global_lock) ||
- system_state == SYSTEM_BOOTING;
+ system_state == SYSTEM_BOOTING ||
+ (IS_ENABLED(CONFIG_INTEL_IOMMU) && !intel_iommu_enabled);
}
#define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())