Skip to contentSkip to conversation

Patch "iommu/vt-d: Fix dead-locks in disable_dmar_iommu() path" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Nov 17, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

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

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
iommu-vt-d-fix-dead-locks-in-disable_dmar_iommu-path.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From bea64033dd7b5fb6296eda8266acab6364ce1554 Mon Sep 17 00:00:00 2001

From: Joerg Roedel <[email protected]>
Date: Tue, 8 Nov 2016 15:08:26 +0100
Subject: iommu/vt-d: Fix dead-locks in disable_dmar_iommu() path

From: Joerg Roedel <[email protected]>

commit bea64033dd7b5fb6296eda8266acab6364ce1554 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 55d940430ab9 ('iommu/vt-d: Get rid of domain->iommu_lock')
---
 drivers/iommu/intel-iommu.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/iommu/intel-iommu.c +12 -2
@@ -1711,6 +1711,7 @@ static void disable_dmar_iommu(struct in
 	if (!iommu->domains || !iommu->domain_ids)
 		return;
 
+again:
 	spin_lock_irqsave(&device_domain_lock, flags);
 	list_for_each_entry_safe(info, tmp, &device_domain_list, global) {
 		struct dmar_domain *domain;
@@ -1723,10 +1724,19 @@ static void disable_dmar_iommu(struct in
 
 		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);
+			goto again;
+		}
 	}
 	spin_unlock_irqrestore(&device_domain_lock, flags);
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/iommu-amd-free-domain-id-when-free-a-domain-of-struct-dma_ops_domain.patch queue-4.8/iommu-vt-d-fix-dead-locks-in-disable_dmar_iommu-path.patch