Re: [PATCH v6 12/27] vfio: Enforce preserved devices are retrieved via LIVEUPDATE_SESSION_RETRIEVE_FD

From: David Matlack

Date: Thu Nov 19 2026 - 19:19:58 EST


On Mon Nov 2, 2026 at 7:36 AM PST, Vipin Sharma wrote:
> diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h
> index 12557d45dfee..e6ca4c3fda06 100644
> --- a/drivers/vfio/vfio.h
> +++ b/drivers/vfio/vfio.h
> @@ -11,6 +11,7 @@
> #include <linux/cdev.h>
> #include <linux/module.h>
> #include <linux/vfio.h>
> +#include <linux/pci.h>
>
> struct iommufd_ctx;
> struct iommu_group;
> @@ -446,4 +447,21 @@ static inline void vfio_device_debugfs_init(struct vfio_device *vdev) { }
> static inline void vfio_device_debugfs_exit(struct vfio_device *vdev) { }
> #endif /* CONFIG_VFIO_DEBUGFS */
>
> +#ifdef CONFIG_VFIO_PCI_LIVEUPDATE
> +static inline bool vfio_liveupdate_incoming_is_preserved(struct vfio_device *device)
> +{
> + struct device *d = device->dev;
> +
> + if (dev_is_pci(d))
> + return pci_liveupdate_is_incoming(to_pci_dev(d));
> +
> + return false;
> +}
> +#else
> +static inline bool vfio_liveupdate_incoming_is_preserved(struct vfio_device *device)
> +{
> + return false;
> +}
> +#endif /* CONFIG_VFIO_PCI_LIVEUPDATE */

No need for the ifdef here and 2 definitions here. If
CONFIG_PCI_LIVEUPDATE is not enabled then the compiler should be able to
optimize vfio_liveupdate_incoming_is_preserved() to false.