]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iommufd: Add mmap interface
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:59:09 +0000 (22:59 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Jul 2025 17:34:35 +0000 (14:34 -0300)
commit56e9a0d8e53f56f313d332888a32a44a71f3a9ab
tree7556cbf223908d2dd54d3b62a60e9468d78b0b36
parent20896914da8ad24df0a77e24887912d87754fb83
iommufd: Add mmap interface

For vIOMMU passing through HW resources to user space (VMs), allowing a VM
to control the passed through HW directly by accessing hardware registers,
add an mmap infrastructure to map the physical MMIO pages to user space.

Maintain a maple tree per ictx as a translation table managing mmappable
regions, from an allocated for-user mmap offset to an iommufd_mmap struct,
where it stores the real physical address range for io_remap_pfn_range().

Keep track of the lifecycle of the mmappable region by taking refcount of
its owner, so as to enforce user space to unmap the region first before it
can destroy its owner object.

To allow an IOMMU driver to add and delete mmappable regions onto/from the
maple tree, add iommufd_viommu_alloc/destroy_mmap helpers.

Link: https://patch.msgid.link/r/9a888a326b12aa5fe940083eae1156304e210fe0.1752126748.git.nicolinc@nvidia.com
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/driver.c
drivers/iommu/iommufd/iommufd_private.h
drivers/iommu/iommufd/main.c
include/linux/iommufd.h