Commit 5cd56264 authored by Joerg Roedel's avatar Joerg Roedel Committed by Luis Henriques

iommu/vt-d: Fix dead-locks in disable_dmar_iommu() path

BugLink: http://bugs.launchpad.net/bugs/1642968

commit bea64033 upstream.

It turns out that the disable_dmar_iommu() code-path tried
to get the device_domain_lock recursivly, which will
dead-lock when this code runs on dmar removal. Fix both
code-paths that could lead to the dead-lock.

Fixes: 55d94043 ('iommu/vt-d: Get rid of domain->iommu_lock')
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
parent c214c8dd
...@@ -1672,6 +1672,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu) ...@@ -1672,6 +1672,7 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
if (!iommu->domains || !iommu->domain_ids) if (!iommu->domains || !iommu->domain_ids)
return; return;
again:
spin_lock_irqsave(&device_domain_lock, flags); spin_lock_irqsave(&device_domain_lock, flags);
list_for_each_entry_safe(info, tmp, &device_domain_list, global) { list_for_each_entry_safe(info, tmp, &device_domain_list, global) {
struct dmar_domain *domain; struct dmar_domain *domain;
...@@ -1684,10 +1685,19 @@ static void disable_dmar_iommu(struct intel_iommu *iommu) ...@@ -1684,10 +1685,19 @@ static void disable_dmar_iommu(struct intel_iommu *iommu)
domain = info->domain; domain = info->domain;
dmar_remove_one_dev_info(domain, info->dev); __dmar_remove_one_dev_info(info);
if (!domain_type_is_vm_or_si(domain)) if (!domain_type_is_vm_or_si(domain)) {
/*
* The domain_exit() function can't be called under
* device_domain_lock, as it takes this lock itself.
* So release the lock here and re-run the loop
* afterwards.
*/
spin_unlock_irqrestore(&device_domain_lock, flags);
domain_exit(domain); domain_exit(domain);
goto again;
}
} }
spin_unlock_irqrestore(&device_domain_lock, flags); spin_unlock_irqrestore(&device_domain_lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment