Re: [PATCH 00/11] iommufd: Enable noiommu mode for cdev

From: Jacob Pan

Date: Tue Mar 03 2026 - 14:13:46 EST


Hi Jason,

On Mon, 2 Mar 2026 20:35:32 -0400
Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:

> On Fri, Feb 27, 2026 at 09:52:36AM -0800, Jacob Pan wrote:
> > VFIO's unsafe_noiommu_mode has long provided a way for userspace
> > drivers to operate on platforms lacking a hardware IOMMU. Today,
> > IOMMUFD also supports No-IOMMU mode for group-based devices under
> > vfio_compat mode. However, IOMMUFD's native character device (cdev)
> > does not yet support No-IOMMU mode, which is the purpose of this
> > patch.
>
> I browsed through this quickly and it looks OK to me, though I might
> suggest correcting that FIXME so that the get pa scans the domain for
> contiguous physical address. You can copy the loop from vfio probably.
>
Thanks for the suggestion, I will add the following to v2 and update
selftest with hugepage to cover this.

--- a/drivers/iommu/iommufd/io_pagetable.c
+++ b/drivers/iommu/iommufd/io_pagetable.c
@@ -877,10 +877,19 @@ int iopt_get_phys(struct io_pagetable *iopt,
unsigned long iova, u64 *paddr, goto unlock_exit;
}
/*
- * TBD: we can return contiguous IOVA length so that userspace
can
- * keep searching for next physical address.
+ * Scan the domain for the contiguous physical address length
so that
+ * userspace search can be optimized for fewer ioctls.
*/
- *length = PAGE_SIZE;
+ while (iova < iopt_area_last_iova(area)) {
+ u64 next_paddr =
iommu_iova_to_phys(area->storage_domain,
+ iova + PAGE_SIZE);
+ if (!next_paddr || next_paddr != *paddr + PAGE_SIZE) {
+ *length += PAGE_SIZE;
+ break;
+ }
+ iova += PAGE_SIZE;
+ *paddr += PAGE_SIZE;
+ }
> Also the kbuild error needs fixing, I gave a suggestion for that in
> the thread.
will fix in v2.

Thanks again,

Jacob