[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aTAzMUa7Gcm+7j9D@devgpu015.cco6.facebook.com>
Date: Wed, 3 Dec 2025 04:55:13 -0800
From: Alex Mastro <amastro@...com>
To: David Matlack <dmatlack@...gle.com>
CC: Alex Williamson <alex@...zbot.org>,
Adithya Jayachandran
<ajayachandra@...dia.com>,
Alistair Popple <apopple@...dia.com>,
Andrew
Morton <akpm@...ux-foundation.org>,
Bjorn Helgaas <bhelgaas@...gle.com>, Chris Li <chrisl@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Jacob Pan
<jacob.pan@...ux.microsoft.com>,
Jason Gunthorpe <jgg@...dia.com>, Jason
Gunthorpe <jgg@...pe.ca>,
Josh Hilke <jrhilke@...gle.com>, Kevin Tian
<kevin.tian@...el.com>,
<kvm@...r.kernel.org>, Leon Romanovsky
<leonro@...dia.com>,
<linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
<linux-pci@...r.kernel.org>, Lukas Wunner
<lukas@...ner.de>,
Mike Rapoport <rppt@...nel.org>, Parav Pandit
<parav@...dia.com>,
Pasha Tatashin <pasha.tatashin@...een.com>,
Philipp
Stanner <pstanner@...hat.com>,
Pratyush Yadav <pratyush@...nel.org>,
Saeed
Mahameed <saeedm@...dia.com>,
Samiullah Khawaja <skhawaja@...gle.com>,
Shuah
Khan <shuah@...nel.org>, Tomita Moeko <tomitamoeko@...il.com>,
Vipin Sharma
<vipinsh@...gle.com>, William Tu <witu@...dia.com>,
Yi Liu
<yi.l.liu@...el.com>, Yunxiang Li <Yunxiang.Li@....com>,
Zhu Yanjun
<yanjun.zhu@...ux.dev>
Subject: Re: [PATCH 06/21] vfio/pci: Retrieve preserved device files after
Live Update
On Wed, Nov 26, 2025 at 07:35:53PM +0000, David Matlack wrote:
> From: Vipin Sharma <vipinsh@...gle.com>
> static int vfio_pci_liveupdate_retrieve(struct liveupdate_file_op_args *args)
> {
> - return -EOPNOTSUPP;
> + struct vfio_pci_core_device_ser *ser;
> + struct vfio_device *device;
> + struct folio *folio;
> + struct file *file;
> + int ret;
> +
> + folio = kho_restore_folio(args->serialized_data);
> + if (!folio)
> + return -ENOENT;
Should this be consistent with the behavior of pci_flb_retrieve() which panics
on failure? The short circuit failure paths which follow leak the folio,
which seems like a hygiene issue, but the practical significance is moot if
vfio_pci_liveupdate_retrieve() failure is catastrophic anyways?
> +
> + ser = folio_address(folio);
> +
> + device = vfio_find_device(ser, match_device);
> + if (!device)
> + return -ENODEV;
> +
> + /*
> + * During a Live Update userspace retrieves preserved VFIO cdev files by
> + * issuing an ioctl on /dev/liveupdate rather than by opening VFIO
> + * character devices.
> + *
> + * To handle that scenario, this routine simulates opening the VFIO
> + * character device for userspace with an anonymous inode. The returned
> + * file has the same properties as a cdev file (e.g. operations are
> + * blocked until BIND_IOMMUFD is called), aside from the inode
> + * association.
> + */
> + file = anon_inode_getfile_fmode("[vfio-device-liveupdate]",
> + &vfio_device_fops, NULL,
> + O_RDWR, FMODE_PREAD | FMODE_PWRITE);
> +
> + if (IS_ERR(file)) {
> + ret = PTR_ERR(file);
> + goto out;
> + }
> +
> + ret = __vfio_device_fops_cdev_open(device, file);
> + if (ret) {
> + fput(file);
> + goto out;
> + }
> +
> + args->file = file;
> +
> +out:
> + /* Drop the reference from vfio_find_device() */
> + put_device(&device->device);
> +
> + return ret;
> +}
Powered by blists - more mailing lists