On Thu, Oct 15, 2026 at 02:20:10PM -0300, Jason Gunthorpe wrote:
If a single PTE cannot be stored in the current bitmap that should be a
failure and reported back to userspace. Allowing a PTE to be split creates
a possibility that dirty memory will be reported as clean.

The gather must also cover the entire PTE that is being cleaned, not just
the part that fits within the bitmap.

Fix both issues by computing the full IOVA range of every PTE and using
that to update the bitmap and the gather. The bitmap code now rejects
ranges that don't fit in it, and the gather always combined ranges.

The selftest quietly relied on a bug where the CONT was split, that is why
the half page size for the mock domain saw alternating dirties. Increase
the dirty test page size to PAGE_SIZE so it still works as intended.

Cc: [email protected]
Fixes: 4a00f9434891 ("iommupt: Add read_and_clear_dirty op")
Reported-by: Samarth Narang <[email protected]>
Closes: https://lore.kernel.org/all/20261013165814.309255
Signed-off-by: Jason Gunthorpe <[email protected]>
---
drivers/iommu/generic_pt/iommu_pt.h     | 30 +++++++------------------
tools/testing/selftests/iommu/iommufd.c | 10 ++++-----
2 files changed, 13 insertions(+), 27 deletions(-)

This relies on other changes in the iommufd tree so I will take it


Reviewed-by: Samiullah Khawaja <[email protected]>

Reply via email to