iommu/amd: Fix domain flush size when syncing iotlb
Subsystems (3)
PATCH 1/1 iommu/amd: Fix domain flush size when syncing iotlb
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However, gather->end is defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.
With this patch, verified that 1 invalidation occurs when unmapping a single page.
--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/iommu.c +1 -1
@@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,unsigned long flags;spin_lock_irqsave (&dom->lock, flags); -domain_flush_pages (dom, gather->start, gather->end - gather->start,1 ); +domain_flush_pages (dom, gather->start, gather->end - gather->start +1 ,1 );amd_iommu_domain_flush_complete (dom);spin_unlock_irqrestore (&dom->lock, flags); }
Signature · 1 line
2.40.0.634.g4ca3ef3211-goog
Quoted 11 lines · Jon Pan-Doh
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->endis defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.
Quoted 8 lines
With this patch, verified that 1 invalidation occurs when unmapping a single page.
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Signed-off-by Jon Pan-Doh <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Suggested-by Gary Zibrat <[email protected]>
Sorry for that.
Quoted 24 lines · Nadav Amit
Quoted 12 lines · Jon Pan-Doh
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->endis defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.Quoted 8 lines
With this patch, verified that 1 invalidation occurs when unmapping a single page.
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Signed-off-by Jon Pan-Doh <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Suggested-by Gary Zibrat <[email protected]>
Quoted 3 lines
Sorry for that.
Acked-by Nadav Amit <[email protected]>
P.S. I think it is stable-worthy.
Quoted 7 lines · Jon Pan-Doh
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->endis defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.
Quoted 7 lines
With this patch, verified that 1 invalidation occurs when unmapping a single page.
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Signed-off-by Jon Pan-Doh <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Suggested-by Gary Zibrat <[email protected]>
Thanks!
-Vasant
Quoted 17 lines
--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/iommu.c +1
-1@@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,unsigned long flags;spin_lock_irqsave (&dom->lock, flags); -domain_flush_pages (dom, gather->start, gather->end - gather->start,1 ); +domain_flush_pages (dom, gather->start, gather->end - gather->start +1 ,1 );amd_iommu_domain_flush_complete (dom);spin_unlock_irqrestore (&dom->lock, flags); }
Hi Joerg,
[Cc'ing [email protected] per Nadav's suggestion]
This bug fix seems to have gotten the necessary reviews (AMD and previous commit author). Is it eligible to be applied?
Thanks,
Jon
Quoted 35 lines · Jon Pan-Doh
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->endis defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.With this patch, verified that 1 invalidation occurs when unmapping a single page.
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Signed-off-by Jon Pan-Doh <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Suggested-by Gary Zibrat <[email protected]>--- drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/iommu.c +1
-2@@ -2378,7 +2378,7 @@ static void amd_iommu_iotlb_sync(struct iommu_domain *domain,unsigned long flags;spin_lock_irqsave (&dom->lock, flags); -domain_flush_pages (dom, gather->start, gather->end - gather->start,1 ); +domain_flush_pages (dom, gather->start, gather->end - gather->start +1 ,1 );amd_iommu_domain_flush_complete (dom);spin_unlock_irqrestore (&dom->lock, flags); } --2.40.0.634.g4ca3ef3211-goog
Greg KH
maintainerQuoted 3 lines · Jon Pan-Doh
Hi Joerg,
[Cc'ing [email protected] per Nadav's suggestion]
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
Quoted 8 lines · Jon Pan-Doh
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->endis defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.
Quoted 7 lines
With this patch, verified that 1 invalidation occurs when unmapping a single page.
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Signed-off-by Jon Pan-Doh <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Suggested-by Gary Zibrat <[email protected]>
Quoted 6 lines · Greg KH
Quoted 3 lines · Jon Pan-Doh
Hi Joerg,
[Cc'ing [email protected] per Nadav's suggestion]
Quoted 8 lines
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.</formletter>
Thanks for the link. Added the Cc tag as a reply to the patch. Apologies for top-posting previously.
Quoted 17 lines · Jon Pan-Doh
!! External Email
Quoted 11 lines · Jon Pan-Doh
When running on an AMD vIOMMU, we observed multiple invalidations (of decreasing power of 2 aligned sizes) when unmapping a single page.
Domain flush takes gather bounds (end-start) as size param. However,
gather->endis defined as the last inclusive address (start + size - 1). This leads to an off by 1 error.With this patch, verified that 1 invalidation occurs when unmapping a single page.
Quoted 6 lines
Quoted 4 lines
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Signed-off-by Jon Pan-Doh <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Suggested-by Gary Zibrat <[email protected]>
Assuming the patch was still not applied, I think that Greg KH would prefer that you send v2 that includes the “Cc: <[email protected]>” (notice the “<“ and “>" signs) and ideally the version in which I added the buggy code (sorry for that again) after a “#” sign.
I think it is version 5.15.
IOW: If the patch was still not applied by Joerg, please send v2 with:
In the commit log.
Quoted 6 lines · Nadav Amit
IOW: If the patch was still not applied by Joerg, please send v2 with:
Cc <[email protected] <mailto:[email protected]>> # 5.15.xIn the commit log.
Thanks for the clarification/guidance. I've resent the patch for review with added tags (Acked-by, Reviewed-by). Will re-read the patch submission doc and try to avoid formatting issues in the future.
Joerg Roedel
maintainerQuoted 2 lines · Jon Pan-Doh
drivers/iommu/amd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied for 6.4, thanks.