All of lore.kernel.org
 help / color / mirror / Atom feed
* [stable PATCH] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()
@ 2014-06-09 13:08 David Woodhouse
       [not found] ` <1402319285.7595.9.camel-W2I5cNIroUsVm/YvaOjsyQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2014-06-09 13:08 UTC (permalink / raw)
  To: stable-DgEjT+Ai2ygdnm+yROfE0A
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA


[-- Attachment #1.1: Type: text/plain, Size: 1960 bytes --]

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.

Signed-off-by: David Woodhouse <David.Woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
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(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index a22c86c..40f6b47 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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;
 }
 
-- 
1.9.0


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org                              Intel Corporation

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [stable PATCH] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()
       [not found] ` <1402319285.7595.9.camel-W2I5cNIroUsVm/YvaOjsyQ@public.gmane.org>
@ 2014-06-09 15:05   ` Greg KH
  2014-06-20  8:13   ` Jiri Slaby
  2014-07-08 15:50   ` Ben Hutchings
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2014-06-09 15:05 UTC (permalink / raw)
  To: David Woodhouse
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	stable-DgEjT+Ai2ygdnm+yROfE0A

On Mon, Jun 09, 2014 at 02:09:53PM +0100, David Woodhouse wrote:
> 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.
> 
> Signed-off-by: David Woodhouse <David.Woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [stable PATCH] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()
       [not found] ` <1402319285.7595.9.camel-W2I5cNIroUsVm/YvaOjsyQ@public.gmane.org>
  2014-06-09 15:05   ` Greg KH
@ 2014-06-20  8:13   ` Jiri Slaby
  2014-07-08 15:50   ` Ben Hutchings
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2014-06-20  8:13 UTC (permalink / raw)
  To: David Woodhouse, stable-DgEjT+Ai2ygdnm+yROfE0A
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On 06/09/2014 03:09 PM, David Woodhouse wrote:
> 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.
> 
> Signed-off-by: David Woodhouse <David.Woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> For 3.14 and earlier. As noted, this fix is in 3.15 already.

Hi, now applied to 3.12.

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [stable PATCH] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap()
       [not found] ` <1402319285.7595.9.camel-W2I5cNIroUsVm/YvaOjsyQ@public.gmane.org>
  2014-06-09 15:05   ` Greg KH
  2014-06-20  8:13   ` Jiri Slaby
@ 2014-07-08 15:50   ` Ben Hutchings
  2 siblings, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2014-07-08 15:50 UTC (permalink / raw)
  To: David Woodhouse
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	stable-DgEjT+Ai2ygdnm+yROfE0A


[-- Attachment #1.1.1: Type: text/plain, Size: 744 bytes --]

On Mon, 2014-06-09 at 14:09 +0100, David Woodhouse wrote:
> 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.
> 
> Signed-off-by: David Woodhouse <David.Woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> 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.

-- 
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.

[-- Attachment #1.1.2: iommu-vt-d-fix-missing-iotlb-flush-in-intel_iommu_unmap.patch --]
[-- Type: text/x-patch, Size: 1900 bytes --]

From: David Woodhouse <dwmw2@infradead.org>
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.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
[bwh: Backported to 3.2:
 - Adjust context
 - Use &dmar_domain->iommu_bmp, as it is a single word not an array]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 drivers/iommu/intel-iommu.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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;
 }
 

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-08 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-09 13:08 [stable PATCH] iommu/vt-d: Fix missing IOTLB flush in intel_iommu_unmap() David Woodhouse
     [not found] ` <1402319285.7595.9.camel-W2I5cNIroUsVm/YvaOjsyQ@public.gmane.org>
2014-06-09 15:05   ` Greg KH
2014-06-20  8:13   ` Jiri Slaby
2014-07-08 15:50   ` Ben Hutchings

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.