v6 2026-11-07

VFIO设备kexec热保留 · v6

为 noiommu vfio-pci 实现 LUO/KHO Live Update,跨 kexec 保持设备运行并由新内核接管 FD。

原始补丁链接

子 Patch(27)

1/27
vfio/pci: Factor out the reset logic in VFIO PCI device close path
从 vfio_pci_core_disable 提取复位逻辑为 vfio_pci_core_try_reset,供 VFIO Liveupdate 复用;disable 改调该 helper,无功能变化。
2/27
vfio: Export various helpers from VFIO
导出 vfio_device_from_file,并使 vfio_pci_ops 去 static、在头文件声明,供 vfio-pci 模块内 Liveupdate 使用;无功能变化。
3/27
liveupdate: Export symbols needed by modules
导出 liveupdate_register_file_handler 和 unregister,供可模块化的 vfio-pci Liveupdate 文件处理器注册/注销使用。
4/27
vfio/pci: Register a file handler with Live Update Orchestrator
新增 VFIO_PCI_LIVEUPDATE 与 vfio-pci LUO file handler,注册必需空回调并接入 liveupdate/PCI;先支持 no-iommu,为跨 kexec 保持设备运行铺路。
5/27
PCI: liveupdate: Add helpers to preserve struct pci_saved_state
On Mon, Nov 02, 2026 at 07:36:34AM -0800, Vipin Sharma wrote: > Drivers that keep a device running across Live Update need to hand the > state they captured with pci_store_saved_state() to the next ke
6/27
vfio: Add helpers to identify device files that can be preserved
新增 vfio_file_is_bound_cdev 判断绑定 iommufd 的 cdev 文件,并导出 vfio_device_is_noiommu,供 vfio-pci 限定仅 no-iommu 设备可保留。
7/27
vfio/pci: Preserve vfio-pci device files across Live Update
实现 vfio-pci 的 preserve/freeze 回调:校验 bound cdev 与 no-iommu,将 domain/BDF/config、reset_works、pci_saved_state 序列化到 KHO 保留页,供跨 kexec 保持设备。
8/27
vfio: Introduce vfio_find_device() helper
新增 vfio_find_device,按 class 条件查找并取 registration 引用,避免仅持 kref 导致模块卸载 UAF;提前初始化 refcount,失败路径等待并发 lookup 排空。
9/27
vfio: Refactor vfio_device_fops_cdev_open()
将 vfio_device_fops_cdev_open 拆出静态 helper vfio_device_cdev_open,供后续 Live Update 恢复时重新打开设备文件使用;无功能变化。
10/27
vfio: Add API to open cdev device for Live Update restore
提供 VFIO Live Update 恢复用 API,用匿名 inode 创建并返回 cdev 设备文件上下文,重建 kexec 前的 file 状态。
11/27
vfio/pci: Retrieve preserved device files after Live Update
Enable userspace to retrieve preserved VFIO device files after a Live Update by implementing the retrieve() and finish() file handler callbacks. During retrieve(): * Validate the handed-over struct
12/27
vfio: Enforce preserved devices are retrieved via LIVEUPDATE_SESSION_RETRIEVE_FD
From: David Matlack dmatlack@google.com Enforce that files for incoming (preserved by previous kernel) VFIO devices are retrieved via LIVEUPDATE_SESSION_RETRIEVE_FD rather than by opening the corre
13/27
vfio/pci: Protect incoming preserved devices until they finish Live Update
Protect incoming preserved devices that were kept running across kexec from being disturbed before userspace either claims them or finishes the Live Update session: * Runtime PM idle D3: In vfio_pci
14/27
vfio/pci: Take over preserved devices without resetting them
When userspace binds a retrieved VFIO cdev file descriptor via VFIO_DEVICE_BIND_IOMMUFD after kexec, take over the running device in vfio_pci_core_enable() via vfio_pci_liveupdate_take_over() without
15/27
docs: liveupdate: Add documentation for VFIO PCI
From: David Matlack dmatlack@google.com Add documentation for preserving VFIO device files across a Live Update, generated from the kernel-doc comments in the code. Signed-off-by: David Matlack <d
16/27
vfio: selftests: Build liveupdate library in VFIO selftests
Import and build liveupdate selftest library in VFIO selftests. It allows using liveupdate ioctls in VFIO selftests Co-developed-by: David Matlack dmatlack@google.com Signed-off-by: David Matlack
17/27
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
From: David Matlack dmatlack@google.com Add a selftest to exercise preserving various VFIO files through /dev/liveupdate. Only the VFIO cdev files of devices in noiommu mode can be preserved. Ensur
18/27
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
Use the given VFIO cdev FD to initialize vfio_pci_device in VFIO selftests. Add the assertion to make sure that passed cdev FD is not used with legacy VFIO APIs. If VFIO cdev FD is provided then do no
19/27
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
From: David Matlack dmatlack@google.com Add Makefile support for TEST_GEN_PROGS_EXTENDED targets. These tests are not run by default. TEST_GEN_PROGS_EXTENDED will be used for Live Update selftests
20/27
vfio: selftests: Add iommufd noiommu mode
Add an opt-in iommufd_noiommu mode (MODE_IOMMUFD_NOIOMMU) for devices bound to vfio-pci in noiommu mode. When a device is in noiommu mode, its VFIO character device is named /dev/vfio/devices/noiommu-
21/27
vfio: selftests: Add helpers to map DMA memory at IOVA == PA in noiommu mode
Selftest drivers program the IOVA returned by to_iova() into the device. Because a device in noiommu mode uses those addresses directly as physical addresses, DMA buffers must be mapped at IOVA == PA
22/27
vfio: selftests: Add helpers for Live Update DMA memory and sysfs state
Add shared libvfio helpers used by the Live Update kexec selftest: - vfio_thp_memfd_alloc() and vfio_memfd_mmap_aligned() to allocate a shmem memfd, map it at a 2MB-aligned virtual address, and b
23/27
vfio: selftests: Add an attach() driver op
Add a new attach() op to vfio_pci_driver_ops and a corresponding vfio_pci_driver_attach() wrapper to adopt a device that was already initialized (and optionally has memcpy operations in flight) in ano
24/27
vfio: selftests: Test preserving noiommu devices in vfio_pci_liveupdate_uapi_test
Add the iommufd_noiommu fixture variant to vfio_pci_liveupdate_uapi_test and detect at startup whether the target device is bound to vfio-pci in noiommu mode so that variants not matching the device c
25/27
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Add a selftest to exercise preserving a vfio-pci device in noiommu mode across a Live Update. For now the test is simple and verifies that the device file can be preserved, retrieved, and bound to iom
26/27
vfio: selftests: Verify that opening VFIO device fails during Live Update
Verify that opening a VFIO device through its cdev file and via VFIO_GROUP_GET_DEVICE_FD both fail with -EBUSY if the device was preserved across a Live Update. When a device file is preserved across
27/27
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Extend vfio_pci_liveupdate_kexec_test to exercise continuous DMA across a Live Update when the device is in noiommu mode. Allocate a shmem memfd backed by three 2MB THP folios (for the driver region,