Skip to contentSkip to conversation

iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()

PATCH In review David Woodhouse 4 participants 4 messages Jun 9, 2014 – Jul 8, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()

This missing IOTLB flush was added as a minor, inconsequential bug-fix in commit ea8ea460c ("iommu/vt-d: Clean up and fix page table clear/free behaviour") in 3.15. It wasn't originally intended for -stable but a couple of users have reported issues which turn out to be fixed by adding the missing flush.

---
For 3.14 and earlier. As noted, this fix is in 3.15 already.

 drivers/iommu/intel-iommu.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +17 -1
index a22c86c..40f6b47 100644
@@ -4075,7 +4075,7 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
 			     unsigned long iova, size_t size)
 {
 	struct dmar_domain *dmar_domain = domain->priv;
-	int order;
+	int order, iommu_id;
 
 	order = dma_pte_clear_range(dmar_domain, iova >> VTD_PAGE_SHIFT,
 			    (iova + size - 1) >> VTD_PAGE_SHIFT);
@@ -4083,6 +4083,22 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
 	if (dmar_domain->max_addr == iova + size)
 		dmar_domain->max_addr = iova;
 
+	for_each_set_bit(iommu_id, dmar_domain->iommu_bmp, g_num_of_iommus) {
+		struct intel_iommu *iommu = g_iommus[iommu_id];
+		int num, ndomains;
+
+		/*
+		 * find bit position of dmar_domain
+		 */
+		ndomains = cap_ndoms(iommu->cap);
+		for_each_set_bit(num, iommu->domain_ids, ndomains) {
+			if (iommu->domains[num] == dmar_domain)
+				iommu_flush_iotlb_psi(iommu, num,
+						      iova >> VTD_PAGE_SHIFT,
+						      1 << order, 0);
+		}
+	}
+
 	return PAGE_SIZE << order;
 }
 
Signature · 6 lines
1.9.0


-- 
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation

A message that is not in the archive (sent off-list or not yet received): 1402319285.7595.9.camel-W2I5cNIroUsVm/[email protected]

#2 lore raw
Quoted 9 lines · David Woodhouse

This missing IOTLB flush was added as a minor, inconsequential bug-fix in commit ea8ea460c ("iommu/vt-d: Clean up and fix page table clear/free behaviour") in 3.15. It wasn't originally intended for -stable but a couple of users have reported issues which turn out to be fixed by adding the missing flush.

---
For 3.14 and earlier. As noted, this fix is in 3.15 already.

What is the commit id of the patch for this in 3.15?

thanks,

greg k-h

#3 lore raw
In reply to a message not in the archive
Quoted 9 lines · David Woodhouse

This missing IOTLB flush was added as a minor, inconsequential bug-fix in commit ea8ea460c ("iommu/vt-d: Clean up and fix page table clear/free behaviour") in 3.15. It wasn't originally intended for -stable but a couple of users have reported issues which turn out to be fixed by adding the missing flush.

---
For 3.14 and earlier. As noted, this fix is in 3.15 already.

Hi, now applied to 3.12.

thanks,

Signature · 2 lines
js
suse labs
#4 lore raw
In reply to a message not in the archive
Quoted 9 lines · David Woodhouse

This missing IOTLB flush was added as a minor, inconsequential bug-fix in commit ea8ea460c ("iommu/vt-d: Clean up and fix page table clear/free behaviour") in 3.15. It wasn't originally intended for -stable but a couple of users have reported issues which turn out to be fixed by adding the missing flush.

---
For 3.14 and earlier. As noted, this fix is in 3.15 already.

[...]

I've queued this up for 3.2, with some adjustment. I'm attaching my version.

Ben.

Signature · 2 lines
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.

From: David Woodhouse <[email protected]>
Date: Mon, 09 Jun 2014 14:09:53 +0100
Subject: iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()

Part of commit ea8ea460c9ace60bbb5ac6e5521d637d5c15293d upstream.

This missing IOTLB flush was added as a minor, inconsequential bug-fix in commit ea8ea460c ("iommu/vt-d: Clean up and fix page table clear/free behaviour") in 3.15. It wasn't originally intended for -stable but a couple of users have reported issues which turn out to be fixed by adding the missing flush.

[bwh: Backported to 3.2:
- Adjust context
- Use &dmar_domain->iommu_bmp, as it is a single word not an array]

---
 drivers/iommu/intel-iommu.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +17 -1
@@ -4070,7 +4070,7 @@ static int intel_iommu_unmap(struct iomm
 {
 	struct dmar_domain *dmar_domain = domain->priv;
 	size_t size = PAGE_SIZE << gfp_order;
-	int order;
+	int order, iommu_id;
 
 	order = dma_pte_clear_range(dmar_domain, iova >> VTD_PAGE_SHIFT,
 			    (iova + size - 1) >> VTD_PAGE_SHIFT);
@@ -4078,6 +4078,22 @@ static int intel_iommu_unmap(struct iomm
 	if (dmar_domain->max_addr == iova + size)
 		dmar_domain->max_addr = iova;
 
+	for_each_set_bit(iommu_id, dmar_domain->iommu_bmp, g_num_of_iommus) {
+		struct intel_iommu *iommu = g_iommus[iommu_id];
+		int num, ndomains;
+
+		/*
+		 * find bit position of dmar_domain
+		 */
+		ndomains = cap_ndoms(iommu->cap);
+		for_each_set_bit(num, iommu->domain_ids, ndomains) {
+			if (iommu->domains[num] == dmar_domain)
+				iommu_flush_iotlb_psi(iommu, num,
+						      iova >> VTD_PAGE_SHIFT,
+						      1 << order, 0);
+		}
+	}
+
 	return order;
 }