Re: [PATCH v10 09/13] PCI: liveupdate: Adopt ACS controls in incoming preserved devices
From: Alex Williamson
Date: Tue Nov 17 2026 - 19:26:51 EST
On Tue, 17 Nov 2026 13:16:21 -0800
"David Matlack" <dmatlack@xxxxxxxxxx> wrote:
> On Mon Nov 16, 2026 at 5:09 PM PST, Alex Williamson wrote:
> > On Tue, 13 Oct 2026 16:25:25 +0000
> > David Matlack <dmatlack@xxxxxxxxxx> wrote:
> >> +int pci_liveupdate_adopt_acs(struct pci_dev *dev)
> >> +{
> >> + /*
> >> + * Check if the device was preserved over a previous Live Update (even
> >> + * if it has already gone through pci_liveupdate_finish()). This ensures
> >> + * that the device continues to use the ACS controls established by the
> >> + * previous kernel.
> >> + */
> >> + if (!dev->liveupdate.was_incoming)
> >> + return -EINVAL;
> >> +
> >> + /*
> >> + * The previous kernel should not have preserved any devices that
> >> + * require device-specific quirks to enable ACS, but if such a device is
> >> + * detected (e.g. new device-specific ACS quirk in the current kernel),
> >> + * log a big warning and fall back to the normal enable ACS path.
> >> + */
> >> + if (pci_need_dev_specific_enable_acs(dev)) {
> >> + pci_warn(dev, "Device-specific quirk required to enable ACS!\n");
> >> + WARN_ON_ONCE(true);
> >> + return -EINVAL;
> >> + }
> >
> > This looks pretty unsafe and the comment is only explaining how we
> > might get here, not why we shouldn't panic. IIUC, the IOMMU lho
> > support requires singleton groups, but I'm not sure what it does if a
> > group becomes non-singleton in the new kernel (such as via a new quirk).
> >
> > Is a warning related to what might be a parent bridge rather than the
> > endpoint device, really sufficient here? Thanks,
>
> It's not necessarily safe. The new quirk could change how TLPs are being
> routed while a downstream preserved device is still sending memory
> transactions.
>
> I think a better approach would be for a preserved device to always
> adopt the ACS controls left by the previous kernel, and keep them
> across resets through the ACS save state. So a new device-specific quirk
> for the device is ignored, apart from logging a warning. IOW, new ACS
> quirks only take effect on cold boot.
>
> If a preserved device has an ACS capability but no save state (i.e. the
> allocation failed), then we can panic, since its adopted controls would
> be lost by the first reset..
>
> Roughly:
>
> int pci_liveupdate_adopt_acs(struct pci_dev *dev)
> {
> if (!dev->liveupdate.was_incoming)
> return -EINVAL;
>
> if (pci_need_dev_specific_enable_acs(dev))
> pci_warn(dev, "Ignoring ACS quirk, adopting ACS controls from previous kernel\n");
>
> if (dev->acs_cap && !pci_find_saved_ext_cap(dev, PCI_EXT_CAP_ID_ACS))
> panic("%s: No ACS save state for preserved device\n",
> pci_name(dev));
>
> return 0;
> }
>
> The panic would only happen if allocating the save state fails. Ideally
> I'd like save state allocation failures to cause the whole device setup
> to fail. That's something I'm hoping to do in the future on top of the
> pci_save_state rework [1], and then we can remove this panic. Until
> then, the panic is constrained to Live Update, and the allocation
> shouldn't fail in practice.
>
> As for IOMMU groups: Sami's IOMMU Live Update series refuses to let any
> device join a group that contains a preserved device, in both the
> outgoing and incoming kernel (__iommu_probe_device() fails with -EBUSY)
> [2][3]. So if the new kernel considers the path less isolated than the
> previous kernel did, e.g. because of a new quirk, the group grows and
> the IOMMU core refuses the second device rather than putting both in
> one group. The system comes up with that device unavailable, which can
> be debugged and recovered by rebooting, instead of panicking.
>
> [1] https://lore.kernel.org/linux-pci/20261106004218.604799-1-dmatlack@xxxxxxxxxx/
> [2] https://lore.kernel.org/linux-iommu/20261110040828.1774343-6-skhawaja@xxxxxxxxxx/
> [3] https://lore.kernel.org/linux-iommu/20261110040828.1774343-13-skhawaja@xxxxxxxxxx/
>
> Does that sound reasonable?
Yes, reasonable. ACS is deterministically managed via standard
controls on the source, continue that after update, disregarding any
new quirks that have been added (to the extent that they fall within
the current framework), IOMMU enforces singleton groups on both ends to
avoid violations. I don't know how to do better than that. Thanks,
Alex