Re: [PATCH v2 2/2] iommufd/selftest: Check dmabuf MMIO mappings filled from another domain

From: Andrea Parri

Date: Wed Oct 14 2026 - 17:16:28 EST


On Wed, Oct 14, 2026 at 02:52:45PM -0300, Jason Gunthorpe wrote:
> > The mock page table has no memory type bits, so a mapping made with
> > IOMMU_MMIO cannot be told apart from one made with IOMMU_CACHE. Wrap the
> > mock's generic_pt map_range and unmap_range ops to record, per domain,
> > the pages mapped with IOMMU_MMIO, and add IOMMU_TEST_OP_MD_CHECK_MMIO to
> > check that a range is recorded. The check rejects ranges that wrap or
> > do not fit in unsigned long.
>
> I'm not keen on this, the special mock amd domain is just for mock
> usage, we should probably just add a mmio bit if we want to do this
> test.

Makes sense, thanks. For v3 I have:

- AMDV1PT_FMT_MOCK_MMIO (bit 52) in amdv1.h under AMDV1_IOMMUFD_SELFTEST,
set by amdv1pt_iommu_set_prot() for IOMMU_MMIO and kept by
amdv1pt_attr_from_entry();

- pt_iommu_amdv1_mock_iova_is_mmio() in fmt/iommu_mock.c, a walk like
iova_to_phys() that returns the bit, exported in GENERIC_PT_IOMMU for
IOMMU_TEST_OP_MD_CHECK_MMIO to use.

The op wrappers and the xarray in mock_iommu_domain are gone. Is the
extra export from iommu_mock.c OK with you, or would you rather the
selftest read the PTE some other way?

Patch 1 is unchanged; if it looks right to you, it could go in ahead of
the test.

Thanks,
Andrea