RE: [PATCH v3 03/15] vfio: Accept vfio device file in the driver facing kAPI

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

 



> From: Alex Williamson <alex.williamson@xxxxxxxxxx>
> Sent: Tuesday, February 14, 2023 7:22 AM
> 
> On Mon, 13 Feb 2023 07:13:36 -0800
> Yi Liu <yi.l.liu@xxxxxxxxx> wrote:
> 
> > This makes the vfio file kAPIs to accepte vfio device files, also a
> > preparation for vfio device cdev support.
> >
> > For the kvm set with vfio device file, kvm pointer is stored in struct
> > vfio_device_file, and use kvm_ref_lock to protect kvm set and kvm
> > pointer usage within VFIO. This kvm pointer will be set to vfio_device
> > after device file is bound to iommufd in the cdev path.
> >
> > Signed-off-by: Yi Liu <yi.l.liu@xxxxxxxxx>
> > Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
> > ---
> >  drivers/vfio/vfio.h      |  2 ++
> >  drivers/vfio/vfio_main.c | 51
> ++++++++++++++++++++++++++++++++++++----
> >  2 files changed, 49 insertions(+), 4 deletions(-)
> 
> This subtly changes the behavior of the vfio-pci hot reset functions
> without updating the uAPI description or implementation to use less
> group-centric variables.  The new behavior appears to be that cdev fds
> can also be passed to prove ownership of the affected set of devices
> for a hot reset, but this probably needs to be examined for gaps.

Yes. user could pass cdev fds afterward. I suppose the VFIO_DEVICE_GET_PCI_HOT_RESET_INFO
will report the existing info (group_id, segment, bus, devfn). While userspace
passes device fds to the kernel for resetting. Need to update struct vfio_pci_hot_reset
and the kernel reset code accordingly. Probably, it is a following series for it. 😊

/**
 * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12,
 *					      struct vfio_pci_hot_reset_info)
 *
 * Return: 0 on success, -errno on failure:
 *	-enospc = insufficient buffer, -enodev = unsupported for device.
 */
struct vfio_pci_dependent_device {
	__u32	group_id;
	__u16	segment;
	__u8	bus;
	__u8	devfn; /* Use PCI_SLOT/PCI_FUNC */
};

struct vfio_pci_hot_reset_info {
	__u32	argsz;
	__u32	flags;
	__u32	count;
	struct vfio_pci_dependent_device	devices[];
};

#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO	_IO(VFIO_TYPE, VFIO_BASE + 12)

/**
 * VFIO_DEVICE_PCI_HOT_RESET - _IOW(VFIO_TYPE, VFIO_BASE + 13,
 *				    struct vfio_pci_hot_reset)
 *
 * Return: 0 on success, -errno on failure.
 */
struct vfio_pci_hot_reset {
	__u32	argsz;
	__u32	flags;
	__u32	count;
	__s32	group_fds[];
};

#define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE + 13)




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux