Re: [PATCH v4 5/7] iommu/dma: Make limit checks self-contained

From: Jon Hunter
Date: Mon May 20 2024 - 14:11:35 EST


Hi Robin,

On 17/05/2024 16:03, Robin Murphy wrote:

..

Thanks. From staring at the code I think I've spotted one subtlety which
may not be quite as intended - can you see if the diff below helps? It
occurs to me that suspend and CPU hotplug may not *cause* the symptom,
but they could certainly stall if one or more relevant CPUs is *already*
stuck in a loop somewhere...

Thanks,
Robin.

----->8-----
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 89a53c2f2cf9..85eb1846c637 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -686,6 +686,7 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
     /* Check the domain allows at least some access to the device... */
     if (map) {
         dma_addr_t base = dma_range_map_min(map);
+        base = max(base, (dma_addr_t)1 << order);
         if (base > domain->geometry.aperture_end ||
             dma_range_map_max(map) < domain->geometry.aperture_start) {
             pr_warn("specified DMA range outside IOMMU capability\n");


That fixes it for me!

Tested-by: Jon Hunter <jonathanh@xxxxxxxxxx>

Thanks!
Jon

--
nvpublic