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

From: Jason Gunthorpe
Date: Mon Jun 26 2023 - 12:24:29 EST


On Mon, Jun 26, 2023 at 10:06:29AM -0600, Alex Williamson wrote:
> On Fri, 23 Jun 2023 10:26:05 -0300
> Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:
>
> > 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..
>
> 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.

Hum, maybe this part should be pushed into the cap helpers..

Jason