iommu/amd: Fix domain flush size when syncing iotlb
Subsystems (3)
PATCH RESEND 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 10 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 8 lines
Fixes a270be1b3fdf ("iommu/amd: Use only natural aligned flushes in a VM")Cc <[email protected]> # 5.15.xSuggested-by Gary Zibrat <[email protected]>Tested-by Sudheer Dantuluri <[email protected]>Acked-by Nadav Amit <[email protected]>Reviewed-by Vasant Hegde <[email protected]>Signed-off-by Jon Pan-Doh <[email protected]>---
Quoted 19 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); }Signature · 1 line
2.40.0.634.g4ca3ef3211-goog