Re: [PATCH v3 2/2] vfio/cdx: add interrupt support

From: Gupta, Nipun
Date: Mon Mar 04 2024 - 06:30:43 EST




On 3/1/2024 11:15 PM, Alex Williamson wrote:
On Mon, 26 Feb 2024 14:18:13 +0530
Nipun Gupta <nipun.gupta@xxxxxxx> wrote:

Support the following ioctls for CDX devices:
- VFIO_DEVICE_GET_IRQ_INFO
- VFIO_DEVICE_SET_IRQS

This allows user to set an eventfd for cdx device interrupts and
trigger this interrupt eventfd from userspace.
All CDX device interrupts are MSIs. The MSIs are allocated from the
CDX-MSI domain.

Signed-off-by: Nipun Gupta <nipun.gupta@xxxxxxx>
Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@xxxxxxx>
---


<snip>

+static int vfio_cdx_ioctl_get_irq_info(struct vfio_cdx_device *vdev,
+ struct vfio_irq_info __user *arg)
+{
+ unsigned long minsz = offsetofend(struct vfio_irq_info, count);
+ struct cdx_device *cdx_dev = to_cdx_device(vdev->vdev.dev);
+ struct vfio_irq_info info;
+
+ if (copy_from_user(&info, arg, minsz))
+ return -EFAULT;
+
+ if (info.argsz < minsz)
+ return -EINVAL;
+
+ if (info.index >= 1)
+ return -EINVAL;
+
+ info.flags = VFIO_IRQ_INFO_EVENTFD;


I think the way you're using this you'd also need the
VFIO_IRQ_INFO_NORESIZE to indicate the MSI range cannot be expanded
from the initial setting. Thanks,

Yes, agree. Will update the flags in the next spin.

Thanks,
Nipun


Alex