Re: [PATCH v9 4/6] iommufd: Add an ioctl to query PA from IOVA for noiommu mode
From: Yi Liu
Date: Tue Jun 16 2026 - 01:53:17 EST
On 6/12/26 01:26, Jacob Pan wrote:
To support no-IOMMU mode where userspace drivers perform unsafe DMA
using physical addresses, introduce a new API to retrieve the
physical address of a user-allocated DMA buffer that has been mapped to
an IOVA via IOMMU_IOAS_MAP. The mapping is backed by SW-only I/O page
tables maintained by the GENERIC_PT framework.
Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Co-developed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Signed-off-by: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
---
v9
- Make no-IOMMU GET_PA length a real upper bound and reject zero length,
avoiding an unbounded scan while holding IOAS locks. This matches the
bounded-range semantics expected by the incoming
iommu_iova_to_phys_length() helper.
v8:
- Fix comment on start IOVA range (Kevin)
v7:
- Fix commit message (Yi)
- Avoid duplicated tmp_length settting (yi)
- Handle race with dma-buf revoke pages (Sashiko)
v6:
- Limit search length (Baolu, Jason)
v5:
- Fix next_iova exceeds iopt_area_last_iova (Alex)
- Rename IOCTL more specific to NOIOMMU, i.e.
IOMMUFD_CMD_IOAS_NOIOMMU_GET_PA (Kevin)
- Add header stubs for iopt_get_phys()
v4:
- Fix ioctl return type (Yi Liu)
---
drivers/iommu/iommufd/io_pagetable.c | 78 +++++++++++++++++++++++++
drivers/iommu/iommufd/ioas.c | 36 ++++++++++++
drivers/iommu/iommufd/iommufd_private.h | 18 ++++++
drivers/iommu/iommufd/main.c | 3 +
include/uapi/linux/iommufd.h | 28 +++++++++
5 files changed, 163 insertions(+)
Reviewed-by: Yi Liu <yi.l.liu@xxxxxxxxx>