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

From: Jason Gunthorpe

Date: Thu Apr 09 2026 - 14:27:06 EST


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);
tmp_paddr = *paddr;
/*
* Scan the domain for the contiguous physical address length so that

Jason