Re: [PATCH v4 02/16] vfio/pci: Preserve vfio-pci device files across Live Update

From: Vipin Sharma

Date: Mon May 18 2026 - 12:38:01 EST


On Thu, May 14, 2026 at 05:24:46PM +0200, Pratyush Yadav wrote:
> On Wed, May 13 2026, Samiullah Khawaja wrote:
>
> > On Tue, May 12, 2026 at 02:29:19PM -0700, Vipin Sharma wrote:
> >>On Tue, May 12, 2026 at 01:59:51PM -0700, David Matlack wrote:
> >>> On Mon, May 11, 2026 at 4:48 PM Vipin Sharma <vipinsh@xxxxxxxxxx> wrote:
> >>>
> >>> > diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig
> >>> > index c12d614fc6c4..019de053f116 100644
> >>> > --- a/drivers/vfio/pci/Kconfig
> >>> > +++ b/drivers/vfio/pci/Kconfig
> >>> > @@ -45,13 +45,15 @@ config VFIO_PCI_IGD
> >>> >
> >>> > config VFIO_PCI_LIVEUPDATE
> >>> > bool "VFIO PCI support for Live Update (EXPERIMENTAL)"
> >>> > - depends on PCI_LIVEUPDATE
> >>> > + depends on PCI_LIVEUPDATE && VFIO_DEVICE_CDEV
> >>> > help
> >>> > Support for preserving devices bound to vfio-pci across a Live
> >>> > Update. This option should only be enabled by developers working on
> >>> > implementing this support. Once enough support has landed in the
> >>> > kernel, this option will no longer be marked EXPERIMENTAL.
> >>> >
> >>> > + Enabling this will disable support for VFIO PCI DMA buffer.
> >>> > +
> >>> > If you don't know what to do here, say N.
> >>> >
> >>> > endif
> >>> > @@ -68,7 +70,7 @@ config VFIO_PCI_ZDEV_KVM
> >>> > To enable s390x KVM vfio-pci extensions, say Y.
> >>> >
> >>> > config VFIO_PCI_DMABUF
> >>> > - def_bool y if VFIO_PCI_CORE && PCI_P2PDMA && DMA_SHARED_BUFFER
> >>> > + def_bool y if VFIO_PCI_CORE && PCI_P2PDMA && DMA_SHARED_BUFFER && !VFIO_PCI_LIVEUPDATE
> >>>
> >>> Why does enabling VFIO_PCI_LIVEUPDATE require disabling
> >>> VFIO_PCI_DMABUF? I saw the cover letter says "to keep things simple",
> >>> but what specific problem does this solve or simplify?
> >>
> >>I should have provided more details there.
> >>
> >>When device is getting reset in vfio_pci_liveupdate_freeze(), we are
> >>zapping userspace mapped bars, we also need to use
> >>vfio_pci_dma_buf_move() to revoke dma buffer access or
> >>vfio_pci_dma_buf_cleanup() combination. Cleanup takes the memory lock
> >>which freeze already takes, and there are some refcounts which are
> >>managed in both of these APIs. This was causing complexities with code
> >>flow based on result of pci_load_saved_state(). All this was adding more
> >>refactoring than I wanted in the series.
> >
> > Maybe we can return -EOPNOTSUPP if any dmabufs for this vfio cdev are
> > exported during preserve?

Currently, no APIs are present to fetch if dmabufs are exported or not.
I will add one patch to this series to return EOPNOTSUPP and remove
condition from the config.

>
> Whichever way you go with, a TODO/comment would be nice to have so
> someone (including future you) looking at this code knows why this
> restriction exists.
>

I will add comment in the next version.