Re: [RFC PATCH v4 04/10] vfio/pci: let vfio_pci know number of vendor regions and vendor irqs

From: Cornelia Huck
Date: Thu Jun 04 2020 - 11:25:34 EST


On Sun, 17 May 2020 22:49:44 -0400
Yan Zhao <yan.y.zhao@xxxxxxxxx> wrote:

> This allows a simpler VFIO_DEVICE_GET_INFO ioctl in vendor driver
>
> Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
> Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
> ---
> drivers/vfio/pci/vfio_pci.c | 23 +++++++++++++++++++++--
> drivers/vfio/pci/vfio_pci_private.h | 2 ++
> include/linux/vfio.h | 3 +++
> 3 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> index 290b7ab55ecf..30137c1c5308 100644
> --- a/drivers/vfio/pci/vfio_pci.c
> +++ b/drivers/vfio/pci/vfio_pci.c
> @@ -105,6 +105,24 @@ void *vfio_pci_vendor_data(void *device_data)
> }
> EXPORT_SYMBOL_GPL(vfio_pci_vendor_data);
>
> +int vfio_pci_set_vendor_regions(void *device_data, int num_vendor_regions)
> +{
> + struct vfio_pci_device *vdev = device_data;
> +
> + vdev->num_vendor_regions = num_vendor_regions;

Do we need any kind of sanity check here, in case this is called with a
bogus value?

> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(vfio_pci_set_vendor_regions);
> +
> +
> +int vfio_pci_set_vendor_irqs(void *device_data, int num_vendor_irqs)
> +{
> + struct vfio_pci_device *vdev = device_data;
> +
> + vdev->num_vendor_irqs = num_vendor_irqs;

Here as well.

> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(vfio_pci_set_vendor_irqs);
> /*
> * Our VGA arbiter participation is limited since we don't know anything
> * about the device itself. However, if the device is the only VGA device

(...)