1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2025, Google LLC.
* Pasha Tatashin <pasha.tatashin@soleen.com>
*/
/**
* DOC: Live Update Orchestrator (LUO)
*
* Live Update is a specialized, kexec-based reboot process that allows a
* running kernel to be updated from one version to another while preserving
* the state of selected resources and keeping designated hardware devices
* operational. For these devices, DMA activity may continue throughout the
* kernel transition.
*
* While the primary use case driving this work is supporting live updates of
* the Linux kernel when it is used as a hypervisor in cloud environments, the
* LUO framework itself is designed to be workload-agnostic. Live Update
* facilitates a full kernel version upgrade for any type of system.
*
* For example, a non-hypervisor system running an in-memory cache like
* memcached with many gigabytes of data can use LUO. The userspace service
* can place its cache into a memfd, have its state preserved by LUO, and
* restore it immediately after the kernel kexec.
*
* Whether the system is running virtual machines, containers, a
* high-performance database, or networking services, LUO's primary goal is to
* enable a full kernel update by preserving critical userspace state and
* keeping essential devices operational.
*
* The core of LUO is a mechanism that tracks the progress of a live update,
* along with a callback API that allows other kernel subsystems to participate
* in the process. Example subsystems that can hook into LUO include: kvm,
* iommu, interrupts, vfio, participating filesystems, and memory management.
*
* LUO uses Kexec Handover to transfer memory state from the current kernel to
* the next kernel. For more details see
* Documentation/core-api/kho/concepts.rst.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kobject.h>
#include <linux/liveupdate.h>
#include <linux/miscdevice.h>
static struct {
bool enabled;
} luo_global;
static int __init early_liveupdate_param(char *buf)
{
return kstrtobool(buf, &luo_global.enabled);
}
early_param("liveupdate", early_liveupdate_param);
/* Public Functions */
/**
* liveupdate_reboot() - Kernel reboot notifier for live update final
* serialization.
*
* This function is invoked directly from the reboot() syscall pathway
* if kexec is in progress.
*
* If any callback fails, this function aborts KHO, undoes the freeze()
* callbacks, and returns an error.
*/
int liveupdate_reboot(void)
{
return 0;
}
/**
* liveupdate_enabled - Check if the live update feature is enabled.
*
* This function returns the state of the live update feature flag, which
* can be controlled via the ``liveupdate`` kernel command-line parameter.
*
* @return true if live update is enabled, false otherwise.
*/
bool liveupdate_enabled(void)
{
return luo_global.enabled;
}
struct luo_device_state {
struct miscdevice miscdev;
};
static const struct file_operations luo_fops = {
.owner = THIS_MODULE,
};
static struct luo_device_state luo_dev = {
.miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "liveupdate",
.fops = &luo_fops,
},
};
static int __init liveupdate_ioctl_init(void)
{
if (!liveupdate_enabled())
return 0;
return misc_register(&luo_dev.miscdev);
}
late_initcall(liveupdate_ioctl_init);
|