On Fri, Feb 03, 2023 at 06:57:02PM +0100, Eric Auger wrote: > Hi Jason, > > On 2/3/23 13:51, Jason Gunthorpe wrote: > > On Tue, Jan 31, 2023 at 09:53:05PM +0100, Eric Auger wrote: > >> Now we support two types of iommu backends, let's add the capability > >> to select one of them. This depends on whether an iommufd object has > >> been linked with the vfio-pci device: > >> > >> if the user wants to use the legacy backend, it shall not > >> link the vfio-pci device with any iommufd object: > >> > >> -device vfio-pci,host=0000:02:00.0 > >> > >> This is called the legacy mode/backend. > >> > >> If the user wants to use the iommufd backend (/dev/iommu) it > >> shall pass an iommufd object id in the vfio-pci device options: > >> > >> -object iommufd,id=iommufd0 > >> -device vfio-pci,host=0000:02:00.0,iommufd=iommufd0 > >> > >> Note the /dev/iommu device may have been pre-opened by a > >> management tool such as libvirt. This mode is no more considered > >> for the legacy backend. So let's remove the "TODO" comment. > > The vfio cdev should also be pre-openable like iommufd? > > where does the requirement come from? I would expect it helps sandbox security. We couldn't do this with the original VFIO model, but now we can have libvirt open the vfio with privilege and FD pass it to qemu. This way qemu never needs to have privilege to open a VFIO or iommu cdev node. Jason