[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALzav=dd3eAgqiWM-MKhu77xq0iWRMrESkDaT9KgzNgSvcjeVQ@mail.gmail.com>
Date: Fri, 31 Oct 2025 14:41:13 -0700
From: David Matlack <dmatlack@...gle.com>
To: Pasha Tatashin <pasha.tatashin@...een.com>
Cc: Jacob Pan <jacob.pan@...ux.microsoft.com>, Vipin Sharma <vipinsh@...gle.com>,
bhelgaas@...gle.com, alex.williamson@...hat.com, jgg@...pe.ca,
graf@...zon.com, pratyush@...nel.org, gregkh@...uxfoundation.org,
chrisl@...nel.org, rppt@...nel.org, skhawaja@...gle.com, parav@...dia.com,
saeedm@...dia.com, kevin.tian@...el.com, jrhilke@...gle.com, david@...hat.com,
jgowans@...zon.com, dwmw2@...radead.org, epetron@...zon.de,
junaids@...gle.com, linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org,
kvm@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [RFC PATCH 06/21] vfio/pci: Accept live update preservation
request for VFIO cdev
On Thu, Oct 30, 2025 at 5:19 PM Pasha Tatashin
<pasha.tatashin@...een.com> wrote:
> On Thu, Oct 30, 2025 at 7:10 PM David Matlack <dmatlack@...gle.com> wrote:
> > On 2025-10-27 01:44 PM, Jacob Pan wrote:
> > > On Fri, 17 Oct 2025 17:06:58 -0700 Vipin Sharma <vipinsh@...gle.com> wrote:
> > > > + guard(mutex)(&device->dev_set->lock);
> > > > + return vfio_device_cdev_opened(device);
> > >
> > > IIUC, vfio_device_cdev_opened(device) will only return true after
> > > vfio_df_ioctl_bind_iommufd(). Where it does:
> > > device->cdev_opened = true;
> > >
> > > Does this imply that devices not bound to an iommufd cannot be
> > > preserved?
> >
> > Event if being bound to an iommufd is required, it seems wrong to check
> > it in can_preserve(), as the device can just be unbound from the iommufd
> > before preserve().
> >
> > I think can_preserve() just needs to check if this is a VFIO cdev file,
> > i.e. vfio_device_from_file() returns non-NULL.
>
> +1, can_preserve() must be fast, as it might be called on every single
> FD that is being preserved, to check if type is correct.
> So, simply check if "struct file" is cdev via ops check perhaps via
> and thats it. It should be a very simple operation
Small correction, vfio_device_from_file() checks if file->fops are
&vfio_device_fops. But device files acquired via group FDs use the
same ops. So I think we actually need to check "device &&
!device->group" here to identify VFIO cdev files, and then check
device->ops == &vfio_pci_ops to make sure this is a vfio-pci device.
Powered by blists - more mailing lists