> Convert the VFIO device fd fops->mmap to create a DMABUF representing > the BAR mapping, and make the VMA fault handler look up PFNs from the > corresponding DMABUF. This supports future code mmap()ing BAR > DMABUFs, and iommufd work to support Type1 P2P. > > First, vfio_pci_core_mmap() uses the new > vfio_pci_core_mmap_prep_dmabuf() helper to export a DMABUF > representing a single BAR range. Then, the vfio_pci_mmap_huge_fault() > callback is updated to understand revoked buffers, and uses the new > vfio_pci_dma_buf_find_pfn() helper to determine the PFN for a given > fault address. > > Now that the VFIO DMABUFs can be mmap()ed, vfio_pci_dma_buf_move() > zaps PTEs (used on the revocation and cleanup paths). > > CONFIG_VFIO_PCI_CORE now unconditionally selects > CONFIG_DMA_SHARED_BUFFER. The CONFIG_VFIO_PCI_DMABUF feature > conditionally includes support for VFIO_DEVICE_FEATURE_DMA_BUF, > depending on the availability of CONFIG_PCI_P2PDMA. > > When the DMABUF feature is not present, DMABUFs are used internally > for the BAR mappings. In this case, DMABUF attach is prohibited (and > the requirement for a P2PDMA provider is relaxed). > > Signed-off-by: Matt Evans <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
