RE: [PATCH 08/13] vfio: Block device access via device fd until device is opened

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Sent: Wednesday, January 18, 2023 9:52 PM
> 
> On Wed, Jan 18, 2023 at 09:35:33AM +0000, Tian, Kevin wrote:
> > > From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> > > Sent: Tuesday, January 17, 2023 9:50 PM
> > >
> > > Allow the vfio_device file to be in a state where the device FD is
> > > opened but the device cannot be used by userspace (i.e. its .open_device()
> > > hasn't been called). This inbetween state is not used when the device
> > > FD is spawned from the group FD, however when we create the device FD
> > > directly by opening a cdev it will be opened in the blocked state.
> > >
> > > In the blocked state, currently only the bind operation is allowed,
> > > other device accesses are not allowed. Completing bind will allow user
> > > to further access the device.
> > >
> > > This is implemented by adding a flag in struct vfio_device_file to mark
> > > the blocked state and using a simple smp_load_acquire() to obtain the
> > > flag value and serialize all the device setup with the thread accessing
> > > this device.
> > >
> > > Due to this scheme it is not possible to unbind the FD, once it is bound,
> > > it remains bound until the FD is closed.
> > >
> >
> > My question to the last version was not answered...
> >
> > Can you elaborate why it is impossible to unbind? Is it more an
> > implementation choice or conceptual restriction?
> 
> At least for the implementation it is due to the use of the lockless
> test for bind.
> 
> It can safely handle unbind->bind but it cannot handle
> bind->unbind. To allows this we'd need to add a lock on all the vfio
> ioctls which seems costly.
> 

OK, it makes sense. Yi, can you add this message in next version?




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux