From nobody Sat Feb 7 04:47:31 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 387CF340273 for ; Wed, 26 Nov 2025 19:36:18 +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=1764185780; cv=none; b=bjUe54BRT0lK/UIZZZYZmpNgRq+C7qw34ebpE0y8VF7YQDX8jqSl+iCSbNbaWM7qEssTOr70sDIsP15WIBxTyHX6QYtFQEidhwA3R1kF0wOTmyK3y+mSOzEv2I71JvpHsC+8d5Tjt05nMZ9ombOeyDwu6YBLTV0GzyPiJIMGEJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764185780; c=relaxed/simple; bh=MdHEo5JlzB38kfrUS/yfJXxeBIf14QgYazV3eFOuYps=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Cko+O+mY3NPs/sh0ImNqhCkpkC4AOiA5Ul4jHfaaA/CezXC973h/pPKLF2IRZxtrulK5U4RBdvZjoaSwm6dj9ewa17m0E882wDd+s6/5P0zIhRx5/XYNInWlJ3S3UeKCYKf0roRDwoY0xkZohXeH9L9y34U6N0pLsauJbpyKKNg= 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=z3gtCNHc; 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="z3gtCNHc" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-7a99a5f77e0so94811b3a.2 for ; Wed, 26 Nov 2025 11:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764185777; x=1764790577; 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=BAvCfHwQMnOs+cOiqWeL0elvv18GHJNsZ1eh/Y/HY0A=; b=z3gtCNHcf+fM7LoIsD3FuDVUkbiRFI6nYpU1cqvbOngvIsVwW3x+OZIFk5ANo94SMy yYlNgAtL2bsUiT34YMLA6criqC0v6i5Fhe2Sf6QgtQRY47fEeBBzodgDtCnAEHpuQcqT C/4Dw2dEVHOZbTSdikhSxybcswAK90d2ZxQ8vTg7kav1qWPkxJ7i0F/iJuvgmrpyOp3M 0WTbAOqHM4gKLfbgpiEOVU1p3IAEqX5JKUqujVf5Zq2DVLbjH0BJv/+XFyxza8PGr27R 6V9HjKd4GJNRVtCd8truRTaeZWSiXkYY/vt8vOCx1hX0YqC+X6sW9X9VMZprMoGlKzwJ DbTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764185777; x=1764790577; 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=BAvCfHwQMnOs+cOiqWeL0elvv18GHJNsZ1eh/Y/HY0A=; b=NBJotHYccoOz1q1Pd19FOVH730OquuqR9qbCq18aFHukadOTEjVKtHW9Qa5vuju1qk W94jJRgfAtmJFnUhiKwgXOvAifgB7AByfQR7Anq6gVUMLQ7NtbMXu3s/mnQppjMYG0V1 mBcRbgXuOfmbsisgxtOnIIHqfs4S68SgkbC+ZBZnHBUNJJrjlhx8nKnJb70aQjXejHeU HnExjoGNH8QBg+sSPI3BeenxvIrIW0Ki49JlFWZOmMJrmR8gS2a/R0ygLCCJRUUJefSp fNwJDqYB63PHJx8uyaQ2KFj9TnfzySnxd3GvHbbbvnm5FaLFq2uuQRh2YDlEX2SjjTZ+ qxjg== X-Forwarded-Encrypted: i=1; AJvYcCU6E34rXBmCv22Z74cK1JOZx5MVWgbuFiUveHDy7Tqp4L9hWle0a5/sApQlJJYQ37dWaYQlYjO4ALUvRfY=@vger.kernel.org X-Gm-Message-State: AOJu0YzLDtV8KLQRMpQ3bBtqlA0UZiBC6i0zKyNI4QkinEt3CTpUjIw2 fFozVRZCNvGsGFYQoThGN9JEnA2sLRp5iRzG80EvGIUXHuOAuYyLJQlUUGTTQeGa8IOee77dT9D +gSX2plhTQ138JQ== X-Google-Smtp-Source: AGHT+IG+xXSTrXQR9csQs3WCqwSJan5Af+yQylnVLM5oBb0LBhg+2VUH2UWT8kYvjS2p2mBfoZH/ozR1D/SXjA== X-Received: from pfbna23.prod.google.com ([2002:a05:6a00:3e17:b0:7b9:7dd0:134d]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:17a3:b0:7b8:349:1b24 with SMTP id d2e1a72fcca58-7c58e116e23mr20953003b3a.22.1764185777352; Wed, 26 Nov 2025 11:36:17 -0800 (PST) Date: Wed, 26 Nov 2025 19:35:51 +0000 In-Reply-To: <20251126193608.2678510-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: <20251126193608.2678510-1-dmatlack@google.com> X-Mailer: git-send-email 2.52.0.487.g5c8c507ade-goog Message-ID: <20251126193608.2678510-5-dmatlack@google.com> Subject: [PATCH 04/21] vfio/pci: Register a file handler with Live Update Orchestrator From: David Matlack To: Alex Williamson Cc: Adithya Jayachandran , Alex Mastro , Alistair Popple , Andrew Morton , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Josh Hilke , Kevin Tian , kvm@vger.kernel.org, Leon Romanovsky , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-pci@vger.kernel.org, Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Philipp Stanner , Pratyush Yadav , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Tomita Moeko , Vipin Sharma , William Tu , Yi Liu , Yunxiang Li , Zhu Yanjun Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 2722f98d0ed7..ff50977277c4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26933,6 +26933,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 cf00c0a7e55c..929df22c079b 100644 --- a/drivers/vfio/pci/Makefile +++ b/drivers/vfio/pci/Makefile @@ -2,6 +2,7 @@ =20 vfio-pci-core-y :=3D vfio_pci_core.o vfio_pci_intrs.o vfio_pci_rdwr.o vfio= _pci_config.o vfio-pci-core-$(CONFIG_VFIO_PCI_ZDEV_KVM) +=3D vfio_pci_zdev.o +vfio-pci-core-$(CONFIG_LIVEUPDATE) +=3D vfio_pci_liveupdate.o obj-$(CONFIG_VFIO_PCI_CORE) +=3D vfio-pci-core.o =20 vfio-pci-y :=3D vfio_pci.o diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index ac10f14417f2..c2fe34a830d8 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -252,6 +252,10 @@ static int __init vfio_pci_init(void) int ret; bool is_disable_vga =3D true; =20 + ret =3D vfio_pci_liveupdate_init(); + if (ret) + return ret; + #ifdef CONFIG_VFIO_PCI_VGA is_disable_vga =3D disable_vga; #endif @@ -260,8 +264,10 @@ static int __init vfio_pci_init(void) =20 /* Register and scan for devices */ ret =3D pci_register_driver(&vfio_pci_driver); - if (ret) + if (ret) { + vfio_pci_liveupdate_cleanup(); return ret; + } =20 vfio_pci_fill_ids(); =20 @@ -275,6 +281,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); =20 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. + * 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_handle= r *handler, + struct file *file) +{ + return false; +} + +static int vfio_pci_liveupdate_preserve(struct liveupdate_file_op_args *ar= gs) +{ + 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 *ar= gs) +{ + return -EOPNOTSUPP; +} + +static void vfio_pci_liveupdate_finish(struct liveupdate_file_op_args *arg= s) +{ +} + +static const struct liveupdate_file_ops vfio_pci_liveupdate_file_ops =3D { + .can_preserve =3D vfio_pci_liveupdate_can_preserve, + .preserve =3D vfio_pci_liveupdate_preserve, + .unpreserve =3D vfio_pci_liveupdate_unpreserve, + .retrieve =3D vfio_pci_liveupdate_retrieve, + .finish =3D vfio_pci_liveupdate_finish, + .owner =3D THIS_MODULE, +}; + +static struct liveupdate_file_handler vfio_pci_liveupdate_fh =3D { + .ops =3D &vfio_pci_liveupdate_file_ops, + .compatible =3D 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_p= riv.h index a9972eacb293..b9f7c4e2b4df 100644 --- a/drivers/vfio/pci/vfio_pci_priv.h +++ b/drivers/vfio/pci/vfio_pci_priv.h @@ -107,4 +107,18 @@ static inline bool vfio_pci_is_vga(struct pci_dev *pde= v) return (pdev->class >> 8) =3D=3D PCI_CLASS_DISPLAY_VGA; } =20 +#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 devi= ce + * files across a kexec reboot using LUO. + * + * Device metadata is serialized into memory which is then handed to the n= ext + * kernel via KHO. + * + * 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 VFIO_PCI_LUO_FH_COMPATIBLE strin= g. + */ + +#define VFIO_PCI_LUO_FH_COMPATIBLE "vfio-pci-v1" + +#endif /* _LINUX_LIVEUPDATE_ABI_VFIO_PCI_H */ --=20 2.52.0.487.g5c8c507ade-goog