Re: [PATCH V3 04/10] iommufd: Add an ioctl IOMMU_IOAS_GET_PA to query PA from IOVA

From: Jacob Pan

Date: Fri Apr 10 2026 - 17:20:29 EST


Hi Jason,

On Thu, 9 Apr 2026 15:26:24 -0300
Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:

> On Thu, Apr 02, 2026 at 10:11:40PM -0700, Jacob Pan wrote:
> > + *paddr = iommu_iova_to_phys(area->storage_domain, iova);
> > + if (!*paddr) {
> > + rc = -EINVAL;
> > + goto unlock_exit;
> > + }
> > +
> > + tmp_length = PAGE_SIZE;
> > + tmp_paddr = *paddr;
>
> shashiko also points out that the length is too long if IOVA is
> unaligned. We adjust the phys for unaligned IOVA but not the length:
>
> @@ -879,7 +879,7 @@ int iopt_get_phys(struct io_pagetable *iopt,
> unsigned long iova, u64 *paddr, goto unlock_exit;
> }
>
> - tmp_length = PAGE_SIZE;
> + tmp_length = PAGE_SIZE - offset_in_page(iova);
Will fix and add an unaligned iova in selftest
vfio_iommufd_noiommu_test.

Thanks,

Jacob