Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Jason Gunthorpe
On Tue, Apr 26, 2022 at 02:59:31PM -0600, Alex Williamson wrote: > > The best you could do is make a dummy IOAS then attach the device, > > read the mappings, detatch, and then do your unmaps. > > Right, the same thing the kernel does currently. > > > I'm imagining something like IOMMUFD_DEVICE_

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Alex Williamson
On Tue, 26 Apr 2022 16:27:03 -0300 Jason Gunthorpe wrote: > On Tue, Apr 26, 2022 at 12:45:41PM -0600, Alex Williamson wrote: > > On Tue, 26 Apr 2022 11:11:56 -0300 > > Jason Gunthorpe wrote: > > > > > On Tue, Apr 26, 2022 at 10:08:30PM +0800, Yi Liu wrote: > > > > > > > > I think it is str

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Jason Gunthorpe
On Tue, Apr 26, 2022 at 12:45:41PM -0600, Alex Williamson wrote: > On Tue, 26 Apr 2022 11:11:56 -0300 > Jason Gunthorpe wrote: > > > On Tue, Apr 26, 2022 at 10:08:30PM +0800, Yi Liu wrote: > > > > > > I think it is strange that the allowed DMA a guest can do depends on > > > > the order how devi

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Alex Williamson
On Tue, 26 Apr 2022 11:11:56 -0300 Jason Gunthorpe wrote: > On Tue, Apr 26, 2022 at 10:08:30PM +0800, Yi Liu wrote: > > > > I think it is strange that the allowed DMA a guest can do depends on > > > the order how devices are plugged into the guest, and varys from > > > device to device? > > > >

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Jason Gunthorpe
On Tue, Apr 26, 2022 at 10:08:30PM +0800, Yi Liu wrote: > > I think it is strange that the allowed DMA a guest can do depends on > > the order how devices are plugged into the guest, and varys from > > device to device? > > > > IMHO it would be nicer if qemu would be able to read the new reserved

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Yi Liu
On 2022/4/26 21:41, Jason Gunthorpe wrote: On Tue, Apr 26, 2022 at 10:41:01AM +, Tian, Kevin wrote: That's one case of incompatibility, but the IOMMU attach group callback can fail in a variety of ways. One that we've seen that is not uncommon is that we might have an mdev container with

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Jason Gunthorpe
On Tue, Apr 26, 2022 at 05:55:29PM +0800, Yi Liu wrote: > > I also suggest falling back to using "/dev/char/%u:%u" if the above > > does not exist which prevents "vfio/devices/vfio" from turning into > > ABI. > > do you mean there is no matched file under /dev/vfio/devices/? Is this > possible? T

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Jason Gunthorpe
On Tue, Apr 26, 2022 at 10:41:01AM +, Tian, Kevin wrote: > That's one case of incompatibility, but the IOMMU attach group callback > can fail in a variety of ways. One that we've seen that is not > uncommon is that we might have an mdev container with various mappings > to other devices.

RE: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Tuesday, April 26, 2022 5:55 PM > On 2022/4/22 22:58, Jason Gunthorpe wrote: > > On Thu, Apr 14, 2022 at 03:47:07AM -0700, Yi Liu wrote: > > > >> + > >> +/* try to attach to an existing container in this space */ > >> +QLIST_FOREACH(bcontainer, &space->containers,

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-26 Thread Yi Liu
Hi Jason, On 2022/4/22 22:58, Jason Gunthorpe wrote: On Thu, Apr 14, 2022 at 03:47:07AM -0700, Yi Liu wrote: +static int vfio_get_devicefd(const char *sysfs_path, Error **errp) +{ +long int vfio_id = -1, ret = -ENOTTY; +char *path, *tmp = NULL; +DIR *dir; +struct dirent *dent;

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-22 Thread Alex Williamson
On Fri, 22 Apr 2022 11:58:15 -0300 Jason Gunthorpe wrote: > > I don't see IOMMU_IOAS_IOVA_RANGES called at all, that seems like a > problem.. Not as much as you might think. Note that you also won't find QEMU testing VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE in the QEMU vfio-pci driver either. The

Re: [RFC 15/18] vfio/iommufd: Implement iommufd backend

2022-04-22 Thread Jason Gunthorpe
On Thu, Apr 14, 2022 at 03:47:07AM -0700, Yi Liu wrote: > +static int vfio_get_devicefd(const char *sysfs_path, Error **errp) > +{ > +long int vfio_id = -1, ret = -ENOTTY; > +char *path, *tmp = NULL; > +DIR *dir; > +struct dirent *dent; > +struct stat st; > +gchar *contents