Merge branch 'v6.6/vfio/cdev' of https://github.com/awilliam/linux-vfio into iommufd for-next
Shared branch with VFIO containing the enablement for VFIO "cdev" devices. This is required by following iommufd patches which add new ioctls to the VFIO cdev. ======= Existing VFIO provides group-centric user APIs for userspace. Userspace opens the /dev/vfio/$group_id first before getting device fd and hence getting access to device. This is not the desired model for iommufd. Per the conclusion of community discussion[1], iommufd provides device-centric kAPIs and requires its consumer (like VFIO) to be device-centric user APIs. Such user APIs are used to associate device with iommufd and also the I/O address spaces managed by the iommufd. This series first introduces a per device file structure to be prepared for further enhancement and refactors the kvm-vfio code to be prepared for accepting device file from userspace. After this, adds a mechanism for blocking device access before iommufd bind. Then refactors the vfio to be able to handle cdev paths (e.g. iommufd binding, no-iommufd, [de]attach ioas). This refactor includes making the device_open exclusive between the group and the cdev path, only allow single device open in cdev path; vfio-iommufd code is also refactored to support cdev. e.g. split the vfio_iommufd_bind() into two steps. Eventually, adds the cdev support for vfio device and the new ioctls, then makes group infrastructure optional as it is not needed when vfio device cdev is compiled. This series is based on some preparation works done to vfio emulated devices[2] and vfio pci hot reset enhancements[3]. Per discussion[4], this series does not support cdev for physical devices that do not have IOMMU. Such devices only have group-centric user APIs. This series is a prerequisite for iommu nesting for vfio device[5] [6]. [1] https://lore.kernel.org/kvm/BN9PR11MB5433B1E4AE5B0480369F97178C189@BN9PR11MB5433.namprd11.prod.outlook.com/ [2] https://lore.kernel.org/kvm/20230327093351.44505-1-yi.l.liu@intel.com/ - merged [3] https://lore.kernel.org/kvm/20230718105542.4138-1-yi.l.liu@intel.com/ [4] https://lore.kernel.org/kvm/20230525095939.37ddb8ce.alex.williamson@redhat.com/ [5] https://lore.kernel.org/linux-iommu/20230511143844.22693-1-yi.l.liu@intel.com/ [6] https://lore.kernel.org/linux-iommu/20230511145110.27707-1-yi.l.liu@intel.com/#t ======= * 'v6.6/vfio/cdev' of https://github.com/awilliam/linux-vfio: (36 commits) docs: vfio: Add vfio device cdev description vfio: Compile vfio_group infrastructure optionally vfio: Move the IOMMU_CAP_CACHE_COHERENCY check in __vfio_register_dev() vfio: Add VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT vfio: Add VFIO_DEVICE_BIND_IOMMUFD vfio: Avoid repeated user pointer cast in vfio_device_fops_unl_ioctl() iommufd: Add iommufd_ctx_from_fd() vfio: Test kvm pointer in _vfio_device_get_kvm_safe() vfio: Add cdev for vfio_device vfio: Move device_del() before waiting for the last vfio_device registration refcount vfio: Move vfio_device_group_unregister() to be the first operation in unregister vfio-iommufd: Add detach_ioas support for emulated VFIO devices iommufd/device: Add iommufd_access_detach() API vfio-iommufd: Add detach_ioas support for physical VFIO devices vfio: Record devid in vfio_device_file vfio-iommufd: Split bind/attach into two steps vfio-iommufd: Move noiommu compat validation out of vfio_iommufd_bind() vfio: Make vfio_df_open() single open for device cdev path vfio: Add cdev_device_open_cnt to vfio_group vfio: Block device access via device fd until device is opened vfio: Pass struct vfio_device_file * to vfio_device_open/close() kvm/vfio: Accept vfio device file from userspace kvm/vfio: Prepare for accepting vfio device fd vfio: Accept vfio device file in the KVM facing kAPI vfio: Refine vfio file kAPIs for KVM vfio: Allocate per device file structure vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET vfio/pci: Copy hot-reset device info to userspace in the devices loop vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev vfio: Add helper to search vfio_device in a dev_set ...
Showing
drivers/vfio/device_cdev.c
0 → 100644
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment