linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg
@ 2019-01-17 19:29 Jerry Snitselaar
  2019-01-19 17:36 ` Jerry Snitselaar
  2019-01-22 10:57 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Jerry Snitselaar @ 2019-01-17 19:29 UTC (permalink / raw)
  To: iommu; +Cc: linux-kernel, Joerg Roedel, Suravee Suthikulpanit

In the error path of map_sg, free_iova_fast is being called with
address instead of the pfn. This results in a bad value getting into
the rcache, and can result in hitting a BUG_ON when
iova_magazine_free_pfns is called.

Cc: Joerg Roedel <joro@8bytes.org>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 drivers/iommu/amd_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 87ba23a75b38..418df8ff3e50 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -2623,7 +2623,7 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
 	}
 
 out_free_iova:
-	free_iova_fast(&dma_dom->iovad, address, npages);
+	free_iova_fast(&dma_dom->iovad, address >> PAGE_SHIFT, npages);
 
 out_err:
 	return 0;
-- 
2.20.1.98.gecbdaf0899


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

* Re: [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg
  2019-01-17 19:29 [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg Jerry Snitselaar
@ 2019-01-19 17:36 ` Jerry Snitselaar
  2019-01-22 10:57 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Jerry Snitselaar @ 2019-01-19 17:36 UTC (permalink / raw)
  To: iommu; +Cc: linux-kernel, Joerg Roedel, Suravee Suthikulpanit

On Thu Jan 17 19, Jerry Snitselaar wrote:
>In the error path of map_sg, free_iova_fast is being called with
>address instead of the pfn. This results in a bad value getting into
>the rcache, and can result in hitting a BUG_ON when
>iova_magazine_free_pfns is called.
>
>Cc: Joerg Roedel <joro@8bytes.org>
>Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
>---
> drivers/iommu/amd_iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
>index 87ba23a75b38..418df8ff3e50 100644
>--- a/drivers/iommu/amd_iommu.c
>+++ b/drivers/iommu/amd_iommu.c
>@@ -2623,7 +2623,7 @@ static int map_sg(struct device *dev, struct scatterlist *sglist,
> 	}
>
> out_free_iova:
>-	free_iova_fast(&dma_dom->iovad, address, npages);
>+	free_iova_fast(&dma_dom->iovad, address >> PAGE_SHIFT, npages);
>
> out_err:
> 	return 0;
>-- 
>2.20.1.98.gecbdaf0899
>


I forgot to add the Fixes line.

Fixes: 80187fd39dcb ("iommu/amd: Optimize map_sg and unmap_sg")

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

* Re: [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg
  2019-01-17 19:29 [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg Jerry Snitselaar
  2019-01-19 17:36 ` Jerry Snitselaar
@ 2019-01-22 10:57 ` Joerg Roedel
  1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2019-01-22 10:57 UTC (permalink / raw)
  To: Jerry Snitselaar; +Cc: iommu, linux-kernel, Suravee Suthikulpanit

On Thu, Jan 17, 2019 at 12:29:02PM -0700, Jerry Snitselaar wrote:
> In the error path of map_sg, free_iova_fast is being called with
> address instead of the pfn. This results in a bad value getting into
> the rcache, and can result in hitting a BUG_ON when
> iova_magazine_free_pfns is called.
> 
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>

Applied, thanks.

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

end of thread, other threads:[~2019-01-22 10:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 19:29 [PATCH] iommu: amd: call free_iova_fast with pfn in map_sg Jerry Snitselaar
2019-01-19 17:36 ` Jerry Snitselaar
2019-01-22 10:57 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).