Re: [PATCH v4 1/1] vfio/nvgpu: Add vfio pci variant module for grace hopper

From: Jason Gunthorpe
Date: Fri Jun 23 2023 - 09:26:15 EST


On Wed, Jun 21, 2023 at 08:07:20PM -0700, ankita@xxxxxxxxxx wrote:
> + if (caps.size) {
> + info.flags |= VFIO_REGION_INFO_FLAG_CAPS;
> + if (info.argsz < sizeof(info) + caps.size) {
> + info.argsz = sizeof(info) + caps.size;
> + info.cap_offset = 0;

Shouldn't this be an error if we can't fit the caps into the response?
Silently discarding the caps seems wrong..

> +static ssize_t nvgpu_vfio_pci_read(struct vfio_device *core_vdev,
> + char __user *buf, size_t count, loff_t *ppos)
> +{
> + unsigned int index = VFIO_PCI_OFFSET_TO_INDEX(*ppos);
> +
> + /*
> + * Only the device memory present on the hardware is mapped, which may
> + * not be power-of-2 aligned. A read to the BAR2 region implies an
> + * access outside the available device memory on the hardware.
> + */
> + if (index == VFIO_PCI_BAR2_REGION_INDEX)
> + return -EINVAL;

What does the qemu do in this case? Crash the VM?

Jason