From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CFC4E67A6D for ; Tue, 3 Mar 2026 06:22:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TXvC0W9BK/qCDM2luuVOjFiw+pG7WQpudbkrpHQ06Bk=; b=JLAxm8QQRK3Da//v9+z4usmIx8 9KjrlndCuJtI/WpGrDW/7xf5OFNaM1xq7PPtUXEQ8T5zgxWWobAEGLoM6ICoD///HStcutFfnKZTv ktc9vWUAe/a9633tG6kazd7jKJlShUEdqXvX4I28YNFF7PBIroTLOeXffdYJMWuweobAplE92aaVc uJpy98M8xBQWkuh7U9W4VmsmrezxpLUSKJ3Q4a3zJBnmFZlju7abd33lzvTc1rweJGqqgdwg9fiQJ jf0YlsM46IgxnnQL53yx1LGAtyixtC1J+XxRQTBc1WaVss45xn2Lj5UMIMGSWbgFLDSuOtPB2O5up 1BTVBozg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxJ9A-0000000Eblp-1zRo; Tue, 03 Mar 2026 06:22:20 +0000 Received: from out-179.mta0.migadu.com ([2001:41d0:1004:224b::b3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxJ97-0000000EblQ-2Spo for kexec@lists.infradead.org; Tue, 03 Mar 2026 06:22:19 +0000 Message-ID: <63622051-f128-4450-8579-97f25305beb5@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772518931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TXvC0W9BK/qCDM2luuVOjFiw+pG7WQpudbkrpHQ06Bk=; b=hBFbBJNeRGCjHua0QjXLgz/eHaN8IFODEb3GXPUD8UbMcTeR5gfAlvWl0O3UihX48thOvt iQ65ft3idSC9hFOIMyAXX0qKP2XgbVR99CJAnOOkPB00eEHxxmhlfz9pNXQ2DLDcq9edGY 7UJwXmxf3sVgeP7+cgWF1X5/kjOz/Tk= Date: Mon, 2 Mar 2026 22:21:55 -0800 MIME-Version: 1.0 Subject: Re: [PATCH v2 04/22] vfio/pci: Register a file handler with Live Update Orchestrator To: David Matlack , Alex Williamson Cc: Adithya Jayachandran , Alexander Graf , Alex Mastro , Alistair Popple , Andrew Morton , Ankit Agrawal , Bjorn Helgaas , Chris Li , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Kevin Tian , kexec@lists.infradead.org, kvm@vger.kernel.org, Leon Romanovsky , Leon Romanovsky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Lukas Wunner , =?UTF-8?Q?Micha=C5=82_Winiarski?= , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Raghavendra Rao Ananta , Rodrigo Vivi , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= , Tomita Moeko , Vipin Sharma , Vivek Kasireddy , William Tu , Yi Liu References: <20260129212510.967611-1-dmatlack@google.com> <20260129212510.967611-5-dmatlack@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zhu Yanjun In-Reply-To: <20260129212510.967611-5-dmatlack@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260302_222217_948062_F57B6470 X-CRM114-Status: GOOD ( 29.61 ) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" Errors-To: kexec-bounces+kexec=archiver.kernel.org@lists.infradead.org 在 2026/1/29 13:24, David Matlack 写道: > From: Vipin Sharma > > Register a live update file handler for vfio-pci device files. Add stub > implementations of all required callbacks so that registration does not > fail (i.e. to avoid breaking git-bisect). > > This file handler will be extended in subsequent commits to enable a > device bound to vfio-pci to run without interruption while the host is > going through a kexec Live Update. > > Signed-off-by: Vipin Sharma > Co-developed-by: David Matlack > Signed-off-by: David Matlack > --- > MAINTAINERS | 1 + > drivers/vfio/pci/Makefile | 1 + > drivers/vfio/pci/vfio_pci.c | 9 +++- > drivers/vfio/pci/vfio_pci_liveupdate.c | 69 ++++++++++++++++++++++++++ > drivers/vfio/pci/vfio_pci_priv.h | 14 ++++++ > include/linux/kho/abi/vfio_pci.h | 28 +++++++++++ > 6 files changed, 121 insertions(+), 1 deletion(-) > create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c > create mode 100644 include/linux/kho/abi/vfio_pci.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index a671e3d4e8be..7d6cdecedb05 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -27520,6 +27520,7 @@ F: Documentation/ABI/testing/debugfs-vfio > F: Documentation/ABI/testing/sysfs-devices-vfio-dev > F: Documentation/driver-api/vfio.rst > F: drivers/vfio/ > +F: include/linux/kho/abi/vfio_pci.h > F: include/linux/vfio.h > F: include/linux/vfio_pci_core.h > F: include/uapi/linux/vfio.h > diff --git a/drivers/vfio/pci/Makefile b/drivers/vfio/pci/Makefile > index e0a0757dd1d2..23305ebc418b 100644 > --- a/drivers/vfio/pci/Makefile > +++ b/drivers/vfio/pci/Makefile > @@ -7,6 +7,7 @@ obj-$(CONFIG_VFIO_PCI_CORE) += vfio-pci-core.o > > vfio-pci-y := vfio_pci.o > vfio-pci-$(CONFIG_VFIO_PCI_IGD) += vfio_pci_igd.o > +vfio-pci-$(CONFIG_LIVEUPDATE) += vfio_pci_liveupdate.o > obj-$(CONFIG_VFIO_PCI) += vfio-pci.o > > obj-$(CONFIG_MLX5_VFIO_PCI) += mlx5/ > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index 0c771064c0b8..19e88322af2c 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -258,6 +258,10 @@ static int __init vfio_pci_init(void) > int ret; > bool is_disable_vga = true; > > + ret = vfio_pci_liveupdate_init(); > + if (ret) > + return ret; > + > #ifdef CONFIG_VFIO_PCI_VGA > is_disable_vga = disable_vga; > #endif > @@ -266,8 +270,10 @@ static int __init vfio_pci_init(void) > > /* Register and scan for devices */ > ret = pci_register_driver(&vfio_pci_driver); > - if (ret) > + if (ret) { > + vfio_pci_liveupdate_cleanup(); > return ret; > + } > > vfio_pci_fill_ids(); > > @@ -281,6 +287,7 @@ module_init(vfio_pci_init); > static void __exit vfio_pci_cleanup(void) > { > pci_unregister_driver(&vfio_pci_driver); > + vfio_pci_liveupdate_cleanup(); > } > module_exit(vfio_pci_cleanup); > > diff --git a/drivers/vfio/pci/vfio_pci_liveupdate.c b/drivers/vfio/pci/vfio_pci_liveupdate.c > new file mode 100644 > index 000000000000..b84e63c0357b > --- /dev/null > +++ b/drivers/vfio/pci/vfio_pci_liveupdate.c > @@ -0,0 +1,69 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +/* > + * Copyright (c) 2025, Google LLC. The live update support for vfio-pci was initiated in 2025, but developments are into 2026. Update the copyright to 2026 or 2025 - 2026. Zhu Yanjun > + * Vipin Sharma > + * David Matlack > + */ > + > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > + > +#include > +#include > +#include > + > +#include "vfio_pci_priv.h" > + > +static bool vfio_pci_liveupdate_can_preserve(struct liveupdate_file_handler *handler, > + struct file *file) > +{ > + return false; > +} > + > +static int vfio_pci_liveupdate_preserve(struct liveupdate_file_op_args *args) > +{ > + return -EOPNOTSUPP; > +} > + > +static void vfio_pci_liveupdate_unpreserve(struct liveupdate_file_op_args *args) > +{ > +} > + > +static int vfio_pci_liveupdate_retrieve(struct liveupdate_file_op_args *args) > +{ > + return -EOPNOTSUPP; > +} > + > +static void vfio_pci_liveupdate_finish(struct liveupdate_file_op_args *args) > +{ > +} > + > +static const struct liveupdate_file_ops vfio_pci_liveupdate_file_ops = { > + .can_preserve = vfio_pci_liveupdate_can_preserve, > + .preserve = vfio_pci_liveupdate_preserve, > + .unpreserve = vfio_pci_liveupdate_unpreserve, > + .retrieve = vfio_pci_liveupdate_retrieve, > + .finish = vfio_pci_liveupdate_finish, > + .owner = THIS_MODULE, > +}; > + > +static struct liveupdate_file_handler vfio_pci_liveupdate_fh = { > + .ops = &vfio_pci_liveupdate_file_ops, > + .compatible = VFIO_PCI_LUO_FH_COMPATIBLE, > +}; > + > +int __init vfio_pci_liveupdate_init(void) > +{ > + if (!liveupdate_enabled()) > + return 0; > + > + return liveupdate_register_file_handler(&vfio_pci_liveupdate_fh); > +} > + > +void vfio_pci_liveupdate_cleanup(void) > +{ > + if (!liveupdate_enabled()) > + return; > + > + liveupdate_unregister_file_handler(&vfio_pci_liveupdate_fh); > +} > diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h > index 27ac280f00b9..68966ec64e51 100644 > --- a/drivers/vfio/pci/vfio_pci_priv.h > +++ b/drivers/vfio/pci/vfio_pci_priv.h > @@ -133,4 +133,18 @@ static inline void vfio_pci_dma_buf_move(struct vfio_pci_core_device *vdev, > } > #endif > > +#ifdef CONFIG_LIVEUPDATE > +int __init vfio_pci_liveupdate_init(void); > +void vfio_pci_liveupdate_cleanup(void); > +#else > +static inline int vfio_pci_liveupdate_init(void) > +{ > + return 0; > +} > + > +static inline void vfio_pci_liveupdate_cleanup(void) > +{ > +} > +#endif /* CONFIG_LIVEUPDATE */ > + > #endif > diff --git a/include/linux/kho/abi/vfio_pci.h b/include/linux/kho/abi/vfio_pci.h > new file mode 100644 > index 000000000000..37a845eed972 > --- /dev/null > +++ b/include/linux/kho/abi/vfio_pci.h > @@ -0,0 +1,28 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +/* > + * Copyright (c) 2025, Google LLC. > + * Vipin Sharma > + * David Matlack > + */ > + > +#ifndef _LINUX_LIVEUPDATE_ABI_VFIO_PCI_H > +#define _LINUX_LIVEUPDATE_ABI_VFIO_PCI_H > + > +/** > + * DOC: VFIO PCI Live Update ABI > + * > + * This header defines the ABI for preserving the state of a VFIO PCI device > + * files across a kexec reboot using LUO. > + * > + * Device metadata is serialized into memory which is then handed to the next > + * kernel via KHO. > + * > + * This interface is a contract. Any modification to any of the serialization > + * structs defined here constitutes a breaking change. Such changes require > + * incrementing the version number in the VFIO_PCI_LUO_FH_COMPATIBLE string. > + */ > + > +#define VFIO_PCI_LUO_FH_COMPATIBLE "vfio-pci-v1" > + > +#endif /* _LINUX_LIVEUPDATE_ABI_VFIO_PCI_H */ -- Best Regards, Yanjun.Zhu