[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230626100629.3c318922.alex.williamson@redhat.com>
Date: Mon, 26 Jun 2023 10:06:29 -0600
From: Alex Williamson <alex.williamson@...hat.com>
To: Jason Gunthorpe <jgg@...dia.com>
Cc: ankita@...dia.com, aniketa@...dia.com, cjia@...dia.com,
kwankhede@...dia.com, targupta@...dia.com, vsethi@...dia.com,
acurrid@...dia.com, apopple@...dia.com, jhubbard@...dia.com,
danw@...dia.com, kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/1] vfio/nvgpu: Add vfio pci variant module for
grace hopper
On Fri, 23 Jun 2023 10:26:05 -0300
Jason Gunthorpe <jgg@...dia.com> wrote:
> On Wed, Jun 21, 2023 at 08:07:20PM -0700, ankita@...dia.com 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..
It's required for backwards compatibility. If a userspace doesn't
support the info ioctl capabilities chain, it gets the basic
information successfully, while an enlightened userspace makes use of
the flags to know that a capability chain is available but unreported
due to an insufficient buffer size, with the required size being
provided in the return structure.
> > +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?
Yes, I don't think return -errno matches what we discussed for
returning -1 on read and dropping writes outside of the device memory.
Also see comments in my review that read/write should handle the
coherent memory area as well, the device should work with x-no-mmap=on.
Thanks,
Alex
Powered by blists - more mailing lists