[PATCH v1 10/16] iommufd: Add mmap interface

Nicolin Chen nicolinc at nvidia.com
Mon Apr 21 10:23:51 PDT 2025


On Mon, Apr 21, 2025 at 08:16:54AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc at nvidia.com>
> > Sent: Friday, April 11, 2025 2:38 PM
> > 
> > For vIOMMU passing through HW resources to user space (VMs), add an
> > mmap
> > infrastructure to map a region of hardware MMIO pages. The addr and size
> > should be given previously via a prior IOMMU_VIOMMU_ALLOC ioctl in some
> > output fields of the structure.
> 
> According to the code the addr must be the immap_id given by previous
> alloc but size can be any as long as it doesn't exceed the physical length.

Yea, though I start to wonder if we should simply close the window
by forcing the full range..

I changed the kdoc of the iommufd_fops_mmap():

+/*
+ * Kernel driver must first do iommufd_ctx_alloc_mmap() to register an mmappable
+ * MMIO region to the iommufd core to receive an "immap_id". Then, driver should
+ * report to user space this immap_id and the size of the registered MMIO region
+ * for @vm_pgoff and @size of an mmap() call, via an IOMMU_VIOMMU_ALLOC ioctl in
+ * the output fields of its driver-type data structure.
+ *
+ * Note the @size is allowed to be smaller than the registered size as a partial
+ * mmap starting from the registered base address.
+ */

> > +/* Entry for iommufd_ctx::mt_mmap */
> > +struct iommufd_mmap {
> > +	unsigned long pfn_start;
> > +	unsigned long pfn_end;
> > +	bool is_io;
> > +};
> 
> what is the point of 'is_io' here? Do you intend to allow userspace to
> mmap anonymous memory via iommufd?
> 
> anyway for now the only user in this series always sets it to true.
> 
> I'd suggest to remove it until there is a real need.

Done.

Thanks
Nicolin



More information about the linux-arm-kernel mailing list