From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DEEF3B2FDA for ; Thu, 23 Apr 2026 21:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979407; cv=none; b=hTMYY0OHo1opOg3ji1Cghtpzyea9hr4GS14v5at0oxDOQD7RYxWHycoK8XxQzwne9qQtXL6M+9iKja52SM5HSO+KUauuw56TrDjRNdRu3+826WSr5omll2IMHQDZ1f5gr1mP7S4cAlNIV1AgRWjqIHZ4M2uk1OP1EPySiDWeBBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979407; c=relaxed/simple; bh=lmCH11RetuzuaSSML9d3XWPKOuj/Ox/xuKogjwWNArY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RCC8PN+xmVglGoSjQcskRIEhxfBRwhjQTk2TSRa0jxePAqS4ykK2P2Ohuzw5n1FBkrBAkjJka3og4VC2UL4qKISmtFCGjBisbFgIISuIAYHmWxp3gPy8MxVyyij529cFx175lKADjcoyEwS+9ChHk1JMQeXOIA3cBxlIdml8XXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Fuy+fWls; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Fuy+fWls" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c6e24ee93a6so4398161a12.0 for ; Thu, 23 Apr 2026 14:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979402; x=1777584202; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=gjMaEBohopo2Yfkm1Hw1N9aZDGPCAerYqbSdZNNS1LM=; b=Fuy+fWls4dtCpSL2XnbO3JFl88Kq3jXSQN5QTNaog979hA3L08Fm3+PJJ7Lcw2ptNN 4MuQ1lNnRCtm6xp8gcH9f0QY+54zScvYGEjQnOMbB1HK39OW8Wn0MNffX1AlGh/O3cfo lG9WEkavKIyCWaJK1Up+lpP2sSvdajtiYN2EEoy06kSx5KFAppcnhhg3ECkfQLsWwkFC 9jei27zHtMGoFZLTqcSLellhK/oiN4ngzIboKIBkmoM4+KrPGofw9d5uvEtTUq2pd3nl tzbbsF/WbfC4izmm496Oz25avJMtJGCkCRvh7sc0s0tDLQxh7QJsPJtQkCkKjxEaJWq/ yhqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979402; x=1777584202; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gjMaEBohopo2Yfkm1Hw1N9aZDGPCAerYqbSdZNNS1LM=; b=W0PxXzKxHPR/LIlxdxZyCaqDFdnSMcz17s/OC7viRnSF8xDuaoVlwobc6rzwD68kMA CEHGJZe/invDH6lTN1g57RMPjrcq1cHRwxGJOII7R56nqYk5ZCTFZ00vgAqh/RScmxnX 3J81jHhuxlg/6vdgqvdHFYTiKk9AL3D71je/7Os8dIVRSAkjpyIe2eeuLq4v2h1bmz0j 9OpQt3DIprhdbCbnrg3tAwUt/P+9Bur9umlVSg5dH164bvTvzIIawriiUvxn4PgMsE0Y 6lpmiAMkCHdE5kCPXVXFuGh2BwTOPo21YWZedZUEGMHpiNL735rAYGF0xO20Edg+E50n HFrA== X-Forwarded-Encrypted: i=1; AFNElJ9rkuYLR0Dgq6DwVLMBJvYoW6Jzly5OZ9vyslWqB8g61EbBPSysiSj5fKNqvnBmWkTWa5HGoQjaGvkGamw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxv7IlxcKxL0bf8LOylbl4rAcJOUFZcaLz0SAaA0UbSkVBkXev4 1gvXgeKtneh+B+2NSSwRqEyL4XGmcg5AOrz4M0Fr5uFWsTMwCb+zyweXoWlFoIKcZUKnaJIA527 fHoxvpQBtTV7Acw== X-Received: from pgge8.prod.google.com ([2002:a63:db08:0:b0:c79:6636:f4c1]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:158a:b0:3a2:c9a1:2c26 with SMTP id adf61e73a8af0-3a2c9a2b9ebmr18927671637.7.1776979401541; Thu, 23 Apr 2026 14:23:21 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:05 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-2-dmatlack@google.com> Subject: [PATCH v4 01/11] PCI: liveupdate: Set up FLB handler for the PCI core From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Set up a File-Lifecycle-Bound (FLB) handler for the PCI core to enable it to participate in the preservation of PCI devices across Live Update. Essentially, this commit enables the PCI core to allocate a struct (struct pci_ser) and preserve it across a Live Update whenever at least one device is preserved. Preserving PCI devices across Live Update is built on top of the Live Update Orchestrator's (LUO) support for file preservation. Drivers are expected to expose a file to userspace to represent a single PCI device and support preservation of that file. This is itended primarily to support preservation of PCI devices bound to VFIO drivers. This commit enables drivers to register their liveupdate_file_handler with the PCI core so that the PCI core can do its own tracking and enforcement of which devices are preserved. pci_liveupdate_register_flb(driver_file_handler); pci_liveupdate_unregister_flb(driver_file_handler); When the first file (with a handler registered with the PCI core) is preserved, the PCI core will be notified to allocate its tracking struct (pci_ser). When the last file is unpreserved (i.e. preservation cancelled) the PCI core will be notified to free struct pci_ser. This struct is preserved across a Live Update using KHO and can be fetched by the PCI core during early boot (e.g. during device enumeration) so that it knows which devices were preserved. Note that this commit only allocates struct pci_ser and preserves it across Live Update. A subsequent commit will add an API for drivers to tell the PCI core exactly which devices are being preserved. Signed-off-by: David Matlack --- MAINTAINERS | 12 ++++ drivers/pci/Kconfig | 14 ++++ drivers/pci/Makefile | 1 + drivers/pci/liveupdate.c | 139 ++++++++++++++++++++++++++++++++++++ include/linux/kho/abi/pci.h | 61 ++++++++++++++++ include/linux/pci.h | 15 ++++ 6 files changed, 242 insertions(+) create mode 100644 drivers/pci/liveupdate.c create mode 100644 include/linux/kho/abi/pci.h diff --git a/MAINTAINERS b/MAINTAINERS index c9b7b6f9828e..94af31837375 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20555,6 +20555,18 @@ L: linux-pci@vger.kernel.org S: Supported F: Documentation/PCI/pci-error-recovery.rst =20 +PCI LIVE UPDATE +M: Bjorn Helgaas +M: David Matlack +L: linux-pci@vger.kernel.org +S: Supported +Q: https://patchwork.kernel.org/project/linux-pci/list/ +B: https://bugzilla.kernel.org +C: irc://irc.oftc.net/linux-pci +T: git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git +F: drivers/pci/liveupdate.c +F: include/linux/kho/abi/pci.h + PCI MSI DRIVER FOR ALTERA MSI IP L: linux-pci@vger.kernel.org S: Orphan diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 33c88432b728..08398cbe970c 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -328,6 +328,20 @@ config VGA_ARB_MAX_GPUS Reserves space in the kernel to maintain resource locking for multiple GPUS. The overhead for each GPU is very small. =20 +config PCI_LIVEUPDATE + bool "PCI Live Update Support (EXPERIMENTAL)" + depends on PCI && LIVEUPDATE + help + Enable PCI core support for preserving PCI devices across Live + Update. This, in combination with support in a device's driver, + enables PCI devices to run and perform memory transactions + uninterrupted during a kexec for Live Update. + + This option should only be enabled by developers working on + implementing this support. + + If unsure, say N. + source "drivers/pci/hotplug/Kconfig" source "drivers/pci/controller/Kconfig" source "drivers/pci/endpoint/Kconfig" diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 41ebc3b9a518..e8d003cb6757 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_PROC_FS) +=3D proc.o obj-$(CONFIG_SYSFS) +=3D pci-sysfs.o slot.o obj-$(CONFIG_ACPI) +=3D pci-acpi.o obj-$(CONFIG_GENERIC_PCI_IOMAP) +=3D iomap.o +obj-$(CONFIG_PCI_LIVEUPDATE) +=3D liveupdate.o endif =20 obj-$(CONFIG_OF) +=3D of.o diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c new file mode 100644 index 000000000000..d4fa61625d56 --- /dev/null +++ b/drivers/pci/liveupdate.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Copyright (c) 2026, Google LLC. + * David Matlack + */ + +/** + * DOC: PCI Live Update + * + * The PCI subsystem participates in the Live Update process to enable dri= vers + * to preserve their PCI devices across kexec. + * + * .. note:: + * The support for preserving PCI devices across Live Update is current= ly + * *partial* and should be considered *experimental*. It should only be + * used by developers working on the implementation for the time being. + * + * To enable the support, enable ``CONFIG_PCI_LIVEUPDATE``. + * + * File-Lifecycle-Bound (FLB) Data + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D + * + * PCI device preservation across Live Update is built on top of the Live = Update + * Orchestrator's (LUO) support for file preservation across kexec. Drivers + * are expected to expose a file to represent a single PCI device and supp= ort + * preservation of that file with ``ioctl(LIVEUPDATE_SESSION_PRESERVE_FD)`= `. + * This allows userspace to control the preservation of devices and ensure + * proper lifecycle management while a device is preserved. The first inte= nded + * use-case is preserving vfio-pci device files. + * + * The PCI core maintains its own state about what devices are being prese= rved + * across Live Update using a feature called File-Lifecycle-Bound (FLB) da= ta in + * LUO. Essentially, this allows the PCI core to allocate struct pci_ser = when + * the first device (file) is preserved and free it when the last device (= file) + * is unpreserved. After kexec, the PCI core can fetch the struct pci_ser = (which + * was constructed by the previous kernel) from LUO at any time (e.g. duri= ng + * enumeration) so that it knows which devices were preserved. + * + * To enable the PCI core to be notified whenever a file representing a de= vice + * is preserved, drivers must register their struct liveupdate_file_handle= r with + * the PCI core by using the following APIs: + * + * * ``pci_liveupdate_register_flb(driver_file_handler)`` + * * ``pci_liveupdate_unregister_flb(driver_file_handler)`` + */ + +#define pr_fmt(fmt) "PCI: liveupdate: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int pci_flb_preserve(struct liveupdate_flb_op_args *args) +{ + struct pci_dev *dev =3D NULL; + u32 max_nr_devices =3D 0; + struct pci_ser *ser; + unsigned long size; + + /* + * Allocate enough space to preserve all of the devices that are + * currently present on the system. Extra padding can be added to this + * in the future to increase the chances that there is enough room to + * preserve devices that are not yet present on the system (e.g. VFs, + * hot-plugged devices). + */ + for_each_pci_dev(dev) + max_nr_devices++; + + size =3D struct_size_t(struct pci_ser, devices, max_nr_devices); + + pr_debug("Preserving struct pci_ser with room for %u devices\n", + max_nr_devices); + + ser =3D kho_alloc_preserve(size); + if (IS_ERR(ser)) + return PTR_ERR(ser); + + ser->max_nr_devices =3D max_nr_devices; + ser->nr_devices =3D 0; + + args->obj =3D ser; + args->data =3D virt_to_phys(ser); + return 0; +} + +static void pci_flb_unpreserve(struct liveupdate_flb_op_args *args) +{ + struct pci_ser *ser =3D args->obj; + + pr_debug("Unpreserving struct pci_ser\n"); + WARN_ON_ONCE(ser->nr_devices); + kho_unpreserve_free(ser); +} + +static int pci_flb_retrieve(struct liveupdate_flb_op_args *args) +{ + args->obj =3D phys_to_virt(args->data); + return 0; +} + +static void pci_flb_finish(struct liveupdate_flb_op_args *args) +{ + kho_restore_free(args->obj); +} + +static struct liveupdate_flb_ops pci_liveupdate_flb_ops =3D { + .preserve =3D pci_flb_preserve, + .unpreserve =3D pci_flb_unpreserve, + .retrieve =3D pci_flb_retrieve, + .finish =3D pci_flb_finish, + .owner =3D THIS_MODULE, +}; + +static struct liveupdate_flb pci_liveupdate_flb =3D { + .ops =3D &pci_liveupdate_flb_ops, + .compatible =3D PCI_LUO_FLB_COMPATIBLE, +}; + +int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh) +{ + pr_debug("Registering file handler \"%s\"\n", fh->compatible); + return liveupdate_register_flb(fh, &pci_liveupdate_flb); +} +EXPORT_SYMBOL_GPL(pci_liveupdate_register_flb); + +void pci_liveupdate_unregister_flb(struct liveupdate_file_handler *fh) +{ + pr_debug("Unregistering file handler \"%s\"\n", fh->compatible); + liveupdate_unregister_flb(fh, &pci_liveupdate_flb); +} +EXPORT_SYMBOL_GPL(pci_liveupdate_unregister_flb); diff --git a/include/linux/kho/abi/pci.h b/include/linux/kho/abi/pci.h new file mode 100644 index 000000000000..5c0e92588c00 --- /dev/null +++ b/include/linux/kho/abi/pci.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (c) 2026, Google LLC. + * David Matlack + */ + +#ifndef _LINUX_KHO_ABI_PCI_H +#define _LINUX_KHO_ABI_PCI_H + +#include +#include +#include + +/** + * DOC: PCI File-Lifecycle Bound (FLB) Live Update ABI + * + * This header defines the ABI for preserving core PCI state across kexec = using + * Live Update File-Lifecycle Bound (FLB) data. + * + * This interface is a contract. Any modification to any of the serializat= ion + * structs defined here constitutes a breaking change. Such changes require + * incrementing the version number in the PCI_LUO_FLB_COMPATIBLE string. + */ + +#define PCI_LUO_FLB_COMPATIBLE "pci-v1" + +/** + * struct pci_dev_ser - Serialized state about a single PCI device. + * + * @domain: The device's PCI domain number (segment). + * @bdf: The device's PCI bus, device, and function number. + * @reserved: Reserved (to naturally align struct pci_dev_ser). + */ +struct pci_dev_ser { + u32 domain; + u16 bdf; + u16 reserved; +} __packed; + +/** + * struct pci_ser - PCI Subsystem Live Update State + * + * This struct tracks state about all devices that are being preserved acr= oss + * a Live Update for the next kernel. + * + * @max_nr_devices: The length of the devices[] flexible array. + * @nr_devices: The number of devices that were preserved. + * @devices: Flexible array of pci_dev_ser structs for each device. + */ +struct pci_ser { + u32 max_nr_devices; + u32 nr_devices; + struct pci_dev_ser devices[]; +} __packed; + +/* Ensure all elements of devices[] are naturally aligned. */ +static_assert(offsetof(struct pci_ser, devices) % sizeof(unsigned long) = =3D=3D 0); +static_assert(sizeof(struct pci_dev_ser) % sizeof(unsigned long) =3D=3D 0); + +#endif /* _LINUX_KHO_ABI_PCI_H */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 2c4454583c11..d70080babd52 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -40,6 +40,7 @@ #include #include #include +#include =20 #include =20 @@ -2876,4 +2877,18 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_= ers_result err_type); WARN_ONCE(condition, "%s %s: " fmt, \ dev_driver_string(&(pdev)->dev), pci_name(pdev), ##arg) =20 +#ifdef CONFIG_PCI_LIVEUPDATE +int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh); +void pci_liveupdate_unregister_flb(struct liveupdate_file_handler *fh); +#else +static inline int pci_liveupdate_register_flb(struct liveupdate_file_handl= er *fh) +{ + return -EOPNOTSUPP; +} + +static inline void pci_liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh) +{ +} +#endif + #endif /* LINUX_PCI_H */ --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C31483BE624 for ; Thu, 23 Apr 2026 21:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979408; cv=none; b=nt3T/GUHqHWaGnRiUlBydvXSujZauZ6av/yojNtRw1QOLzbjcrMxcLQo+syF13M294fhlgxCh6s3WS9vz8fUwooO42rwkQezH+U2T5Dudpd5tJXYYCccnNV5AR+dASC28XmLZbGz/3VYVtz6EZPJin0RdES83drSNUbIEVztyS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979408; c=relaxed/simple; bh=wvsl+lqCx3435FNXLJ3KqBDnB6oUV04ymFGLbModbqM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Eel3tu7mrOKWvprobHSHUc7gR11FXCAD/q6tFvKrHMcJNMoPYPD5aModIr61rKZii8MDxOMoDki/mXstURcv88mXXyazXYeY9KEFolquPcO0W2PpVDE/3m1e6WF8Agfy0wtDBgbMi9eRY50Z/4/3xE4X1T6SHaN/sg76tGsS9so= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZXw1eTm1; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZXw1eTm1" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b258636d16so71717925ad.2 for ; Thu, 23 Apr 2026 14:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979403; x=1777584203; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=LW56WQ/GxI9kfbfGRUP82x0Orz5k50krThArcWSM6yc=; b=ZXw1eTm1GkaSUJBpbeGOgR1rZBpPCCkIVCDrclpF6t26EmHwoJvyeOcm0aPN59CRtd WmqKhLD8ZGBCx2PSAPOrVXLSo6D26/VXcW8/iNOmuyk5/12Jvc9ntaeEJnSLjPV6lw7s CjEHNPdws/jhhgE9CSRkS5xOA1EU1Y6FlqCjly5wsO/Hbn7ff/+1ZQ+QWLqsVqrXHxmJ f4AeRP8AHjcJ6vAW23FRHyP270+MHrlrVfSjlUWRpsZhmqFeQgKWslIw4XzVwScUqnDw enAKqFyyCykwQCm5uwS5A9y+RijlUbVKPW/bGYphbTcnikkMwzgLbsQgVPYi4IwhALfd NSIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979403; x=1777584203; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LW56WQ/GxI9kfbfGRUP82x0Orz5k50krThArcWSM6yc=; b=kRZ7umBRwM0F16dWLZU5vQfo4kBSgCe8Kgzoh/uBZ9Nz2LYFj/BSkIhH3OdZuFkOPx LYCOMZC5BdHdYEQQDfgUm1lbh6EmQkS78barQdz3fsB8jRuVk1HSpI78XaDTN7uCB3PK 4N6swBvEIGc0fypRxg8AXiPHOrJ7GTGoATe27PyXvyuPz793KICTmjganZgE4jFibIuT aFy/jMXODi5GpiBjS8eY72IeoySFgKg2LpF5bGVjUhLC+xSrNpeTKSja5Piqt8po4YeJ dQbkoThze9OqpcImaNhqEkiEt/jtI355ieaYVGAUbNFLbH544iVC54us2CEZzhCx8EdJ ZecA== X-Forwarded-Encrypted: i=1; AFNElJ8e5Q70xRM1UgCLIhj7OiBAbKdsmSF4J5wfkgyNirNJ5so8WIXSJoDBjIN4oppJ1gXTCC6SNOAfrAWwA50=@vger.kernel.org X-Gm-Message-State: AOJu0YyIvxUGHvRBrgwgOoQJ14Ilf3iF2PnZrNEJvMU7Y00l2pBml5wI 9KR0fK6SSxIOQTF6FHZzJauOFXCL/6Pr1NjhE05OLWYLK6FY4iqhRINLfB4kU22ODkC1SvoB2iC iPnbno0LR8x5fcA== X-Received: from plai2.prod.google.com ([2002:a17:902:c942:b0:2b3:2649:c9c1]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:930b:b0:2b2:67ca:5fff with SMTP id d9443c01a7336-2b5f9fd24b7mr208541215ad.28.1776979403289; Thu, 23 Apr 2026 14:23:23 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:06 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-3-dmatlack@google.com> Subject: [PATCH v4 02/11] PCI: liveupdate: Track outgoing preserved PCI devices From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add APIs to allow drivers to notify the PCI core of which devices are being preserved across a Live Update for the next kernel, i.e. "outgoing" devices. Drivers must notify the PCI core when devices are preserved so that the PCI core can update its FLB data (struct pci_ser) and track the list of outgoing devices. pci_liveupdate_preserve() notifies the PCI core that a device must be preserved across Live Update. pci_liveupdate_unpreserve() reverses this (cancels the preservation of the device). This tracking ensures the PCI core is fully aware of which devices may need special handling during shutdown and kexec, and so that it can be handed off to the next kernel. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 101 ++++++++++++++++++++++++++++++++++++ include/linux/kho/abi/pci.h | 7 +-- include/linux/pci.h | 26 ++++++++++ 3 files changed, 131 insertions(+), 3 deletions(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index d4fa61625d56..2dd8daa2f17c 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -43,6 +43,26 @@ * * * ``pci_liveupdate_register_flb(driver_file_handler)`` * * ``pci_liveupdate_unregister_flb(driver_file_handler)`` + * + * Device Tracking + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * Drivers must notify the PCI core when specific devices are preserved or + * unpreserved with the following APIs: + * + * * ``pci_liveupdate_preserve(pci_dev)`` + * * ``pci_liveupdate_unpreserve(pci_dev)`` + * + * This allows the PCI core to keep it's FLB data (struct pci_ser) up to d= ate + * with the list of **outgoing** preserved devices for the next kernel. + * + * Restrictions + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * The PCI core enforces the following restrictions on which devices can be + * preserved. These may be relaxed in the future: + * + * * The device cannot be a Virtual Function (VF). */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt @@ -57,6 +77,8 @@ #include #include =20 +static DEFINE_MUTEX(pci_flb_outgoing_lock); + static int pci_flb_preserve(struct liveupdate_flb_op_args *args) { struct pci_dev *dev =3D NULL; @@ -124,6 +146,85 @@ static struct liveupdate_flb pci_liveupdate_flb =3D { .compatible =3D PCI_LUO_FLB_COMPATIBLE, }; =20 +int pci_liveupdate_preserve(struct pci_dev *dev) +{ + struct pci_ser *ser; + int i, ret; + + guard(mutex)(&pci_flb_outgoing_lock); + + ret =3D liveupdate_flb_get_outgoing(&pci_liveupdate_flb, (void **)&ser); + if (ret) + return ret; + + if (!ser) + return -ENOENT; + + if (dev->is_virtfn) + return -EINVAL; + + if (dev->liveupdate_outgoing) + return -EBUSY; + + if (ser->nr_devices =3D=3D ser->max_nr_devices) + return -ENOSPC; + + for (i =3D 0; i < ser->max_nr_devices; i++) { + /* + * Start searching at index ser->nr_devices. This should result + * in a constant time search under expected conditions (devices + * are not getting unpreserved). + */ + int index =3D (ser->nr_devices + i) % ser->max_nr_devices; + struct pci_dev_ser *dev_ser =3D &ser->devices[index]; + + if (dev_ser->refcount) + continue; + + pci_info(dev, "Device will be preserved across next Live Update\n"); + ser->nr_devices++; + + dev_ser->domain =3D pci_domain_nr(dev->bus); + dev_ser->bdf =3D pci_dev_id(dev); + dev_ser->refcount =3D 1; + + dev->liveupdate_outgoing =3D dev_ser; + return 0; + } + + return -ENOSPC; +} +EXPORT_SYMBOL_GPL(pci_liveupdate_preserve); + +void pci_liveupdate_unpreserve(struct pci_dev *dev) +{ + struct pci_dev_ser *dev_ser; + struct pci_ser *ser =3D NULL; + int ret; + + guard(mutex)(&pci_flb_outgoing_lock); + + ret =3D liveupdate_flb_get_outgoing(&pci_liveupdate_flb, (void **)&ser); + + if (ret || !ser) { + pci_warn(dev, "Cannot unpreserve device without outgoing Live Update sta= te\n"); + return; + + } + + dev_ser =3D dev->liveupdate_outgoing; + if (!dev_ser) { + pci_warn(dev, "Cannot unpreserve device that is not preserved\n"); + return; + } + + pci_info(dev, "Device will no longer be preserved across next Live Update= \n"); + ser->nr_devices--; + memset(dev_ser, 0, sizeof(*dev_ser)); + dev->liveupdate_outgoing =3D NULL; +} +EXPORT_SYMBOL_GPL(pci_liveupdate_unpreserve); + int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh) { pr_debug("Registering file handler \"%s\"\n", fh->compatible); diff --git a/include/linux/kho/abi/pci.h b/include/linux/kho/abi/pci.h index 5c0e92588c00..5b4c8d9e462c 100644 --- a/include/linux/kho/abi/pci.h +++ b/include/linux/kho/abi/pci.h @@ -23,19 +23,20 @@ * incrementing the version number in the PCI_LUO_FLB_COMPATIBLE string. */ =20 -#define PCI_LUO_FLB_COMPATIBLE "pci-v1" +#define PCI_LUO_FLB_COMPATIBLE "pci-v2" =20 /** * struct pci_dev_ser - Serialized state about a single PCI device. * * @domain: The device's PCI domain number (segment). * @bdf: The device's PCI bus, device, and function number. - * @reserved: Reserved (to naturally align struct pci_dev_ser). + * @refcount: Reference count used by the PCI core to keep track of whethe= r it + * is done using a device's struct pci_dev_ser. */ struct pci_dev_ser { u32 domain; u16 bdf; - u16 reserved; + u16 refcount; } __packed; =20 /** diff --git a/include/linux/pci.h b/include/linux/pci.h index d70080babd52..eb94cbd8ab9d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -41,6 +41,7 @@ #include #include #include +#include =20 #include =20 @@ -594,6 +595,9 @@ struct pci_dev { u8 tph_mode; /* TPH mode */ u8 tph_req_type; /* TPH requester type */ #endif +#ifdef CONFIG_PCI_LIVEUPDATE + struct pci_dev_ser *liveupdate_outgoing; /* State preserved for next kern= el */ +#endif }; =20 static inline struct pci_dev *pci_physfn(struct pci_dev *dev) @@ -2880,6 +2884,14 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_= ers_result err_type); #ifdef CONFIG_PCI_LIVEUPDATE int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh); void pci_liveupdate_unregister_flb(struct liveupdate_file_handler *fh); + +int pci_liveupdate_preserve(struct pci_dev *dev); +void pci_liveupdate_unpreserve(struct pci_dev *dev); + +static inline struct pci_dev_ser *pci_liveupdate_outgoing(struct pci_dev *= dev) +{ + return dev->liveupdate_outgoing; +} #else static inline int pci_liveupdate_register_flb(struct liveupdate_file_handl= er *fh) { @@ -2889,6 +2901,20 @@ static inline int pci_liveupdate_register_flb(struct= liveupdate_file_handler *fh static inline void pci_liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh) { } + +static inline int pci_liveupdate_preserve(struct pci_dev *dev) +{ + return -EOPNOTSUPP; +} + +static inline void pci_liveupdate_unpreserve(struct pci_dev *dev) +{ +} + +static inline struct pci_dev_ser *pci_liveupdate_outgoing(struct pci_dev *= dev) +{ + return NULL; +} #endif =20 #endif /* LINUX_PCI_H */ --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E5143BF689 for ; Thu, 23 Apr 2026 21:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979412; cv=none; b=XT0WWh26hRRKIWYjALpLKhWVv068o7mi+uJxh+GHZ/qt1YaAvJ9V9VZd0ccGxcuNjIMsfniP10USNuMEzkQYjoMVR6IF/hMwLLViDxwO8Y5rIfn+hV/0GR6koPUwYxa2WHElCZFPX9yz5CNYAoKziXmh6o5YUbDw1E9YATIL/7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979412; c=relaxed/simple; bh=70RKSMZjgbP0ktOPb9PAca2L/0fqqjCC+IMmxSG4xU0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=a2OdA3plF8CzstcS6mNZxJPWAG+kqlxRYU6iw3ggwdSkFU96WognCunTuFYF0M2yglzzCbYIact2wrRopOkhvDHdEIDZ7ZtKMbkAHcEyuBFx1O781rLzebLCoVSks8r3bIViJwX2X/vZODf/eiXR3fp7sY3mpKRkZBvcd5S1VHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=k55Wmyda; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="k55Wmyda" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-82fbceb0181so3707373b3a.3 for ; Thu, 23 Apr 2026 14:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979405; x=1777584205; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZmpZCS6mKPYD/A8Ingq/lQA2gApCpbjA3a6IaVe9Pqc=; b=k55WmydafbrWSfuPS88BcRtlnZgnNe4/EFqlmRjFkprYzxrbJTyws+sdBdnQxdjEu/ RgIUMXa07dOsuGKnGLfuH/vPKEXWcOSouydoDZcWGh4AiAghOmjPhE5dXtWJwzvvIUEU PqB5Gyy9szf7gOuDKAxXS9EHxv6hcQnTGm8niDcxxhcdQAqM3SFAr+2LgydV4O3hOCWf eoULVmYRFChvKSYJR6feJMB9qg8K7DFXIgQlcUk53XWMAkJHhp3B0585X+05rwuXiBc5 xv744R30TiGSxEKAiNlNWD0Opt9+s/X/OVYHJs/rkhxxPIi+SWn9r/PRCyJc/aTR8gOB 73PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979405; x=1777584205; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZmpZCS6mKPYD/A8Ingq/lQA2gApCpbjA3a6IaVe9Pqc=; b=bDhuzjsKuozP1h65GY6mM29iBcUa02sGbzj3/pvWtOF3ypvbeL0kh7BGkgotrF8vGn 99NCdd4KwBQ2JdzulD2OzghRFKO6m/33yged88FWsKC1plxJ9bIpfq1ynlVu+Xs0wh+D jn/w1vwzDutBdnxBVfXHKvmDQQOTcLCpKhqnVabTZHLcogkMxN7qY+vWUQiFUr7uCd9U 0yZPPUoYEavJ72YCp2Sh5/vUYy/K1f1YjmTuPaE4lxcAQchc+pYtMSlz5Y2FNAkaPt8U DaAC1Zny3eYx3/SMVKbMxovEbMQxvVsgHvcuX59DClrKkV1yQWnJAH3oF0HUUsyy8s8l 7dHQ== X-Forwarded-Encrypted: i=1; AFNElJ/kUBF4UAfB5ylEeEM+6h2/6lXdYgnI/YKKjF7iCL10pC/vSVonD+RRSZDdFWMtxZf1rTN4CrPsp/+oBY8=@vger.kernel.org X-Gm-Message-State: AOJu0YxyEakw9yvwK10Yd+XmU7HJ9j38A6WxjbOgvCOiHiAwynlfCscs 2fXAOXTTbJdMsGZmTP0eGH27JhRmsABg7YXpRVyE9Yqi4JCBZQJcs2QsGmRlvxJNYKrZY1eEGBL QIZM54cfoNmChog== X-Received: from pfav10.prod.google.com ([2002:a05:6a00:ab0a:b0:82f:805:b62a]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1993:b0:82c:2241:ab71 with SMTP id d2e1a72fcca58-82f8c9718c5mr31412431b3a.42.1776979405031; Thu, 23 Apr 2026 14:23:25 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:07 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-4-dmatlack@google.com> Subject: [PATCH v4 03/11] PCI: liveupdate: Track incoming preserved PCI devices From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" During PCI enumeration, the previous kernel might have passed state about devices that were preserved across kexec. The PCI core needs to fetch this state to identify which devices are "incoming" and require special handling. Add pci_liveupdate_setup_device() which is called during device setup to fetch the serialized state (struct pci_ser) from the Live Update Orchestrator. The first time this happens, pci_flb_retrieve() will run and convert the array of pci_dev_ser structs into an xarray so that it can be looked up efficiently. If a device is found in the xarray, the PCI core stores a pointer to its state in dev->liveupdate_incoming and holds a reference to the incoming FLB until pci_liveupdate_finish() is called by the driver. This ensures proper lifecycle management for incoming preserved devices and allows the PCI core and drivers to apply specific Live Update logic to them in subsequent commits. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 189 ++++++++++++++++++++++++++++++++++++++- drivers/pci/pci.h | 13 +++ drivers/pci/probe.c | 4 + include/linux/pci.h | 16 ++++ 4 files changed, 218 insertions(+), 4 deletions(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index 2dd8daa2f17c..e616cecc37c8 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -56,6 +56,20 @@ * This allows the PCI core to keep it's FLB data (struct pci_ser) up to d= ate * with the list of **outgoing** preserved devices for the next kernel. * + * After kexec, whenever a device is enumerated, the PCI core will check i= f it + * is an **incoming** preserved device (i.e. preserved by the previous ker= nel) + * by checking the incoming FLB data (struct pci_ser). + * + * Drivers must notify the PCI core when an **incoming** device is done + * participating in the incoming Live Update with the following API: + * + * * ``pci_liveupdate_finish(pci_dev)`` + * + * The PCI core does not enforce any ordering of ``pci_liveupdate_finish()= `` and + * ``pci_liveupdate_preserve()``. i.e. A PCI device can be **outgoing** + * (preserved for next kernel) and **incoming** (preserved by previous ker= nel) + * at the same time. + * * Restrictions * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * @@ -67,7 +81,6 @@ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt =20 -#include #include #include #include @@ -75,10 +88,24 @@ #include #include #include -#include + +#include "pci.h" =20 static DEFINE_MUTEX(pci_flb_outgoing_lock); =20 +struct pci_flb_incoming { + /* The pci_ser struct passed by the previous kernel. */ + struct pci_ser *ser; + + /* xarray used to quickly find a device in ser->devices[] */ + struct xarray xa; +}; + +static unsigned long pci_ser_xa_key(unsigned long domain, unsigned long bd= f) +{ + return domain << 16 | bdf; +} + static int pci_flb_preserve(struct liveupdate_flb_op_args *args) { struct pci_dev *dev =3D NULL; @@ -124,13 +151,44 @@ static void pci_flb_unpreserve(struct liveupdate_flb_= op_args *args) =20 static int pci_flb_retrieve(struct liveupdate_flb_op_args *args) { - args->obj =3D phys_to_virt(args->data); + struct pci_flb_incoming *incoming; + int i, ret; + + incoming =3D kmalloc(sizeof(*incoming), GFP_KERNEL); + if (!incoming) + return -ENOMEM; + + incoming->ser =3D phys_to_virt(args->data); + + xa_init(&incoming->xa); + + for (i =3D 0; i < incoming->ser->max_nr_devices; i++) { + struct pci_dev_ser *dev_ser =3D &incoming->ser->devices[i]; + unsigned long key; + + if (!dev_ser->refcount) + continue; + + key =3D pci_ser_xa_key(dev_ser->domain, dev_ser->bdf); + ret =3D xa_err(xa_store(&incoming->xa, key, dev_ser, GFP_KERNEL)); + if (ret) { + xa_destroy(&incoming->xa); + kfree(incoming); + return ret; + } + } + + args->obj =3D incoming; return 0; } =20 static void pci_flb_finish(struct liveupdate_flb_op_args *args) { - kho_restore_free(args->obj); + struct pci_flb_incoming *incoming =3D args->obj; + + xa_destroy(&incoming->xa); + kho_restore_free(incoming->ser); + kfree(incoming); } =20 static struct liveupdate_flb_ops pci_liveupdate_flb_ops =3D { @@ -225,6 +283,129 @@ void pci_liveupdate_unpreserve(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_liveupdate_unpreserve); =20 +static struct xarray *pci_liveupdate_flb_get_incoming(void) +{ + struct pci_flb_incoming *incoming; + int ret; + + ret =3D liveupdate_flb_get_incoming(&pci_liveupdate_flb, (void **)&incomi= ng); + + /* Live Update is not enabled. */ + if (ret =3D=3D -EOPNOTSUPP) + return NULL; + + /* Live Update is enabled, but there is no incoming FLB data. */ + if (ret =3D=3D -ENODATA) + return NULL; + + /* + * Live Update is enabled and there is incoming FLB data, but none of it + * matches pci_liveupdate_flb.compatible. + * + * This could mean that no PCI FLB data was passed by the previous + * kernel, but it could also mean the previous kernel used a different + * compatibility string (i.e. a different ABI). + */ + if (ret =3D=3D -ENOENT) { + pr_info_once("No incoming FLB matched %s\n", pci_liveupdate_flb.compatib= le); + return NULL; + } + + /* + * There is incoming FLB data that matches pci_liveupdate_flb.compatible + * but it cannot be retrieved. + */ + if (ret) { + WARN_ONCE(ret, "Failed to retrieve incoming FLB data\n"); + return NULL; + } + + return &incoming->xa; +} + +static void pci_liveupdate_flb_put_incoming(void) +{ + liveupdate_flb_put_incoming(&pci_liveupdate_flb); +} + +void pci_liveupdate_setup_device(struct pci_dev *dev) +{ + struct pci_dev_ser *dev_ser; + struct xarray *xa; + unsigned long key; + + xa =3D pci_liveupdate_flb_get_incoming(); + if (!xa) + return; + + key =3D pci_ser_xa_key(pci_domain_nr(dev->bus), pci_dev_id(dev)); + dev_ser =3D xa_load(xa, key); + + /* This device was not preserved across Live Update */ + if (!dev_ser) { + pci_liveupdate_flb_put_incoming(); + return; + } + + /* + * This device was preserved, but has already been probed and gone + * through pci_liveupdate_finish(). This can happen if PCI core probes + * the same device multiple times, e.g. due to hotplug. + */ + if (!dev_ser->refcount) { + pci_liveupdate_flb_put_incoming(); + return; + } + + pci_info(dev, "Device was preserved by previous kernel across Live Update= \n"); + + /* + * Hold the ref on the incoming FLB until pci_liveupdate_finish() so + * that dev_ser does not get freed while it is in use. + */ + dev->liveupdate_incoming =3D dev_ser; +} + +void pci_liveupdate_cleanup_device(struct pci_dev *dev) +{ + /* + * Drop the FLB reference acquired in pci_liveupdate_setup_device() if + * the device is being cleaned up before pci_liveupdate_finish(), e.g. + * due to allocation failure during setup. + * + * Do not drop dev->liveupdate_incoming->refcount since this device has + * not gone through pci_liveupdate_finish() and thus is still an + * incoming preserved device. + * + * Note: This cannot race with pci_liveupdate_finish() since it is only + * called in cleanup paths when there are no users of the pci_dev. + */ + if (dev->liveupdate_incoming) + pci_liveupdate_flb_put_incoming(); +} + +void pci_liveupdate_finish(struct pci_dev *dev) +{ + if (!dev->liveupdate_incoming) { + pci_warn(dev, "Cannot finish preserving an unpreserved device\n"); + return; + } + + pci_info(dev, "Device is finished participating in Live Update\n"); + + /* + * Drop the refcount so this device does not get treated as an incoming + * device again, e.g. in case pci_liveupdate_setup_device() gets called + * again becase the device is hot-plugged. + */ + dev->liveupdate_incoming->refcount =3D 0; + dev->liveupdate_incoming =3D NULL; + + /* Drop this device's reference on the incoming FLB. */ + pci_liveupdate_flb_put_incoming(); +} +EXPORT_SYMBOL_GPL(pci_liveupdate_finish); + int pci_liveupdate_register_flb(struct liveupdate_file_handler *fh) { pr_debug("Registering file handler \"%s\"\n", fh->compatible); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 4a14f88e543a..09bab39738d7 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1439,4 +1439,17 @@ static inline int pci_msix_write_tph_tag(struct pci_= dev *pdev, unsigned int inde (PCI_CONF1_ADDRESS(bus, dev, func, reg) | \ PCI_CONF1_EXT_REG(reg)) =20 +#ifdef CONFIG_PCI_LIVEUPDATE +void pci_liveupdate_setup_device(struct pci_dev *dev); +void pci_liveupdate_cleanup_device(struct pci_dev *dev); +#else +static inline void pci_liveupdate_setup_device(struct pci_dev *dev) +{ +} + +static inline void pci_liveupdate_cleanup_device(struct pci_dev *dev) +{ +} +#endif + #endif /* DRIVERS_PCI_H */ diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b63cd0c310bc..938a28e4a7a0 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2069,6 +2069,8 @@ int pci_setup_device(struct pci_dev *dev) if (pci_early_dump) early_dump_pci_device(dev); =20 + pci_liveupdate_setup_device(dev); + /* Need to have dev->class ready */ dev->cfg_size =3D pci_cfg_space_size(dev); =20 @@ -2192,6 +2194,7 @@ int pci_setup_device(struct pci_dev *dev) default: /* unknown header */ pci_err(dev, "unknown header type %02x, ignoring device\n", dev->hdr_type); + pci_liveupdate_cleanup_device(dev); pci_release_of_node(dev); return -EIO; =20 @@ -2490,6 +2493,7 @@ static void pci_release_dev(struct device *dev) =20 pci_dev =3D to_pci_dev(dev); pci_release_capabilities(pci_dev); + pci_liveupdate_cleanup_device(pci_dev); pci_release_of_node(pci_dev); pcibios_release_device(pci_dev); pci_bus_put(pci_dev->bus); diff --git a/include/linux/pci.h b/include/linux/pci.h index eb94cbd8ab9d..dd6b26ca9462 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -597,6 +597,7 @@ struct pci_dev { #endif #ifdef CONFIG_PCI_LIVEUPDATE struct pci_dev_ser *liveupdate_outgoing; /* State preserved for next kern= el */ + struct pci_dev_ser *liveupdate_incoming; /* State preserved by previous k= ernel */ #endif }; =20 @@ -2887,11 +2888,17 @@ void pci_liveupdate_unregister_flb(struct liveupdat= e_file_handler *fh); =20 int pci_liveupdate_preserve(struct pci_dev *dev); void pci_liveupdate_unpreserve(struct pci_dev *dev); +void pci_liveupdate_finish(struct pci_dev *dev); =20 static inline struct pci_dev_ser *pci_liveupdate_outgoing(struct pci_dev *= dev) { return dev->liveupdate_outgoing; } + +static inline struct pci_dev_ser *pci_liveupdate_incoming(struct pci_dev *= dev) +{ + return dev->liveupdate_incoming; +} #else static inline int pci_liveupdate_register_flb(struct liveupdate_file_handl= er *fh) { @@ -2911,10 +2918,19 @@ static inline void pci_liveupdate_unpreserve(struct= pci_dev *dev) { } =20 +static inline void pci_liveupdate_finish(struct pci_dev *dev) +{ +} + static inline struct pci_dev_ser *pci_liveupdate_outgoing(struct pci_dev *= dev) { return NULL; } + +static inline struct pci_dev_ser *pci_liveupdate_incoming(struct pci_dev *= dev) +{ + return NULL; +} #endif =20 #endif /* LINUX_PCI_H */ --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD78A3BFE25 for ; Thu, 23 Apr 2026 21:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979412; cv=none; b=Rz75OCQsJn3f9be4jFeud4uxML8GsNDpSbcsAYAURQFtIOKaFIRCJFU9UY0k0XD5oiVb416qQNX8D1WSx6M1EC5NWKGH4+0VoEnBr3CoTx9M+BKCAoWnvZT8JYpiC3Yo20/k0ukugql0yg7r4xLtkwyq7adjQamecwNYT9sNCFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979412; c=relaxed/simple; bh=dE5Wu3i/3oTCNIY4DxPIO1WQs74yLAprf78sku84Hgk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YRRv15oNTjlY4NXXxh3elWsfw92s0PH8TlWG+33Kaa4I0US9kUFeCzSvd0f5VaIdLXIlHSy5v0RhE14ebo/DwAfAqkOMbexrUlZtITCXnH3h/i2ZeGCbOP4iMgdeHe3dfAESgLVsNdTMirYHQ2cQtx4bA05P4csxhopBSsP++n8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UpCaZjJy; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UpCaZjJy" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-c70ea91bfe1so3530560a12.1 for ; Thu, 23 Apr 2026 14:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979407; x=1777584207; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cA/8iRDD7lhVYHGAuqnc3aBzPoZ7lUU2DgL4E3vJPEc=; b=UpCaZjJyglexDgqkb/6vhHNODNhfFff4wOY7JRTtVdk30fxK+tz5WI3aAmJfHms8lj qcx8taL6eEz2wgUHxlTKGm05dinaGUQ5hrTwWaXSfRpacdrCM6bBvbAUfsv/2T2IoJlA 4/aUxDgEDaA2fDUeJdUmv2lRowKRUDwLirJN8II8XBEyI0Rxhc0poz6ktLDomsLLgcil GQfoKNfCBuj5J9R/XsgkUpP0+MM9XjoCB47zmY0iM8xAA/EDF1SyOyYM/0Vs2RwC6NIH cNsIZNjEUzmsx+Q4ZQRgvpNp+aiDwNCwqfXir3pdDjRuk01Hur6FPePl/vpQEzC+tBsU n2PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979407; x=1777584207; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cA/8iRDD7lhVYHGAuqnc3aBzPoZ7lUU2DgL4E3vJPEc=; b=HV0xTYu/3+9mPVBIWBO9nhsC9I/Tb4/1Za5iVc2yEMdxtP+MzI1o6eQoaxrXFWlOPH U+bQTJOOQLmdl7wr9kgxuF5ZFM+vRs7k7RAXKykx+mTfL+w83uEL3ZOStM+lp1i9ZZhG MYmEqJCMpD77gHwsLw578wgc3WwCiYZONH+FSl6JUk5lO3Gqow/OWToqhJmBowHTgpDB pyY9AjHTOUtMAtjO/+LmqfjhQ0KXGY8yZsCvQt2W1YmtWTCRPiIaE0N9jJVDdFpqy0fc /nWhx7LuSJmszzPkW43SdpzqjpqNMslHdViR8IJskpBq0LTBhCcQmt014j3XUbkSe3T0 pOTA== X-Forwarded-Encrypted: i=1; AFNElJ/9SvB62mibWFRWlhZiZmIv2bzk4KJbQm8RWj/cJvT4zP9tFR9gh1a3aEo1XF1X0C46jEeZuosE47JE7cY=@vger.kernel.org X-Gm-Message-State: AOJu0YyDTlbkKwxqKUsbKlJneKAPFunYkE6rB6lbI3ESRTquRz+dRzFt BEJqjWdYU3iCnu+sOnhekwWRjSU4DhletLgVxHb4fWoDU5JpbYg8faNN+BQntSRCxchCACZ3R3e 7kGm3i311JFIxnw== X-Received: from pgjm19.prod.google.com ([2002:a63:fd53:0:b0:c79:7f30:5d18]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3399:b0:398:7982:21df with SMTP id adf61e73a8af0-3a08d687673mr31625673637.9.1776979406884; Thu, 23 Apr 2026 14:23:26 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:08 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-5-dmatlack@google.com> Subject: [PATCH v4 04/11] PCI: liveupdate: Document driver binding responsibilities From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document how driver binding works during a Live Update and what the PCI core expects of drivers and users. Note that this is only a description of the current division of responsibilities. These can change in the future if we decide. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index e616cecc37c8..c0a30d16d9b8 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -77,6 +77,22 @@ * preserved. These may be relaxed in the future: * * * The device cannot be a Virtual Function (VF). + * + * Driver Binding + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * In the outgoing kernel, it is the driver's responsibility to ensure tha= t it + * does not release a device between pci_liveupdate_preserve() and + * pci_liveupdate_unpreserve(). + * + * In the incoming kernel, it is the driver's responsibility to ensure tha= t it + * does not release a preserved device between probe() and + * pci_liveupdate_finish(). + * + * It is the user's responsibility to ensure that incoming preserved devic= es are + * bound to the correct driver. i.e. The PCI core does not protect against= a + * device getting preserved by driver A in the outgoing kernel and then ge= tting + * bound to driver B in the incoming kernel. */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBA583BFE5C for ; Thu, 23 Apr 2026 21:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979415; cv=none; b=Mo2II8QzQhjiFOXpSWDexXx4rEqEL1msXYEDmPysvKKmpRc37HV+PjCKSAt/qTSnwBwVqk9zn/vARm3q0nfKwBTnMGOh95vS/09s5YOOyrYC8/1Vj8Tf1U10IacKQX4mhMgL7Rpf8pt1CzTCQ5273JVDPFN7/OlWUp4EGcmI8Ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979415; c=relaxed/simple; bh=7EFFL8rzwwkNs2VFh7UxqjTSTsZEbT6FDog+Mkn6Mnc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NQ/VZLk2H2v7JGYy90tO5fJXsn1uTKpGn2qv7uUKNCEHRSb7KS++wHWroJ6y7T50mHEcXBPytCkzySB3suoffuDu+EiRLn4IvvkNeyL6CEfNy4jBTOZJuq8Otrc+ReZ5kRQkK5gamH6v9iC02785/KJwfsKfantc1Oa3Iv8saeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Sq2TNcpG; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sq2TNcpG" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-354bc535546so7237030a91.3 for ; Thu, 23 Apr 2026 14:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979409; x=1777584209; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=hfzU9SNjvxnnqDKncwfyemtEYZFu8CMxXPZg5kqrMR0=; b=Sq2TNcpGCGiGCFgdGA72+Q/PWdzrkQ6vC1dD7Tv+NEMfhQdJW0cqAXNNBOkIdUp08/ IucsfPwVoSFCb9VSQKxRz1+1G7zMFK0CLc1+fIOJnfyv9hfpU7eK4StvFM7HGQRiA3pB /z84SiYjOh0ejQaGspmV/wAuSGLJwpt6tJVE6Ztd0JmCFUjQGLt3wQPIQ0Al3dNRrou6 DKRxCBQrn2xnNUkIvLWZmNUy3crfqRKIO/HyB8kh6nVf7zjq4mLbrWLZFjpziTUv/pof D2Pc5wQLOexIWr9ma1wcqINFSk2US7xqqye7kq+D0rWYNqsOhj5gnCK20Sk8duPAYAqT KARA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979409; x=1777584209; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hfzU9SNjvxnnqDKncwfyemtEYZFu8CMxXPZg5kqrMR0=; b=UadZ04QM9927iL5Xybq6i+ySjM8pTqEzNN9Nd8yLE27Kr9ZTPI3gsdolPO3E7kXVKX 1ctEMrfXftMYZMo8+7T8J6UQxMdcedzIOMcmsHWSDF+NkkeiV55stEOXGRYRHQOEiZBk /BobQs881vaFsAUKhaX3tccfqJqdjAfbL9xI5nIMu6IaSS855Hztz2+W6JMdtSaJCWyb KEPbails+zObGn+ttfWjjPF8Yqvvrnt5eYxZoYQKo1trEijAAfwVfBdexoPropgF/K3G 3Ha5ROBzkAF66u7FBIBeskNob7iqpUA8kDPFL5Ei9+VT7PdpW8Eh/Rm+p+P9lQBpR8dm ZE5g== X-Forwarded-Encrypted: i=1; AFNElJ+MdNpg+Cuklt9RYn6jYTR5/8iZTT1auwaQcZtRcncBqRnCpiaSCR5AaMp2uSvfgaYbihqz5515Xe15MPk=@vger.kernel.org X-Gm-Message-State: AOJu0YyMHIa3ufSLUl5w0MnQwk/jYzDsdEbv+T0jDHEk0ZC30Z1QHV1f nw9ex/05uhX/bf1xYpTLwkTjtBDdTkocopC+DLGsyT8DblDT5/0zVpMIQIcZwmlYTmCndFjySbM ONz81EHsbVVi78A== X-Received: from pgbcw1.prod.google.com ([2002:a05:6a02:4281:b0:c76:8acb:773d]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6d9c:b0:3a3:17f8:bedd with SMTP id adf61e73a8af0-3a317f8cbb2mr6879688637.17.1776979408708; Thu, 23 Apr 2026 14:23:28 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:09 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-6-dmatlack@google.com> Subject: [PATCH v4 05/11] PCI: liveupdate: Inherit bus numbers during Live Update From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Inherit bus numbers from the previous kernel during a Live Update when one or more PCI devices are being preserved. During a Live Update, preserved devices must be allowed to continue performing memory transactions so the kernel cannot change the fabric topology, including bus numbers, since that would require disabling and flushing any memory transactions first. To keep things simple, inherit the secondary and subordinate bus numbers on all bridges if any PCI devices were preserved (i.e. even bridges without any downstream endpoints that were preserved). This avoids accidentally assigning a bridge a new window that overlaps with a preserved device that is downstream of a different bridge. If a bridge is enumerated with a broken topology or has no bus numbers set during a Live Update, refuse to assign it new bus numbers and refuse to enumerate devices below it. This is a safety measure to prevent topology conflicts. Require that CONFIG_CARDBUS is not enabled to enable CONFIG_PCI_LIVEUPDATE since inheriting bus numbers on PCI-to-CardBus bridges requires additional work but is not a priority at the moment. Signed-off-by: David Matlack --- .../admin-guide/kernel-parameters.txt | 6 +++- drivers/pci/Kconfig | 2 +- drivers/pci/liveupdate.c | 28 +++++++++++++++++++ drivers/pci/probe.c | 21 +++++++++++--- include/linux/pci.h | 1 + 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index cf3807641d89..f412a4b77fb7 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5156,7 +5156,11 @@ Kernel parameters explicitly which ones they are. assign-busses [X86] Always assign all PCI bus numbers ourselves, overriding - whatever the firmware may have done. + whatever the firmware may have done. Ignored + during a Live Update, where the kernel must + inherit the PCI topology (including bus numbers) + to avoid interrupting ongoing memory + transactions of preserved devices. usepirqmask [X86] Honor the possible IRQ mask stored in the BIOS $PIR table. This is needed on some systems with broken BIOSes, notably diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 08398cbe970c..6ef457ff9d08 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -330,7 +330,7 @@ config VGA_ARB_MAX_GPUS =20 config PCI_LIVEUPDATE bool "PCI Live Update Support (EXPERIMENTAL)" - depends on PCI && LIVEUPDATE + depends on PCI && LIVEUPDATE && !CARDBUS help Enable PCI core support for preserving PCI devices across Live Update. This, in combination with support in a device's driver, diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index c0a30d16d9b8..cf8cff134a75 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -93,6 +93,19 @@ * bound to the correct driver. i.e. The PCI core does not protect against= a * device getting preserved by driver A in the outgoing kernel and then ge= tting * bound to driver B in the incoming kernel. + * + * BDF Stability + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * The PCI core guarantees that incoming preserved devices can be identifi= ed by + * the same bus, device, and function numbers as prior to kexec. To accomp= lish + * this, the PCI core always inherits the secondary and subordinate bus nu= mbers + * assigned to bridges during enumeration, rather than assigning new ones = (the + * PCI core assumes that the previous kernel established a sane topology). + * + * If a misconfigured or unconfigured bridge is encountered during enumera= tion + * while there are incoming preserved devices, it's secondary and subordin= ate + * bus numbers will be cleared and devices below it will not be enumerated. */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt @@ -354,6 +367,21 @@ void pci_liveupdate_setup_device(struct pci_dev *dev) if (!xa) return; =20 + /* + * During a Live Update, preserved devices are allowed to continue + * performing memory transactions. The kernel must not change the fabric + * topology, including bus numbers, since that would require disabling + * and flushing any memory transactions first. + * + * To keep things simple, inherit the secondary and subordinate bus + * numbers on _all_ bridges if _any_ PCI devices were preserved (i.e. + * even bridges without any downstream endpoints that were preserved). + * This avoids accidentally assigning a bridge a new window that + * overlaps with a preserved device that is downstream of a different + * bridge. + */ + dev->liveupdate_inherit_buses =3D true; + key =3D pci_ser_xa_key(pci_domain_nr(dev->bus), pci_dev_id(dev)); dev_ser =3D xa_load(xa, key); =20 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 938a28e4a7a0..fa26f4170add 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1374,6 +1374,14 @@ bool pci_ea_fixed_busnrs(struct pci_dev *dev, u8 *se= c, u8 *sub) return true; } =20 +static bool pci_should_assign_new_buses(struct pci_dev *dev) +{ + if (dev->liveupdate_inherit_buses) + return false; + + return pcibios_assign_all_busses(); +} + /* * pci_scan_bridge_extend() - Scan buses behind a bridge * @bus: Parent bus the bridge is on @@ -1401,6 +1409,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, int max, unsigned int available_buses, int pass) { + const bool assign_new_buses =3D pci_should_assign_new_buses(dev); struct pci_bus *child; u32 buses; u16 bctl; @@ -1453,8 +1462,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, goto out; } =20 - if ((secondary || subordinate) && - !pcibios_assign_all_busses() && !broken) { + if ((secondary || subordinate) && !assign_new_buses && !broken) { unsigned int cmax, buses; =20 /* @@ -1496,8 +1504,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, * do in the second pass. */ if (!pass) { - if (pcibios_assign_all_busses() || broken) - + if (assign_new_buses || broken) /* * Temporarily disable forwarding of the * configuration cycles on all bridges in @@ -1511,6 +1518,12 @@ static int pci_scan_bridge_extend(struct pci_bus *bu= s, struct pci_dev *dev, goto out; } =20 + if (dev->liveupdate_inherit_buses) { + pci_err(dev, "Cannot reconfigure bridge during Live Update!\n"); + pci_err(dev, "Downstream devices will not be enumerated!\n"); + goto out; + } + /* Clear errors */ pci_write_config_word(dev, PCI_STATUS, 0xffff); =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index dd6b26ca9462..9a602b322e3c 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -511,6 +511,7 @@ struct pci_dev { unsigned int rom_bar_overlap:1; /* ROM BAR disable broken */ unsigned int rom_attr_enabled:1; /* Display of ROM attribute enabled? */ unsigned int non_mappable_bars:1; /* BARs can't be mapped to user-space = */ + unsigned int liveupdate_inherit_buses:1; /* Inherit bus numbers due to Li= ve Update */ pci_dev_flags_t dev_flags; atomic_t enable_cnt; /* pci_enable_device has been called */ =20 --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 242093C13EE for ; Thu, 23 Apr 2026 21:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979419; cv=none; b=nzgdueif5X1Z0QYA0Mmkp0tLdiQg93pv9lzhwjzYPb09d34lxyQPzp8yJs7ZEX91/ARasHzv+/U4Qh1NZ3suLFZiNWeRJOFvciYRhvbzlVmAKj5Mp/YeksJ59IrDTQZrBFprOsPpxIO4g81VNedoSR68LfQ+eJZ7wju+KRf+l3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979419; c=relaxed/simple; bh=t91HQYsvqO7GpxrInKPzJTXawhCo+mAVGsn6AWsa7oo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=PcMia75yv3VrQzOgUCAwu8RL1wrGAKzFioxtCrgZO4jyMo20AtmATK3PPcP2xJdDEUJx2jn3tmWSwJxi4zy01jipm4Lwj+qtXHoNcSQaoKnapuQpHpBDjV8lFybhBqlNqNN2NYexHRWGcvXtFcR0JSV7eKobclyDE1Z+Key3CC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=F98F217i; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="F98F217i" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2adc527eaf5so56064075ad.0 for ; Thu, 23 Apr 2026 14:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979411; x=1777584211; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eZtY+EWHg3/BRWz3H3Wx+cRr9MZM3880uCt4Dp7O+PI=; b=F98F217iPSUUusEk5WYzTdRhHBGRCVX09+anwzYCtawdgRoaan84zgvLkOEycXrjD1 ShZLIkNsBm5rFN9qgV0uBH+3Ou38j3lu2qU9PDYOvP8zeoKID0x15I7KcXkPDS9b4kr0 n3nNgws0QSaD8ipeIsDlaoUSWtYVFfpO0aGTcLsRSplnxCMYIVxoAXfB7cyMtPfdqTVE o7piHXoXkYt/nK8jpGAJGUOcsixJu4KQmInAnATXrbjh+SHzTH2RE44/vxrPkaA91Syi UTPLodOJuVCl4c9nJgNecI+o6YAsACJB7aWrPqMHKjeoCESQqDm0TcSMo1N+b0SknRJ/ OniQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979411; x=1777584211; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eZtY+EWHg3/BRWz3H3Wx+cRr9MZM3880uCt4Dp7O+PI=; b=anuXSQDeWP0A8rFLJIVutTMLr2Q6/QAnMcO5xyMfs3DIdLHtVuiBrmqDpwQFOV6k6l XFhyZqaaIh8yRWk6GGC/MS7Fb68jzFoIhO9MXWg4DmK9VaIEaqUO4KG+Ay85mZgMsdvR iKWrC/1gr6bubmO33h6Gb/O3Eq68wXAsWoAuZAsayQlHzf56aiePYo2ZXPUgmm1c/7/B 81/TYNEOCeQVfsEWe991Wn3QVcqGRcBdmqK7q7a4JJyyAgT5a0USHmWurv8tV03+5xdF OkRjWqlPDTkBqAcga2pzmouGLQzAjET3RpFmWqpxFC0Fdc7niFdmGyTWd1Fy/eVgpOuC SymQ== X-Forwarded-Encrypted: i=1; AFNElJ+D4Q6R1nqoYSotk+3Ooyjk0oIx7ouj0L012MLtAHBQlIUJ/9GudSZ2BxbyrfdpZ+En6KyK90ToKBOZ7vI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzg77zK67e+aN8BmouN0NCShdK44fs0gfdIzysuEckOEfHp2VAY IEXoYVkM48ROYMCQf0IsUrllnOq/Uh91tekjbsrKA7dphaaOksYxX0oXTcMs9huE4mhTkr9wvHP pKxWoFpwOArseAw== X-Received: from pghu17.prod.google.com ([2002:a63:ef11:0:b0:c74:321:201a]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:3949:b0:39f:27ab:2438 with SMTP id adf61e73a8af0-3a08d90bdbamr33243244637.48.1776979410524; Thu, 23 Apr 2026 14:23:30 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:10 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-7-dmatlack@google.com> Subject: [PATCH v4 06/11] PCI: liveupdate: Auto-preserve upstream bridges across Live Update From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a PCI device is preserved across a Live Update, all of its upstream bridges up to the root port must also be preserved. This enables the PCI core and any drivers bound to the bridges to manage bridges correctly across a Live Update. Notably, this will be used in subsequent commits to ensure that preserved devices can continue performing memory transactions without a disruption or change in routing. To preserve bridges, the PCI core tracks the number of downstream devices preserved under each bridge using a reference count in struct pci_dev_ser. This allows a bridge to remain preserved until all its downstream preserved devices are unpreserved or finish their participation in the Live Update. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 149 +++++++++++++++++++++++++++++---------- 1 file changed, 111 insertions(+), 38 deletions(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index cf8cff134a75..88125f9a2c6b 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -106,6 +106,18 @@ * If a misconfigured or unconfigured bridge is encountered during enumera= tion * while there are incoming preserved devices, it's secondary and subordin= ate * bus numbers will be cleared and devices below it will not be enumerated. + * + * PCI-to-PCI Bridges + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * + * Any PCI-to-PCI bridges upstream of a preserved device are automatically + * preserved when the device is preserved. The PCI core keeps track of the + * number of downstream devices that are preserved under a bridge so that = the + * bridge is only unpreserved once all downstream devices are unpreserved. + * + * This enables the PCI core and any drivers bound to the bridge to partic= ipate + * in the Live Update so that preserved endpoints can continue issuing mem= ory + * transactions during the Live Update. */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt @@ -233,25 +245,14 @@ static struct liveupdate_flb pci_liveupdate_flb =3D { .compatible =3D PCI_LUO_FLB_COMPATIBLE, }; =20 -int pci_liveupdate_preserve(struct pci_dev *dev) +static int pci_liveupdate_preserve_device(struct pci_ser *ser, struct pci_= dev *dev) { - struct pci_ser *ser; - int i, ret; - - guard(mutex)(&pci_flb_outgoing_lock); - - ret =3D liveupdate_flb_get_outgoing(&pci_liveupdate_flb, (void **)&ser); - if (ret) - return ret; + int i; =20 - if (!ser) - return -ENOENT; - - if (dev->is_virtfn) - return -EINVAL; - - if (dev->liveupdate_outgoing) - return -EBUSY; + if (dev->liveupdate_outgoing) { + dev->liveupdate_outgoing->refcount++; + return 0; + } =20 if (ser->nr_devices =3D=3D ser->max_nr_devices) return -ENOSPC; @@ -281,11 +282,82 @@ int pci_liveupdate_preserve(struct pci_dev *dev) =20 return -ENOSPC; } + +static void pci_liveupdate_unpreserve_path(struct pci_ser *ser, struct pci= _dev *dev) +{ + struct pci_dev *upstream_bridge =3D dev->bus->self; + struct pci_dev_ser *dev_ser; + + if (upstream_bridge) + pci_liveupdate_unpreserve_path(ser, upstream_bridge); + + dev_ser =3D dev->liveupdate_outgoing; + if (!dev_ser) { + pci_warn(dev, "Cannot unpreserve device that is not preserved\n"); + return; + } + + if (--dev_ser->refcount =3D=3D 0) { + pci_info(dev, "Device will no longer be preserved across next Live Updat= e\n"); + ser->nr_devices--; + memset(dev_ser, 0, sizeof(*dev_ser)); + dev->liveupdate_outgoing =3D NULL; + } +} + +static int pci_liveupdate_preserve_path(struct pci_ser *ser, struct pci_de= v *dev) +{ + struct pci_dev *upstream_bridge =3D dev->bus->self; + int ret =3D 0; + + if (upstream_bridge) { + ret =3D pci_liveupdate_preserve_path(ser, upstream_bridge); + if (ret) + return ret; + } else if (!pci_is_root_bus(dev->bus)) { + pci_err(dev, "Failed to preserve up to root port\n"); + return -EINVAL; + } + + ret =3D pci_liveupdate_preserve_device(ser, dev); + if (ret) + goto err; + + return 0; + +err: + if (upstream_bridge) + pci_liveupdate_unpreserve_path(ser, upstream_bridge); + + return ret; +} + +int pci_liveupdate_preserve(struct pci_dev *dev) +{ + struct pci_ser *ser; + int ret; + + guard(mutex)(&pci_flb_outgoing_lock); + + ret =3D liveupdate_flb_get_outgoing(&pci_liveupdate_flb, (void **)&ser); + if (ret) + return ret; + + if (!ser) + return -ENOENT; + + if (dev->is_virtfn) + return -EINVAL; + + if (dev->liveupdate_outgoing) + return -EBUSY; + + return pci_liveupdate_preserve_path(ser, dev); +} EXPORT_SYMBOL_GPL(pci_liveupdate_preserve); =20 void pci_liveupdate_unpreserve(struct pci_dev *dev) { - struct pci_dev_ser *dev_ser; struct pci_ser *ser =3D NULL; int ret; =20 @@ -296,19 +368,9 @@ void pci_liveupdate_unpreserve(struct pci_dev *dev) if (ret || !ser) { pci_warn(dev, "Cannot unpreserve device without outgoing Live Update sta= te\n"); return; - - } - - dev_ser =3D dev->liveupdate_outgoing; - if (!dev_ser) { - pci_warn(dev, "Cannot unpreserve device that is not preserved\n"); - return; } =20 - pci_info(dev, "Device will no longer be preserved across next Live Update= \n"); - ser->nr_devices--; - memset(dev_ser, 0, sizeof(*dev_ser)); - dev->liveupdate_outgoing =3D NULL; + pci_liveupdate_unpreserve_path(ser, dev); } EXPORT_SYMBOL_GPL(pci_liveupdate_unpreserve); =20 @@ -428,6 +490,25 @@ void pci_liveupdate_cleanup_device(struct pci_dev *dev) pci_liveupdate_flb_put_incoming(); } =20 +static void pci_liveupdate_finish_path(struct pci_dev *dev) +{ + struct pci_dev *upstream_bridge =3D dev->bus->self; + + if (upstream_bridge) + pci_liveupdate_finish_path(upstream_bridge); + + /* + * Decrement the refcount so this device does not get treated as an + * incoming device again, e.g. in case pci_liveupdate_setup_device() + * gets called again becase the device is hot-plugged. + */ + if (--dev->liveupdate_incoming->refcount) + return; + + pci_info(dev, "Device is finished participating in Live Update\n"); + dev->liveupdate_incoming =3D NULL; +} + void pci_liveupdate_finish(struct pci_dev *dev) { if (!dev->liveupdate_incoming) { @@ -435,15 +516,7 @@ void pci_liveupdate_finish(struct pci_dev *dev) return; } =20 - pci_info(dev, "Device is finished participating in Live Update\n"); - - /* - * Drop the refcount so this device does not get treated as an incoming - * device again, e.g. in case pci_liveupdate_setup_device() gets called - * again becase the device is hot-plugged. - */ - dev->liveupdate_incoming->refcount =3D 0; - dev->liveupdate_incoming =3D NULL; + pci_liveupdate_finish_path(dev); =20 /* Drop this device's reference on the incoming FLB. */ pci_liveupdate_flb_put_incoming(); --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83F813BFE31 for ; Thu, 23 Apr 2026 21:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979420; cv=none; b=rYoAk5hwrDOBgZVokSDqtctVAq9t3OVRDD1BZrVUwwlMNi6b0Z8KeROm/XvhVrFaHZrL/ACikfxbKKsnL5B60nOqzMnSRADlKuhHrIfHWxWlHorqcUjPM4vXXC1wLUxAFz0r87rGEfRfJwnxJStKGigQ4iRvtovV5Lfb75gyJtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979420; c=relaxed/simple; bh=k0MqtokF5x5FrnuJGyuULJNyUYCZIUvKCsZhPGRTT5M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MZ4N5u50/wJ+2rgRrJ+HG46O23CjJDuMMXh2MIxTYEODAbdf2stnowpITvckW5zLxeCzy44iEE3XjiGnpyMGgQ0WLeNYAO0p85Abe9DBgxq/K0DWYmE1qHDbHg2wXvuCDooI3etw56zE7bkne5m0tBlUP3g53yHAR5KDtHbhIUk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=o9QrzpOE; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="o9QrzpOE" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35d9278587bso8317596a91.2 for ; Thu, 23 Apr 2026 14:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979412; x=1777584212; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ys4uatxpJYM7Kl1KgUYRndxIbkLNusGMab4h1bmL7Us=; b=o9QrzpOEoG27XXUFVJqcJBtO11q92FrGntzJZz5mtF2nn6Hu0VYdUkvfA6EiSqVQFq sP+TbIFvXazbxKgYUDqQOAVgu10q+2+HM7qyQ5EUxWZSHJJvj6jnCr2uE5JDNFYN00Qu 5yM0c79bo8yHIYNIyjqhDZ24d3CRez8ZKHVJOm/3rCC/rwi6ezuhQy6vymXvhxKA1S1s nel1hpOYqiV39X1XE1tMtnJfUlE0NtRZcUrkTEkvyfO+gSRRmIumvaGq+enqMz4plyaX bZK/COP7o0lMy/skFw034jke/umUFw5Pfjf5nGn3Q1Es/Z3UxT6su5VuCnU1ElRE+GMU GLHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979412; x=1777584212; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ys4uatxpJYM7Kl1KgUYRndxIbkLNusGMab4h1bmL7Us=; b=DrpNzvBsq5zyRYFviubaHUXiFio4GqfcyFk1vGNjF1yPGydd9zcq9XUYppqU3JSoj/ MgqG9O2dAbowrYb/ibslsxvF5SqtnYX5ZNQsEZTZKjs2445xcIv/VIZWT+7v0hRyE2j0 kFEpi4oDGEhyTZxM4+D2R5FEczlRl41/Ky0d5oRy3yR0wlaJQagJoz3cixQiPpNAs5wd qVR6sGCTBjVZilyE84vMBJZkNww6mEJqggJ1NwfxhFCGldRxWXaVGrWKD7iHGAFKXKDY 4lLQrkPH2T0QwZMaeyYUWWWJ4Ql91GNleYNHKKb7hAtE4r9BFfV12xri5J8aOKSJAtz4 M7ZQ== X-Forwarded-Encrypted: i=1; AFNElJ+RPxdT2jYT76OkskYejzF3bXqR50qwLPjMcSbmQzySB/LLATtHsVVf8wGtwmM02ra3DwjyINqZCxhVL7A=@vger.kernel.org X-Gm-Message-State: AOJu0Yzcb7MxTMF+4v2jTffFL4PQoIoFNm5vjEeQ77US5PrM7iJ4oqcO 0Yj3x6rLwICWaDJkDWY6K5kaj3KEPIQOuq3AD+ijTnU5HnQe6NXn1TWLKsHuxRUOnTJ+GUPRNfO 0IVDa9KSFLPWj9w== X-Received: from pjbbj17.prod.google.com ([2002:a17:90b:891:b0:362:b5ab:9cd3]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:51a3:b0:362:bb93:f25e with SMTP id 98e67ed59e1d1-362bb93f462mr8872524a91.23.1776979412273; Thu, 23 Apr 2026 14:23:32 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:11 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-8-dmatlack@google.com> Subject: [PATCH v4 07/11] PCI: liveupdate: Inherit ACS flags in incoming preserved devices From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Inherit Access Control Services (ACS) flags on all incoming preserved devices (endpoints and upstream bridges) during a Live Update. Inheriting ACS flags avoids changing routing rules while memory transactions are in flight from preserved devices. This is also strictly necessary to ensure that IOMMU group assignments do not change across a Live Update for preserved devices, as changing ACS configurations can split or merge IOMMU groups. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 10 ++++++++++ drivers/pci/pci.c | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index 88125f9a2c6b..a9a89f7bd3e5 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -118,6 +118,16 @@ * This enables the PCI core and any drivers bound to the bridge to partic= ipate * in the Live Update so that preserved endpoints can continue issuing mem= ory * transactions during the Live Update. + * + * Handling Preserved Devices + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + * + * The PCI core treats preserved devices differently than non-preserved de= vices. + * This section enumerates those differences. + * + * * The PCI core inherits all ACS flags enabled on incoming preserved de= vices + * rather than assigning new ones. This ensures that TLPs are routed th= e same + * way after Live Update and ensures that IOMMU groups do not change. */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8f7cfcc00090..e615b7c3e430 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1017,6 +1017,15 @@ void pci_enable_acs(struct pci_dev *dev) bool enable_acs =3D false; int pos; =20 + /* + * ACS flags must be inherited from the previous kernel during a Live + * Update for preserved devices (which includes endpoints and any + * upstream bridges) to avoid changing routing while memory transactions + * are in flight. + */ + if (pci_liveupdate_incoming(dev)) + return; + /* If an iommu is present we start with kernel default caps */ if (pci_acs_enable) { if (pci_dev_specific_enable_acs(dev)) @@ -1041,7 +1050,6 @@ void pci_enable_acs(struct pci_dev *dev) PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC, ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC)); __pci_config_acs(dev, &caps, config_acs_param, 0, 0); - pci_write_config_word(dev, pos + PCI_ACS_CTRL, caps.ctrl); } =20 --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCE2F3C2770 for ; Thu, 23 Apr 2026 21:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979420; cv=none; b=qeJ0AoE9SNTd4QWVcROiGVPpKqauW2jwfxQP49y5D9nAmzpsN7jUPJOUprpQWTPHuc+pcuddtWFzDy8b92aJDXu6kIfggOExqZZEevpKXZnwRWLDr3udQF1orPBZdb/BzprHveVISla7a5UCY5IOAXskwEDFdhXuZxdE1cHSUFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979420; c=relaxed/simple; bh=GLaesJwUwri2XBQC98JUEA4yA/xfrELrLuoXDywngTA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=V7a2vVSXMCp6Rs6k3xGM98r8KELi/KzAE0WLXqcwcCzRLk8BuXvHvXDbPEvX3J/8zO1sJh2dy6Hc5TCc/7M+gthhAdOqHQ/1BoiopBXrshk26wnVbSxG295GQNwevWQQBbXUSMiK2+2p36NL7Ra9zAvLUoqqw3vgNS4oCQxxvEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VA1+2JWS; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VA1+2JWS" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-bce224720d8so4148498a12.1 for ; Thu, 23 Apr 2026 14:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979414; x=1777584214; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Xzr76OgKRSVyLlNPZ4BBmoEisHfu3frnnsSEc+2qgNA=; b=VA1+2JWS7IZk/6jE0kqswLqR5jApMuOYqzkzFNJ3x+Q9JgNdA45/321J5I4rX11z+g slDC3Fq8zkBjz1Svs0kAN+Mt1Oho1BMZh6UBZ9SGs/KViObuW7J/7vEUGTUgaoRjXRDt tiQzTejOANkIfN5m+y9o6ARdNe1BqyJXHGz+ObRIV34TbXJUC4f8FFWfXcwGLAz20+7f 8ZLtTXFotDyJ+SHn+fC1whXylunliysds+0xQLPSnvqfsZk55z6rjWLlz/3QwUD+ww1H YtjFH2fzBtLFUYixCMMwt6OSRVn0WC1XFFWri5xC6OomH0gAIJbU0CoxQflYDM5NvsnO t/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979414; x=1777584214; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Xzr76OgKRSVyLlNPZ4BBmoEisHfu3frnnsSEc+2qgNA=; b=ZW82qLpDrFw5fiiPQ7QcQtMw9Z1nmNeMBbNQyu2GsgcZ5GYS4t/PsWs8JhfkSoTF0O DBPrsjiIXA00pQqeWpKdbN2Z1zGlXhXZJlHvmhvjvgrxhueAncNWkt4hJDrMA5IFihaC wgw0JEvCAy3utskgzHqkZEW7gMOH3iq5OyzdiRDZgU5GLGuez2htyPZiwtMCl8LqZV6F ZPv7NesjoIdWm4lkZ//wCRsB6zB+EKG4ZyDwkpyq3rK1qWETpOhYk9uxBeZSkCpChuPD 60F2NQ5XWBE+ExhuUdJXDOYmK2uexg8we1LLmg24LpZZ7AC6j5DerJeKJ655vH94JWHx 8XxA== X-Forwarded-Encrypted: i=1; AFNElJ/CW5ff5KbbZm/ppz5qUYYXsV/i4IllSe+p7d6W9gQT3la55KvcZGMHnJfwCGy7hosMM2gPQbeLL2nBlhI=@vger.kernel.org X-Gm-Message-State: AOJu0Yydaku5O3ZBacrc8qYaKmuvOE0vY8/Oz/GsrVmV2w8vEocNIvwW OVuynuNcuURLGX2uJ2m7HoNpUjV7xNYEflvkd07L6rIPuCYEgQWgIYOulBsU+JyvnyEMOyERjeC ZAAhckO7q0kTbzQ== X-Received: from pgbda7.prod.google.com ([2002:a05:6a02:2387:b0:c79:9058:b77e]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6da2:b0:3a0:b781:4c8b with SMTP id adf61e73a8af0-3a0b78155d5mr25116879637.2.1776979414052; Thu, 23 Apr 2026 14:23:34 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:12 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-9-dmatlack@google.com> Subject: [PATCH v4 08/11] PCI: liveupdate: Require preserved devices are in immutable singleton IOMMU groups From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Restrict support for preserving PCI devices across Live Update to devices in immutable singleton IOMMU groups. A device's group is considered immutable if all bridges upstream from the device up to the root port have the required ACS features enabled. Since ACS flags are inherited across a Live Update for preserved devices and all the way up to the root port, the preserved device should be in a singleton IOMMU group after kexec in the new kernel. This change should still permit all the current use-cases for PCI device preservation across Live Update, since it is intended to be used in Cloud enviroments which should have the required ACS features enabled for virtualization purposes. If a device is part of a multi-device IOMMU group, preserving it will now fail with an error. This restriction may be lifted in the future if support for preserving multi-device groups is desired. Signed-off-by: David Matlack --- drivers/iommu/iommu.c | 35 +++++++++++++++++++++++++++++++++++ drivers/pci/liveupdate.c | 6 ++++++ include/linux/iommu.h | 7 +++++++ 3 files changed, 48 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 61c12ba78206..782e73a9d45f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1664,6 +1664,41 @@ struct iommu_group *pci_device_group(struct device *= dev) } EXPORT_SYMBOL_GPL(pci_device_group); =20 +bool pci_device_group_immutable_singleton(struct pci_dev *dev) +{ + struct iommu_group *group; + struct group_device *d; + struct pci_bus *bus; + int nr_devices =3D 0; + + group =3D iommu_group_get(&dev->dev); + if (!group) + return false; + + mutex_lock(&group->mutex); + + for_each_group_device(group, d) + nr_devices++; + + mutex_unlock(&group->mutex); + iommu_group_put(group); + + if (nr_devices !=3D 1) + return false; + + for (bus =3D dev->bus; !pci_is_root_bus(bus); bus =3D bus->parent) { + if (!bus->self) + continue; + + if (!pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS)) + return false; + + break; + } + + return true; +} + /* Get the IOMMU group for device on fsl-mc bus */ struct iommu_group *fsl_mc_device_group(struct device *dev) { diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index a9a89f7bd3e5..54a90ff02bdd 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -133,6 +133,7 @@ #define pr_fmt(fmt) "PCI: liveupdate: " fmt =20 #include +#include #include #include #include @@ -359,6 +360,11 @@ int pci_liveupdate_preserve(struct pci_dev *dev) if (dev->is_virtfn) return -EINVAL; =20 + if (!pci_device_group_immutable_singleton(dev)) { + pci_warn(dev, "Device preservation limited to immutable singleton iommu = groups\n"); + return -EINVAL; + } + if (dev->liveupdate_outgoing) return -EBUSY; =20 diff --git a/include/linux/iommu.h b/include/linux/iommu.h index e587d4ac4d33..6f5d1dec3f89 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1096,6 +1096,8 @@ extern struct iommu_group *generic_device_group(struc= t device *dev); struct iommu_group *fsl_mc_device_group(struct device *dev); extern struct iommu_group *generic_single_device_group(struct device *dev); =20 +bool pci_device_group_immutable_singleton(struct pci_dev *dev); + /** * struct iommu_fwspec - per-device IOMMU instance data * @iommu_fwnode: firmware handle for this device's IOMMU @@ -1528,6 +1530,11 @@ static inline int pci_dev_reset_iommu_prepare(struct= pci_dev *pdev) static inline void pci_dev_reset_iommu_done(struct pci_dev *pdev) { } + +static inline bool pci_device_group_immutable_singleton(struct pci_dev *de= v) +{ + return false; +} #endif /* CONFIG_IOMMU_API */ =20 #ifdef CONFIG_IRQ_MSI_IOMMU --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBF813C342B for ; Thu, 23 Apr 2026 21:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979424; cv=none; b=oR1F/JOS1OEWZco6F403x5tYNSDx/B+31CgHvwaIF7w9UuCkynRKlilJLL9EQxdrzP65oBkK8D1+S9VrPLvjQZFqJZHrh+bi1U6SAo4tB5rx8Ch1iDM4FDnx4NzfGXPXxWfxyVUAjAW4JhdP+TeJSmAKbwI5ioqlmX5OludIMjg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979424; c=relaxed/simple; bh=85D2Ac3hBoG1dFzFVA37bHIGBGx9gipkQcKVvZXkhV0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=YuzrP8vbjIJImjAdYWIaGGa0+jRMg+iq7iRJWQUexukbFJcGsvafK5LqhfkCRydbOOhXHqkh8FuBHdkS7VDXqqKaAqv6nI+Tlfq6wY+bJLs3lkJIO7V7ZRmTwQ5dX409/vbQ5wM3xu7+RVHvhuP+dX/MDLSWxI8tnd3Yqc3lLew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WftHepeb; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WftHepeb" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b2eba42b8dso63916295ad.0 for ; Thu, 23 Apr 2026 14:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979416; x=1777584216; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=E/PZfm0ILlaeTWExhdrHJ+nS/9VkLe0d8hpRsDexX1A=; b=WftHepebeGrtlnGFv1eTN7gbQTxf65Be0pW2b6TIYxRpTxGkTQ+I0XcccEZXLPTcyz DPxyUxv8OsvX2MyW2vlljWc+Q3/fQFKhHAZqUjHvI0LPoTmYcLvLflgzq1ogKS6aaWf9 g8v4Bm29KZf7+IUzwodjsRaNecxSXBmQMf4qJ7GD9n+cqkTn9j0Hw4AkHMdhwXcKK6Iv PmlVxQX3oD+GuMJG26POAs9yNa2X/P8LlaDwNz1B65ZOknndB0rUaG8iUpPWWyGRoJlY 47amll8l/Exvo+UHTiy8s7J1NOO0PvD+aY7jz+eJacalsrMkWtE5XeQ5xJwTZp64Hv56 XqsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979416; x=1777584216; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E/PZfm0ILlaeTWExhdrHJ+nS/9VkLe0d8hpRsDexX1A=; b=MJ0WSUKYYCzXIdPju+CMGmigwO2uBE8QieKcTSB12OQZ0hpJfyfvVHkZLsblpPWD/4 yKpXmQWnoC96dLykYoD+z9+2Iwk/TU6wSrxxwbc7vCqnQwlbzVNmksyYf+FfscMIO1BZ DFGEaQrqtBhOvqGlFGeeusd+Fdk3C8VFF7+Y1SnAuYKmVAbCc8KrzC7LV2VnekVjYvTP mKYNNHTfOC5WCcbytALW3nR4YZxn3CfOEkbQILJG42cMKBNfIcemHveKE4zeGOcHdHiV YE02Ifx5aKBLUiLkjaSoAhUvxhGw4WcxXn0vGdpqktSgQ4egwK2PGKSiEnXweflwVcdn gOlg== X-Forwarded-Encrypted: i=1; AFNElJ/hUSsu56mJzKwMnAfXxwYpsIy3B7OUo0COvmltdoEY9l3SOcA+fUmCsYtL2Bru1KF7aM/i+xsvhJwfoCM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxdp5/Ff1RNC4xeT8tn/Ez1G3uOvFfBal5zjbRTiUjOSI0u61OY KZ5sOc8iwtq/1zPRLxIdRmzMrTkgUGIUN0EtNaGuTayBW3vAWv4C94PV1J2AVSenT+3B4gFmPrS OhmTSST2KcRxJSQ== X-Received: from plav22.prod.google.com ([2002:a17:902:f0d6:b0:2b0:5380:49f1]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1a88:b0:2b2:5ec6:dcf6 with SMTP id d9443c01a7336-2b5f9e85f20mr294713095ad.8.1776979415642; Thu, 23 Apr 2026 14:23:35 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:13 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-10-dmatlack@google.com> Subject: [PATCH v4 09/11] PCI: liveupdate: Inherit ARI Forwarding Enable on preserved bridges From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Inherit the ARI Forwarding Enable on preserved bridges and update pci_dev->ari_enabled accordingly during a Live Update. This ensures that the preserved devices on the bridge's secondary bus can be identified with the same expanded 8-bit function number after a Live Update. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 4 ++++ drivers/pci/pci.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index 54a90ff02bdd..25c86cd4c173 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -128,6 +128,10 @@ * * The PCI core inherits all ACS flags enabled on incoming preserved de= vices * rather than assigning new ones. This ensures that TLPs are routed th= e same * way after Live Update and ensures that IOMMU groups do not change. + * + * * The PCI core inherits ARI Forwarding Enable on all bridges with down= stream + * preserved devices to ensure that all preserved devices on the bridge= 's + * secondary bus are addressable after the Live Update. */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e615b7c3e430..b45539c55c7d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3498,8 +3498,9 @@ void pci_configure_ari(struct pci_dev *dev) { u32 cap; struct pci_dev *bridge; + u16 val =3D 0; =20 - if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) + if (!pci_is_pcie(dev) || dev->devfn) return; =20 bridge =3D dev->bus->self; @@ -3510,6 +3511,15 @@ void pci_configure_ari(struct pci_dev *dev) if (!(cap & PCI_EXP_DEVCAP2_ARI)) return; =20 + if (pci_liveupdate_incoming(bridge)) { + pcie_capability_read_word(bridge, PCI_EXP_DEVCTL2, &val); + bridge->ari_enabled =3D !!(val & PCI_EXP_DEVCTL2_ARI); + return; + } + + if (pcie_ari_disabled) + return; + if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) { pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8C983C13F5 for ; Thu, 23 Apr 2026 21:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979424; cv=none; b=S/MpqdBaUQE1K+C6IwqnJzHmP4x5+sDCND8rUM50AiXwdvCEVhTbjSoYcWm8jcV7CzjDt4wKCCR09tCgLYVmxlrRXWs6aVewphRwqNAd+ZcNhS0YbFGK4a1+iiScbp2V3AFivKNgXWkshNomBOK06i3tG4durDIGrBjLONkUllc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979424; c=relaxed/simple; bh=Oe8MwOihG5BzjH99EK3y2Iy4j4M/3j0maoUzCe5H9s8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WnOt7hKJlGrAxboFoO1iNx0z1H8gJzCq+4aaWt1eVnM36aFmzoeok+lAhWBMAeocYML4do0y7QDHmGMD8HsyGTMqP4//fXWvgZuKizEjG656Qhy2C/mJkI59EKXi5NjEOMn4XxrlwM68zS15sM/MTTAp2JqfwI/EEutM7eOR+6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=S6Yg/35I; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="S6Yg/35I" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2b242b9359aso70728535ad.0 for ; Thu, 23 Apr 2026 14:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979418; x=1777584218; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NDSmr3KzvFf45fqXLLacm4Nig+LS/n/kl38OHtIvfGo=; b=S6Yg/35I+BOb4hlpM7fzMitlnY4VsnIm8RupHp0/S0Bs1Bi9GhkNJoPAuow9rzY+vH ustao6je+FQe+CEwUTr/JgUaCeehxRbwLbaVcupthpdSpZ4L7kOgB0UTvQvU5etRR3HD QCsLDtGOo1VZs8zLzhUlPdHdPb1ZnbqF59ZDdaYRnQ8Iaa7TT7t/ZPAkjoVqxbSrPbaH oyCaNehedELWVERJ+buwkQvhjc5g4shwm4F3SHsZ/z/RPjcn778jZ6amThx8037XTcGD wQrcfJUCLw8Ej5pzHTOhkTLs+9H/Rwet4hCqtrsK+HFlyKW24P2T2BzKgGGYE++mGss+ uQ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979418; x=1777584218; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NDSmr3KzvFf45fqXLLacm4Nig+LS/n/kl38OHtIvfGo=; b=ZrBu5KhZE/rsWLfDevN4gzM7VPVoRlgHvbYmVtuwEaXDxPR2lHwNAKBhvU0YiJYsHD GaeFUpKNY6QUAbJ4JRSi2qs/JfFAQAH0ZBXJa2cM9UyCcOXQ83R8puv5WBG9vd12xqbl YeEzftQXYTvyOgbt0uxDTthjWj4NW0u7kJ0GjDbrbg6agyCTXkdhzv/ZFWXaHDfhubzY bX1gLNyXnEBFmRUccCErU1OjSM82b79xdrfV/FMa7srOqCvpKvfctSbLIgdLKn3JRjIy rxJjLxT+CcG6ZkvJSBLEVRYTlLyG2FTk2+91up19yBhPYWmSChGpX6dwHEUAhmeuC09x Fn1Q== X-Forwarded-Encrypted: i=1; AFNElJ+fFg4JYyMl24HA/i0LB353VV0AC1ywO90EG35XppOdY7kncLQRoSvUaYlWor9n3nuaT6ZtUcAqAie3B0o=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5ncdzawM/TUTaGYuR6m1i6FkfHiqRsnGk58HY3UkU7RmPT3Cs w5dc73F+wukYvbSpctQpjhaF9WQZe/UT84iF/6y+sYXqGi1tLbtMymvQZS2/vwZ08KrTsCSx6f1 zTFsAS0m846OTNw== X-Received: from plov1.prod.google.com ([2002:a17:902:8d81:b0:2ae:c54f:d5ad]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ba94:b0:2b4:5c0d:314b with SMTP id d9443c01a7336-2b5f9f83342mr210260195ad.38.1776979417788; Thu, 23 Apr 2026 14:23:37 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:14 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-11-dmatlack@google.com> Subject: [PATCH v4 10/11] PCI: liveupdate: Do not disable bus mastering on preserved devices during kexec From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Do not disable bus mastering on outgoing preserved devices during pci_device_shutdown() for kexec. Preserved devices must be allowed to perform memory transactions during a Live Update to minimize downtime and ensure continuous operation. Clearing the bus mastering bit would prevent these devices from issuing any memory requests while the new kernel boots. Because bridges upstream of preserved endpoint devices are also automatically preserved, this change also avoids clearing bus mastering on them. This is critical because clearing bus mastering on an upstream bridge prevents the bridge from forwarding memory requests upstream (i.e. it would prevent the endpoint device from accessing system RAM and doing peer-to-peer transactions with devices not downstream of the bridge). Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 4 ++++ drivers/pci/pci-driver.c | 31 ++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index 25c86cd4c173..2a4a139623a6 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -132,6 +132,10 @@ * * The PCI core inherits ARI Forwarding Enable on all bridges with down= stream * preserved devices to ensure that all preserved devices on the bridge= 's * secondary bus are addressable after the Live Update. + * + * * The PCI core does not disable bus mastering on outoing preserved dev= ices + * during kexec. This allows preserved devices to issue memory transact= ions + * throughout the Live Update. */ =20 #define pr_fmt(fmt) "PCI: liveupdate: " fmt diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index d10ece0889f0..05584bc76332 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -531,6 +531,27 @@ static void pci_device_remove(struct device *dev) pci_dev_put(pci_dev); } =20 +/* + * Disable bus mastering on the device so that it does not perform memory + * transactions during kexec. + * + * Don't touch devices that are being preserved across kexec for Live + * Update or that are in D3cold or unknown states. + */ +static void pci_clear_master_for_shutdown(struct pci_dev *pci_dev) +{ + if (!kexec_in_progress) + return; + + if (pci_liveupdate_outgoing(pci_dev)) + return; + + if (pci_dev->current_state > PCI_D3hot) + return; + + pci_clear_master(pci_dev); +} + static void pci_device_shutdown(struct device *dev) { struct pci_dev *pci_dev =3D to_pci_dev(dev); @@ -541,15 +562,7 @@ static void pci_device_shutdown(struct device *dev) if (drv && drv->shutdown) drv->shutdown(pci_dev); =20 - /* - * If this is a kexec reboot, turn off Bus Master bit on the - * device to tell it to not continue to do DMA. Don't touch - * devices in D3cold or unknown states. - * If it is not a kexec reboot, firmware will hit the PCI - * devices with big hammer and stop their DMA any way. - */ - if (kexec_in_progress && (pci_dev->current_state <=3D PCI_D3hot)) - pci_clear_master(pci_dev); + pci_clear_master_for_shutdown(pci_dev); } =20 #ifdef CONFIG_PM_SLEEP --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog From nobody Fri Jun 19 17:21:46 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 507D23C4551 for ; Thu, 23 Apr 2026 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979427; cv=none; b=SlltKqbazj+xH+bYeODRvRcg/GnDO1xzpZSQzycqjKrEhEZVcVNrxUmzUj2qKXbfUk8AQwsg7n0lMm548nsE0+XL/uQ/G78Pgw9HLWZ3IVguJ/uo0ggTNTQnUQQw3mmQVolDPlxhxhinkGUaHqUJUWhB3G3LCOBjELfEx6Mk0no= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979427; c=relaxed/simple; bh=TAk9N0onkf1LhiBL762i+SXrkfm+35fT9FFl7hPmejg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cy6Hu3G25+J7ACYIMLqRDTC2NVMxQa+1ntiwa50bqWenEYkKRmwCD+1gUpAJ1ui6T06NyUjUPAQMDx14kS26isgqUBeGEamIujs5coC6SjRoZU5jNfZ07kUF+XwzCeM/Gp/tZ/YN1UofksvvnVqUZVYQPoxl4kQsIW7igDol1C4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JKgJaVln; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JKgJaVln" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2b2e8bba2e6so100401435ad.1 for ; Thu, 23 Apr 2026 14:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979420; x=1777584220; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4E3v8P9Bgd+PvGMRS8uoO/TIv3RrWRtb2HfczKdNV9k=; b=JKgJaVlnR8hG+u7YpR5pb79KVryCkxD8SKpnMekLWmpAIJRl+oUGY+B5CsJE0YShSo l853HXv0wtILtDRYHOUPMdEs7E79lCAzHNbXLX/TMHc1pH+3EaIPW6N5+A/uGs+Gng13 Z8L+KqtKLsgLT2yFRNz7tFFm2OsWkwCGXjNU15uiPMGVNCqK9EDUYlG6UVFKqYf9bS4q 8f31+D0vW+zZm8Y/raiL+xPaAjZcN3naU43OgaWKmZM1xtdmaf2UsZT/GQs+Hn4a9/zX wZsDkQeBvaQhM1a3qL94fgzo0aR/Gx+Y7I7iER4cHQ/ulsaYgtmM0OdrnIkuP80LRQNH TEKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979420; x=1777584220; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4E3v8P9Bgd+PvGMRS8uoO/TIv3RrWRtb2HfczKdNV9k=; b=AWHRTdbgA75nsRnHFuSXqgAEO7xyfdo/WMza0rle9KpH4haedavd9dmO7Me5btit7D P8AT4gHMy0boVqSXl4U+K/QIhF3pcK3v3CQaqPvRrs00kgxniVfss5/J/gZkM/gsI0Ai p08fhRUtStkhoQMGAZGfc4aKRUFHM78FHCkPJQFiMamgmRHt5dHN/rUjYnwigMvUvuUw L2MSQZrczq87W8LBD33JHMCvdEvhGm0UIH0lAgo5C21T9BAN9slnnWKlyl5Njq6hFv2t GkWJ2kistpK8FfUW/uNyALARkk55hgHLRduATiOnK3oGWKvvLcQmBq5OoPw2LjrNGrFH 6E+g== X-Forwarded-Encrypted: i=1; AFNElJ/yOUzF854GfVRyOkOqgMYK/fK0ew8AiGkjAa23bJj2VqDTpMyEhHqIYpUcXCSks5zmfRz7Uu1yVq0OCQk=@vger.kernel.org X-Gm-Message-State: AOJu0YxgByWA8CxGnOfulX97fkUAspD5otGvZEgc+lVVkuMrAEjsk09N AZZ8V9kor2XLiny5iiEaPiVORnrXn2874gQciQQYGTFHmvkwvqvCddmuGiW3xQEy1+zFOUWXbYd q7ZvkN+59L8f3zA== X-Received: from plon6.prod.google.com ([2002:a17:903:1a86:b0:2b2:c9d2:11fd]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2984:b0:2b0:4f9a:b794 with SMTP id d9443c01a7336-2b5f9fd146amr301151585ad.37.1776979419527; Thu, 23 Apr 2026 14:23:39 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:15 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-12-dmatlack@google.com> Subject: [PATCH v4 11/11] Documentation: PCI: Add documentation for Live Update From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add documentation files for the PCI subsystem's participation in Live Update. These documentation files are generated from the kernel-doc comments in the PCI Live Update source code. They describe the File-Lifecycle Bound (FLB) API, the device tracking API, and the specific policies applied to preserved devices (such as bus number inheritance and bus mastering preservation). Signed-off-by: David Matlack --- Documentation/PCI/index.rst | 1 + Documentation/PCI/liveupdate.rst | 23 +++++++++++++++++++++++ Documentation/core-api/liveupdate.rst | 1 + MAINTAINERS | 1 + 4 files changed, 26 insertions(+) create mode 100644 Documentation/PCI/liveupdate.rst diff --git a/Documentation/PCI/index.rst b/Documentation/PCI/index.rst index 5d720d2a415e..23fb737ac969 100644 --- a/Documentation/PCI/index.rst +++ b/Documentation/PCI/index.rst @@ -20,3 +20,4 @@ PCI Bus Subsystem controller/index boot-interrupts tph + liveupdate diff --git a/Documentation/PCI/liveupdate.rst b/Documentation/PCI/liveupdat= e.rst new file mode 100644 index 000000000000..04c9b675e8df --- /dev/null +++ b/Documentation/PCI/liveupdate.rst @@ -0,0 +1,23 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +PCI Support for Live Update +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + +.. kernel-doc:: drivers/pci/liveupdate.c + :doc: PCI Live Update + +PCI Preservation ABI +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. kernel-doc:: include/linux/kho/abi/pci.h + :doc: PCI File-Lifecycle Bound (FLB) Live Update ABI + +.. kernel-doc:: include/linux/kho/abi/pci.h + :internal: + +See Also +=3D=3D=3D=3D=3D=3D=3D=3D + + * :doc:`/core-api/liveupdate` + * :doc:`/core-api/kho/index` diff --git a/Documentation/core-api/liveupdate.rst b/Documentation/core-api= /liveupdate.rst index 5a292d0f3706..d56a7760978a 100644 --- a/Documentation/core-api/liveupdate.rst +++ b/Documentation/core-api/liveupdate.rst @@ -70,3 +70,4 @@ See Also =20 - :doc:`Live Update uAPI ` - :doc:`/core-api/kho/index` +- :doc:`PCI ` diff --git a/MAINTAINERS b/MAINTAINERS index 94af31837375..42dbac2c2ed3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -20564,6 +20564,7 @@ Q: https://patchwork.kernel.org/project/linux-pci/l= ist/ B: https://bugzilla.kernel.org C: irc://irc.oftc.net/linux-pci T: git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git +F: Documentation/PCI/liveupdate.rst F: drivers/pci/liveupdate.c F: include/linux/kho/abi/pci.h =20 --=20 2.54.0.rc2.544.gc7ae2d5bb8-goog