[PATCH v3 07/24] vfio/pci: Preserve vfio-pci device files across Live Update

David Matlack dmatlack at google.com
Tue Apr 21 10:40:29 PDT 2026


On Mon, Mar 23, 2026 at 4:58 PM David Matlack <dmatlack at google.com> wrote:

> +static int vfio_pci_liveupdate_freeze(struct liveupdate_file_op_args *args)
> +{
> +       struct vfio_device *device = vfio_device_from_file(args->file);
> +       struct vfio_pci_core_device *vdev;
> +       struct pci_dev *pdev;
> +       int ret;
> +
> +       vdev = container_of(device, struct vfio_pci_core_device, vdev);
> +       pdev = vdev->pdev;
> +
> +       guard(mutex)(&device->dev_set->lock);
> +
> +       /*
> +        * Userspace must disable interrupts on the device prior to freeze so
> +        * that the device does not send any interrupts until new interrupt
> +        * handlers have been established by the next kernel.
> +        */
> +       if (vdev->irq_type != VFIO_PCI_NUM_IRQS) {
> +               pci_err(pdev, "Freeze failed! Interrupts are still enabled.\n");
> +               return -EINVAL;
> +       }
> +
> +       ret = pci_load_saved_state(pdev, vdev->pci_saved_state);
> +       if (ret)
> +               return ret;
> +
> +       vfio_pci_core_try_reset(vdev);

I think a call to pci_clear_master() is needed here to so the device
stops issuing memory transactions while VFIO is trying to resetting
it. Otherwise I see these timeouts when running
vfio_pci_liveupdate_kexec_test with Intel DSA: "timed out waiting for
pending transaction; performing function level reset anyway".

Sashiko also wondered if pci_clear_master() is needed to ensure that
the device has bus mastering disabled during the kexec but I don't
think that is actually an issue. vfio_pci_core_enable() makes sure
that vdev->pci_saved_state has bus mastering disabled, so
pci_restore_state() below here should guaranteed it is clear during
kexec.

https://sashiko.dev/#/patchset/20260323235817.1960573-1-dmatlack%40google.com?part=7

> +       pci_restore_state(pdev);
> +       return 0;
>  }



More information about the kexec mailing list