Commit Graph
4 Commits
Author SHA1 Message Date
Pasha Tatashin 16cec0d265 liveupdate: luo_session: add ioctls for file preservation
Introducing the userspace interface and internal logic required to manage
the lifecycle of file descriptors within a session.  Previously, a session
was merely a container; this change makes it a functional management unit.

The following capabilities are added:

A new set of ioctl commands are added, which operate on the file
descriptor returned by CREATE_SESSION. This allows userspace to:
- LIVEUPDATE_SESSION_PRESERVE_FD: Add a file descriptor to a session
  to be preserved across the live update.
- LIVEUPDATE_SESSION_RETRIEVE_FD: Retrieve a preserved file in the
  new kernel using its unique token.
- LIVEUPDATE_SESSION_FINISH: finish session

The session's .release handler is enhanced to be state-aware.  When a
session's file descriptor is closed, it correctly unpreserves the session
based on its current state before freeing all associated file resources.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Pasha Tatashin <[email protected]>
Reviewed-by: Pratyush Yadav <[email protected]>
Reviewed-by: Mike Rapoport (Microsoft) <[email protected]>
Tested-by: David Matlack <[email protected]>
Cc: Aleksander Lobakin <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: Alice Ryhl <[email protected]>
Cc: Andriy Shevchenko <[email protected]>
Cc: anish kumar <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Borislav Betkov <[email protected]>
Cc: Chanwoo Choi <[email protected]>
Cc: Chen Ridong <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Daniel Wagner <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: David Jeffery <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Guixin Liu <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Ilpo Järvinen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ira Weiny <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Joanthan Cameron <[email protected]>
Cc: Joel Granados <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Lennart Poettering <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Marc Rutland <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Matthew Maurer <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Cc: Myugnjoo Ham <[email protected]>
Cc: Parav Pandit <[email protected]>
Cc: Pratyush Yadav <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Saeed Mahameed <[email protected]>
Cc: Samiullah Khawaja <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Stuart Hayes <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Thomas Gleinxer <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: Vincent Guittot <[email protected]>
Cc: William Tu <[email protected]>
Cc: Yoann Congal <[email protected]>
Cc: Zhu Yanjun <[email protected]>
Cc: Zijun Hu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-11-27 14:24:39 -08:00
Pasha Tatashin 81cd25d263 liveupdate: luo_core: add user interface
Introduce the user-space interface for the Live Update Orchestrator via
ioctl commands, enabling external control over the live update process and
management of preserved resources.

The idea is that there is going to be a single userspace agent driving the
live update, therefore, only a single process can ever hold this device
opened at a time.

The following ioctl commands are introduced:

LIVEUPDATE_IOCTL_CREATE_SESSION
Provides a way for userspace to create a named session for grouping file
descriptors that need to be preserved. It returns a new file descriptor
representing the session.

LIVEUPDATE_IOCTL_RETRIEVE_SESSION
Allows the userspace agent in the new kernel to reclaim a preserved
session by its name, receiving a new file descriptor to manage the
restored resources.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Pasha Tatashin <[email protected]>
Reviewed-by: Mike Rapoport (Microsoft) <[email protected]>
Reviewed-by: Pratyush Yadav <[email protected]>
Tested-by: David Matlack <[email protected]>
Cc: Aleksander Lobakin <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: Alice Ryhl <[email protected]>
Cc: Andriy Shevchenko <[email protected]>
Cc: anish kumar <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Borislav Betkov <[email protected]>
Cc: Chanwoo Choi <[email protected]>
Cc: Chen Ridong <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Daniel Wagner <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: David Jeffery <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Guixin Liu <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Ilpo Järvinen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ira Weiny <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Joanthan Cameron <[email protected]>
Cc: Joel Granados <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Lennart Poettering <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Marc Rutland <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Matthew Maurer <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Cc: Myugnjoo Ham <[email protected]>
Cc: Parav Pandit <[email protected]>
Cc: Pratyush Yadav <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Saeed Mahameed <[email protected]>
Cc: Samiullah Khawaja <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Stuart Hayes <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Thomas Gleinxer <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: Vincent Guittot <[email protected]>
Cc: William Tu <[email protected]>
Cc: Yoann Congal <[email protected]>
Cc: Zhu Yanjun <[email protected]>
Cc: Zijun Hu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-11-27 14:24:38 -08:00
Pasha Tatashin 0153094d03 liveupdate: luo_session: add sessions support
Introduce concept of "Live Update Sessions" within the LUO framework.  LUO
sessions provide a mechanism to group and manage `struct file *` instances
(representing file descriptors) that need to be preserved across a
kexec-based live update.

Each session is identified by a unique name and acts as a container for
file objects whose state is critical to a userspace workload, such as a
virtual machine or a high-performance database, aiming to maintain their
functionality across a kernel transition.

This groundwork establishes the framework for preserving file-backed state
across kernel updates, with the actual file data preservation mechanisms
to be implemented in subsequent patches.

[[email protected]: fix use after free in luo_session_deserialize()]
  Link: https://lkml.kernel.org/r/c5dd637d7eed3a3be48c5e9fedb881596a3b1f5a.1764163896.git.dan.carpenter@linaro.org
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Pasha Tatashin <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Mike Rapoport (Microsoft) <[email protected]>
Reviewed-by: Pratyush Yadav <[email protected]>
Tested-by: David Matlack <[email protected]>
Cc: Aleksander Lobakin <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: Alice Ryhl <[email protected]>
Cc: Andriy Shevchenko <[email protected]>
Cc: anish kumar <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Borislav Betkov <[email protected]>
Cc: Chanwoo Choi <[email protected]>
Cc: Chen Ridong <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Daniel Wagner <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: David Jeffery <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Guixin Liu <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Ilpo Järvinen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ira Weiny <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Joanthan Cameron <[email protected]>
Cc: Joel Granados <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Lennart Poettering <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Marc Rutland <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Matthew Maurer <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Cc: Myugnjoo Ham <[email protected]>
Cc: Parav Pandit <[email protected]>
Cc: Pratyush Yadav <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Saeed Mahameed <[email protected]>
Cc: Samiullah Khawaja <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Stuart Hayes <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Thomas Gleinxer <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: Vincent Guittot <[email protected]>
Cc: William Tu <[email protected]>
Cc: Yoann Congal <[email protected]>
Cc: Zhu Yanjun <[email protected]>
Cc: Zijun Hu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-11-27 14:24:38 -08:00
Pasha Tatashin 9e2fd062fa liveupdate: luo_core: Live Update Orchestrator
Patch series "Live Update Orchestrator", v8.

This series introduces the Live Update Orchestrator, a kernel subsystem
designed to facilitate live kernel updates using a kexec-based reboot. 
This capability is critical for cloud environments, allowing hypervisors
to be updated with minimal downtime for running virtual machines.  LUO
achieves this by preserving the state of selected resources, such as
memory, devices and their dependencies, across the kernel transition.

As a key feature, this series includes support for preserving memfd file
descriptors, which allows critical in-memory data, such as guest RAM or
any other large memory region, to be maintained in RAM across the kexec
reboot.

The other series that use LUO, are VFIO [1], IOMMU [2], and PCI [3]
preservations.

Github repo of this series [4].

The core of LUO is a framework for managing the lifecycle of preserved
resources through a userspace-driven interface. Key features include:

- Session Management
  Userspace agent (i.e. luod [5]) creates named sessions, each
  represented by a file descriptor (via centralized agent that controls
  /dev/liveupdate). The lifecycle of all preserved resources within a
  session is tied to this FD, ensuring automatic kernel cleanup if the
  controlling userspace agent crashes or exits unexpectedly.

- File Preservation
  A handler-based framework allows specific file types (demonstrated
  here with memfd) to be preserved. Handlers manage the serialization,
  restoration, and lifecycle of their specific file types.

- File-Lifecycle-Bound State
  A new mechanism for managing shared global state whose lifecycle is
  tied to the preservation of one or more files. This is crucial for
  subsystems like IOMMU or HugeTLB, where multiple file descriptors may
  depend on a single, shared underlying resource that must be preserved
  only once.

- KHO Integration
  LUO drives the Kexec Handover framework programmatically to pass its
  serialized metadata to the next kernel. The LUO state is finalized and
  added to the kexec image just before the reboot is triggered. In the
  future this step will also be removed once stateless KHO is
  merged [6].

- Userspace Interface
  Control is provided via ioctl commands on /dev/liveupdate for creating
  and retrieving sessions, as well as on session file descriptors for
  managing individual files.

- Testing
  The series includes a set of selftests, including userspace API
  validation, kexec-based lifecycle tests for various session and file
  scenarios, and a new in-kernel test module to validate the FLB logic.




Introduce LUO, a mechanism intended to facilitate kernel updates while
keeping designated devices operational across the transition (e.g., via
kexec).  The primary use case is updating hypervisors with minimal
disruption to running virtual machines.  For userspace side of hypervisor
update we have copyless migration.  LUO is for updating the kernel.

This initial patch lays the groundwork for the LUO subsystem.

Further functionality, including the implementation of state transition
logic, integration with KHO, and hooks for subsystems and file
descriptors, will be added in subsequent patches.

Create a character device at /dev/liveupdate.

A new uAPI header, <uapi/linux/liveupdate.h>, will define the necessary
structures.  The magic number for IOCTL is registered in
Documentation/userspace-api/ioctl/ioctl-number.rst.

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lore.kernel.org/all/[email protected]/ [1]
Link: https://lore.kernel.org/linux-iommu/[email protected] [2]
Link: https://lore.kernel.org/linux-pci/[email protected] [3]
Link: https://github.com/googleprodkernel/linux-liveupdate/tree/luo/v8 [4]
Link: https://tinyurl.com/luoddesign [5]
Link: https://lore.kernel.org/all/[email protected] [6]
Link: https://lore.kernel.org/all/[email protected] [7]
Link: https://github.com/soleen/linux/blob/luo/v8b03/diff.v7.v8 [8]
Signed-off-by: Pasha Tatashin <[email protected]>
Reviewed-by: Pratyush Yadav <[email protected]>
Reviewed-by: Mike Rapoport (Microsoft) <[email protected]>
Tested-by: David Matlack <[email protected]>
Cc: Aleksander Lobakin <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: Alice Ryhl <[email protected]>
Cc: Andriy Shevchenko <[email protected]>
Cc: anish kumar <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: Borislav Betkov <[email protected]>
Cc: Chanwoo Choi <[email protected]>
Cc: Chen Ridong <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Daniel Wagner <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: David Jeffery <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Guixin Liu <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Ilpo Järvinen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ira Weiny <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Joanthan Cameron <[email protected]>
Cc: Joel Granados <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Lennart Poettering <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: Lukas Wunner <[email protected]>
Cc: Marc Rutland <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Matthew Maurer <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Cc: Myugnjoo Ham <[email protected]>
Cc: Parav Pandit <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Saeed Mahameed <[email protected]>
Cc: Samiullah Khawaja <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Stuart Hayes <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Thomas Gleinxer <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: Vincent Guittot <[email protected]>
Cc: William Tu <[email protected]>
Cc: Yoann Congal <[email protected]>
Cc: Zijun Hu <[email protected]>
Cc: Pratyush Yadav <[email protected]>
Cc: Zhu Yanjun <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-11-27 14:24:37 -08:00