From: David Matlack <dmatlack@google.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Vipin Sharma <vipinsh@google.com>,
bhelgaas@google.com, alex.williamson@redhat.com,
pasha.tatashin@soleen.com, jgg@ziepe.ca, graf@amazon.com,
pratyush@kernel.org, gregkh@linuxfoundation.org,
chrisl@kernel.org, rppt@kernel.org, skhawaja@google.com,
parav@nvidia.com, saeedm@nvidia.com, kevin.tian@intel.com,
jrhilke@google.com, david@redhat.com, jgowans@amazon.com,
dwmw2@infradead.org, epetron@amazon.de, junaids@google.com,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [RFC PATCH 15/21] PCI: Make PCI saved state and capability structs public
Date: Thu, 30 Oct 2025 23:55:39 +0000 [thread overview]
Message-ID: <aQP6-49_FeB2nNEm@google.com> (raw)
In-Reply-To: <aPSeF_QiUWnhKIma@wunner.de>
On 2025-10-19 10:15 AM, Lukas Wunner wrote:
> On Sat, Oct 18, 2025 at 03:36:20PM -0700, Vipin Sharma wrote:
> > On 2025-10-18 09:17:33, Lukas Wunner wrote:
> > > On Fri, Oct 17, 2025 at 05:07:07PM -0700, Vipin Sharma wrote:
> > > > Move struct pci_saved_state{} and struct pci_cap_saved_data{} to
> > > > linux/pci.h so that they are available to code outside of the PCI core.
> > > >
> > > > These structs will be used in subsequent commits to serialize and
> > > > deserialize PCI state across Live Update.
> > >
> > > That's not sufficient as a justification to make these public in my view.
> > >
> > > There are already pci_store_saved_state() and pci_load_saved_state()
> > > helpers to serialize PCI state. Why do you need anything more?
> > > (Honest question.)
> >
> > In LUO ecosystem, currently, we do not have a solid solution to do
> > proper serialization/deserialization of structs along with versioning
> > between different kernel versions. This work is still being discussed.
> >
> > Here, I created separate structs (exactly same as the original one) to
> > have little bit control on what gets saved in serialized state and
> > correctly gets deserialized after kexec.
> >
> > For example, if I am using existing structs and not creating my own
> > structs then I cannot just do a blind memcpy() between whole of the PCI state
> > prior to kexec to PCI state after the kexec. In the new kernel
> > layout might have changed like addition or removal of a field.
>
> The last time we changed those structs was in 2013 by fd0f7f73ca96.
> So changes are extremely rare.
>
> What could change in theory is the layout of the individual
> capabilities (the data[] in struct pci_cap_saved_data).
> E.g. maybe we decide that we need to save an additional register.
> But that's also rare. Normally we add all the mutable registers
> when a new capability is supported and have no need to amend that
> afterwards.
Yeah that has me worried. A totally innocuous commit that adds, removes,
or reorders a register stashed in data[] could lead a broken device when
VFIO does pci_restore_state() after a Live Update.
Turing pci_save_state into an actual ABI would require adding the
registers into the save state probably, rather than assuming their
order.
But... I wonder if we truly need to preserve the PCI save state
across Live Update.
Based on this comment in drivers/vfio/pci/vfio_pci_core.c, the PCI
save/restore stuff in VFIO is for cleaning up devices that do not
support resets:
648 /*
649 * If we have saved state, restore it. If we can reset the device,
650 * even better. Resetting with current state seems better than
651 * nothing, but saving and restoring current state without reset
652 * is just busy work.
653 */
654 if (pci_load_and_free_saved_state(pdev, &vdev->pci_saved_state)) {
655 pci_info(pdev, "%s: Couldn't reload saved state\n", __func__);
656
657 if (!vdev->reset_works)
658 goto out;
659
660 pci_save_state(pdev);
661 }
So if we just limit Live Update support to devices with reset_works,
then we don't have to deal with preserving the save state.
I will have to double check that reset_works is true for all the devices
we care about supporting for Live Update, but I imagine it will be.
They're all relatively modern PCIe devices.
next prev parent reply other threads:[~2025-10-30 23:55 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-18 0:06 [RFC PATCH 00/21] VFIO live update support Vipin Sharma
2025-10-18 0:06 ` [RFC PATCH 01/21] selftests/liveupdate: Build tests from the selftests/liveupdate directory Vipin Sharma
2025-10-18 0:06 ` [RFC PATCH 02/21] selftests/liveupdate: Create library of core live update ioctls Vipin Sharma
2025-10-18 0:06 ` [RFC PATCH 03/21] selftests/liveupdate: Move do_kexec.sh script to liveupdate/lib Vipin Sharma
2025-10-18 0:06 ` [RFC PATCH 04/21] selftests/liveupdate: Move LUO ioctls calls to liveupdate library Vipin Sharma
2025-10-18 0:06 ` [RFC PATCH 05/21] vfio/pci: Register VFIO live update file handler to Live Update Orchestrator Vipin Sharma
2025-10-31 21:24 ` David Matlack
2025-10-31 22:28 ` David Matlack
2025-10-18 0:06 ` [RFC PATCH 06/21] vfio/pci: Accept live update preservation request for VFIO cdev Vipin Sharma
2025-10-27 20:44 ` Jacob Pan
2025-10-28 13:28 ` Jason Gunthorpe
2025-10-28 17:39 ` Jacob Pan
2025-10-29 16:21 ` Jason Gunthorpe
2025-10-30 23:10 ` David Matlack
2025-10-31 0:18 ` Pasha Tatashin
2025-10-31 21:41 ` David Matlack
2025-10-18 0:06 ` [RFC PATCH 07/21] vfio/pci: Store VFIO PCI device preservation data in KHO for live update Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 08/21] vfio/pci: Retrieve preserved VFIO device for Live Update Orechestrator Vipin Sharma
2025-10-31 23:12 ` David Matlack
2025-10-18 0:07 ` [RFC PATCH 09/21] vfio/pci: Add Live Update finish callback implementation Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 10/21] PCI: Add option to skip Bus Master Enable reset during kexec Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 11/21] vfio/pci: Skip clearing bus master on live update device " Vipin Sharma
2025-10-18 7:09 ` Lukas Wunner
2025-10-18 22:19 ` Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 12/21] vfio/pci: Skip clearing bus master on live update restored device Vipin Sharma
2025-10-20 21:29 ` David Matlack
2025-10-20 22:39 ` Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 13/21] vfio/pci: Preserve VFIO PCI config space through live update Vipin Sharma
2025-10-18 14:59 ` Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 14/21] vfio/pci: Skip device reset on live update restored device Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 15/21] PCI: Make PCI saved state and capability structs public Vipin Sharma
2025-10-18 7:17 ` Lukas Wunner
2025-10-18 22:36 ` Vipin Sharma
2025-10-18 23:11 ` Jason Gunthorpe
2025-10-20 23:49 ` Vipin Sharma
2025-10-22 17:45 ` David Matlack
2025-10-22 17:51 ` Jason Gunthorpe
2025-10-22 17:53 ` Jason Gunthorpe
2025-10-19 8:15 ` Lukas Wunner
2025-10-20 23:54 ` Vipin Sharma
2025-10-30 23:55 ` David Matlack [this message]
2025-10-31 0:06 ` David Matlack
2025-10-18 0:07 ` [RFC PATCH 16/21] vfio/pci: Save and restore the PCI state of the VFIO device Vipin Sharma
2025-10-18 7:25 ` Lukas Wunner
2025-10-18 22:44 ` Vipin Sharma
2025-10-18 15:02 ` Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 17/21] vfio/pci: Disable interrupts before going live update kexec Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 18/21] vfio: selftests: Build liveupdate library in VFIO selftests Vipin Sharma
2025-10-20 20:50 ` David Matlack
2025-10-20 23:55 ` Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 19/21] vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 20/21] vfio: selftests: Add VFIO live update test Vipin Sharma
2025-10-18 0:07 ` [RFC PATCH 21/21] vfio: selftests: Validate vconfig preservation of VFIO PCI device during live update Vipin Sharma
2025-10-18 17:21 ` [RFC PATCH 00/21] VFIO live update support Jason Gunthorpe
2025-10-18 22:53 ` Vipin Sharma
2025-10-18 23:06 ` Jason Gunthorpe
2025-10-20 23:30 ` Vipin Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aQP6-49_FeB2nNEm@google.com \
--to=dmatlack@google.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=chrisl@kernel.org \
--cc=david@redhat.com \
--cc=dwmw2@infradead.org \
--cc=epetron@amazon.de \
--cc=graf@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=jgg@ziepe.ca \
--cc=jgowans@amazon.com \
--cc=jrhilke@google.com \
--cc=junaids@google.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=parav@nvidia.com \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=saeedm@nvidia.com \
--cc=skhawaja@google.com \
--cc=vipinsh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox