Re: [PATCH 1/2] iommu: Add __iommu_debug_unmap_phys() to drop refs by physical address

From: Jason Gunthorpe

Date: Thu Aug 27 2026 - 12:21:55 EST


On Thu, Aug 27, 2026 at 10:58:54PM +0800, Yuanhe Shu wrote:
> The IOMMU_DEBUG_PAGEALLOC sanitizer takes a reference on each page at
> iommu_map() time, keyed by physical address, and the only way to drop
> them is the IOVA based iommu_debug_unmap_begin()/end(). A path that
> tears down a page table with mappings still installed has no IOVA to
> unmap with, so add a physical address based counterpart of
> __iommu_debug_map() for those paths, sharing the counting loop through
> __iommu_debug_update_phys().

This is not right. The following patch has the iova:

+ iommu_debug_unmap_phys(&iommu_table->domain,
+ pt_entry_oa(&pts), oasz);

Every pts has the iova of its current iteration location. Call
pt_index_to_va() and then pts->range->va is the current spot.

Jason