Subject: Re: [PATCH V9 mlx5-next 08/15] vfio: Have the core code decode the VFIO_DEVICE_FEATURE ioctl

From: Jason Gunthorpe <[email-masked]>
Date: Wed, 2 Mar 2022 10:23:55 -0400

On Wed, Mar 02, 2022 at 11:00:08AM +0100, Cornelia Huck wrote:
> > diff --git a/include/linux/vfio.h b/include/linux/vfio.h
> > index 76191d7abed1..ca69516f869d 100644
> > +++ b/include/linux/vfio.h
> > @@ -55,6 +55,7 @@ struct vfio_device {
> >   * @match: Optional device name match callback (return: 0 for no-match, >0 for
> >   *         match, -errno for abort (ex. match with insufficient or incorrect
> >   *         additional args)
> > + * @device_feature: Fill in the VFIO_DEVICE_FEATURE ioctl
> >   */
> >  struct vfio_device_ops {
> >  	char	*name;
> > @@ -69,8 +70,39 @@ struct vfio_device_ops {
> >  	int	(*mmap)(struct vfio_device *vdev, struct vm_area_struct *vma);
> >  	void	(*request)(struct vfio_device *vdev, unsigned int count);
> >  	int	(*match)(struct vfio_device *vdev, char *buf);
> > +	int	(*device_feature)(struct vfio_device *device, u32 flags,
> > +				  void __user *arg, size_t argsz);
> >  };
> 
> Is the expectation that most drivers will eventually implement
> ->device_feature()?

I would say probably no, but it depends on what future features are
designed. Maybe we will make a new all-driver one someday?

> migration; mostly asking because e.g. ->match() is explicitly marked as
> "optional". As the only callback every driver implements seems to be
> ->ioctl() (if we also include the samples), "optional" or not does not
> seem to be particularly relevant anyway.

The comment could have said optional here too, but it is also clear
from the code.

Thanks,
Jason