From: Alex Williamson <alex.williamson@redhat.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: ankita@nvidia.com, aniketa@nvidia.com, cjia@nvidia.com,
kwankhede@nvidia.com, targupta@nvidia.com, vsethi@nvidia.com,
acurrid@nvidia.com, apopple@nvidia.com, jhubbard@nvidia.com,
danw@nvidia.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/1] vfio/nvgpu: Add vfio pci variant module for grace hopper
Date: Mon, 26 Jun 2023 10:06:29 -0600 [thread overview]
Message-ID: <20230626100629.3c318922.alex.williamson@redhat.com> (raw)
In-Reply-To: <ZJWdbbNESp1+6GVN@nvidia.com>
On Fri, 23 Jun 2023 10:26:05 -0300
Jason Gunthorpe <jgg@nvidia.com> wrote:
> On Wed, Jun 21, 2023 at 08:07:20PM -0700, ankita@nvidia.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
next prev parent reply other threads:[~2023-06-26 16:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 3:07 ankita
2023-06-23 6:27 ` Cédric Le Goater
2023-06-23 11:47 ` Jason Gunthorpe
2023-06-23 13:04 ` Cédric Le Goater
2023-06-23 13:07 ` Jason Gunthorpe
2023-06-23 15:07 ` Cédric Le Goater
2023-06-23 16:38 ` Jason Gunthorpe
2023-06-23 13:26 ` Jason Gunthorpe
2023-06-26 16:06 ` Alex Williamson [this message]
2023-06-26 16:23 ` Jason Gunthorpe
2023-06-28 19:00 ` Ankit Agrawal
2023-06-26 16:01 ` Alex Williamson
2023-07-05 18:37 ` Ankit Agrawal
2023-07-05 22:16 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230626100629.3c318922.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=acurrid@nvidia.com \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=apopple@nvidia.com \
--cc=cjia@nvidia.com \
--cc=danw@nvidia.com \
--cc=jgg@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=targupta@nvidia.com \
--cc=vsethi@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®