Re: [PATCH 2/2] iommupt: Drop pagealloc references during domain deinit

From: Yuanhe Shu

Date: Mon Aug 31 2026 - 02:33:12 EST


On Thu, Aug 27, 2026 at 01:18:28PM -0300, Jason Gunthorpe wrote:
> It is not misusing iommupt, but it is definitely misusing any iommu
> API built on top of it. How did you trigger this?

The kunit suite, nothing else. test_pgsize_boundary() maps 128K at a
hard-coded OA and never unmaps it, so with iommu.debug_pagealloc=1 those
32 pages stay counted after pt_iommu_deinit() and every later allocation
or free of one of them WARNs. The out-of-tree module in the cover letter
was something I wrote to confirm the mechanism, not a real driver.

The only non-test path I found that frees a populated domain is
iommu_setup_default_domain(), which releases the old domain with its
IOMMU_RESV_DIRECT mappings still installed. I have not seen that WARN,
presumably because those pages do not come from the page allocator, so it
is not evidence of a bug and I am not proposing to change it.

> If this is the only trigger, then it is different testing things
> interacting badly and I don't think it should be fixed like this.
>
> Probably have the kunits directly unmap as they were being lazy

Agreed, and my "not driver misuse" framing was wrong: the iommupt deinit
contract says nothing about unmapping, but the iommu API above it does.
Dropping this series.

You were right about the tests: adding a count_valids() == 0 check to
pt_kunit_iommu_exit() without touching anything else fails exactly
test_increase_level(), test_pgsize_boundary() and test_mixed(); the other
cases already unmap. I will send that as a single patch.

Thanks,
Yuanhe