riscv: Enable kexec handover and live update
Subsystems (5)
v4 cover riscv: Enable kexec handover and live update
Host kernel updates in the cloud should not require draining the
machine: next to live migration to another host, replacing the kernel in place while preserving selected workload state ("live update") is what KHO/LUO were built for, and LUO's documentation names hypervisor hosts as its primary use case. This series closes the gap for riscv64 and validates it with both upstream test runners.
KHO has been architecture independent since it was merged: the outgoing kernel publishes the handover FDT and the bootmem descriptor array in the /chosen node of the DTB it builds for the incoming kernel, and the incoming kernel collects both while scanning that node -- which is why the arm64 integration (commit 274cdcb1c004) needed only three lines of arch code.
RISC-V already walks those generic paths. The blocker is ordering:setup_arch() runs early_ioremap_setup() after parse_dtb(), so the early mapping kho_populate() needs for the handover FDT is not set up yet and the handover is dropped. Patch 1 fixes that ordering and stands on its own regardless of KHO. Patch 2 enables ARCH_SUPPORTS_KEXEC_HANDOVER as "def_bool 64BIT && MMU" rather than arm64's "def_bool y":ARCH_SUPPORTS_KEXEC_FILE is already 64BIT only, and KEXEC_HANDOVER selects CMA, which depends on MMU. LIVEUPDATE depends only on KEXEC_HANDOVER, so patch 2 makes it selectable on riscv as well. Patches 3 and 4 teach the two upstream vmtest runners about riscv64.
This base already contains Greg Thelen's is_kho_boot() fix [1] and Mike Rapoport's bootmem sizing rework [2], so the series carries no generic KHO changes and neither patch is needed on top.
No DT schema changes are needed: linux,kho-fdt / linux,kho-bootmem are the properties arm64 introduced (commit 274cdcb1c004), and their binding lives in the external dt-schema repository [3] rather than in Documentation.
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/kexec/[email protected]/
[3] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/chosen.yaml
Changes since v3:
- Dropped the arm64/x86 comparison from patch 1 and this cover letter.
- Renamed patch 2 to "riscv: Add support for KHO" and spelled out the acronym on first use in its body.
- Dropped the dependency note; both generic fixes are in this base.
- Collected Reviewed-by and Acked-by tags.
- Rebased onto linux-next-20261117 (7cfbf79c66c6).
Changes since v2:
- Dropped "kho: Do not translate the handover FDT address in is_kho_boot()", which Greg Thelen's fix does as well.
- Commit messages cut back to the reason for the change.
- Rebased onto linux-next-20261105 (ddfe51b0a0f5).
Changes since v1:
- New patch 1: kho: Do not translate the handover FDT address in is_kho_boot(), a generic fix the riscv enablement needs.
- Rebased onto linux-next-20261102 (2637bdec0535).
Test
----
Testing on linux-next-20261117 (7cfbf79c66c6) with qemu-system-riscv64 (virt, -cpu max, TCG); method and logs under the --- of patches 3 and 4:
- kho vmtest: "ok 1 KHO succeeded", Totals pass:1 fail:0
- liveupdate vmtest, all four suites passed one by one (simple,
multi-session, 500 files, 2000 sessions)
- riscv defconfig with and without CONFIG_KEXEC_HANDOVER both boot to
userspace with no oops on the console; builds: riscv defconfig
(+KHO), rv32_defconfig, arm64 defconfig (+KHO), x86_64 defconfig
(+KHO) - UEFI handover boot (edk2 on pflash over OpenSBI fw_dynamic, DEBUG_VIRTUAL=y): 28 consecutive handovers and no BUG
Additionally, a workload-continuity test was run outside the selftests:
a counter process was snapshot with criu 4.3, the dump was carried across the kexec in an LUO-preserved memfd, and criu restored it in the new kernel. The process resumed with the same PID and open log file and kept counting from where it was dumped (500006 -> 500007, no lost or duplicated ticks).
Chen Pei (4):
riscv: Call early_ioremap_setup() before parsing the DTB
riscv: Add support for KHO
selftests: kho: Add riscv support
selftests: liveupdate: Add riscv support
arch/riscv/Kconfig | 3 +++ arch/riscv/kernel/setup.c | 2 +- tools/testing/selftests/kho/riscv.conf | 9 +++++++++ tools/testing/selftests/kho/vmtest.sh | 3 ++- tools/testing/selftests/liveupdate/config.riscv64 | 3 +++ tools/testing/selftests/liveupdate/run-vmtests.sh | 2 +- tools/testing/selftests/liveupdate/vmtest.sh | 8 +++++++- 7 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tools/testing/selftests/kho/riscv.conf create mode 100644 tools/testing/selftests/liveupdate/config.riscv64
base-commit: 7cfbf79c66c63e807ea452abf0546e6f6d6833a6
Signature · 1 line
2.50.1
PATCH v4 1/4 riscv: Call early_ioremap_setup() before parsing the DTB
parse_dtb() can reach early_memremap(), whose return value is composed from the slot table that early_ioremap_setup() fills in - and on RISC-V that setup ran after the scan, so the mapping came back NULL. The DT based kexec handover parsing is the first caller to hit this:kho_populate() cannot map the handover FDT and the handover is dropped.
Run early_ioremap_setup() before the DT is parsed.
--- arch/riscv/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/setup.c +1 -1
@@ -308,12 +308,12 @@ extern void __init init_rt_signal_env(void);void __init setup_arch (char **cmdline_p) { +early_ioremap_setup ();parse_dtb ();setup_initial_init_mm (_stext, _etext, _edata, _end); *cmdline_p = boot_command_line; -early_ioremap_setup ();sbi_init ();jump_label_init ();parse_early_param ();
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v4 1/4] riscv: Call early_ioremap_setup() before parsing the DTB
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
parse_dtb()can reachearly_memremap(), whose return value is composed from the slot table thatearly_ioremap_setup()fills in - and on RISC-V that setup ran after the scan, so the mapping came back NULL. The DT based kexec handover parsing is the first caller to hit this:kho_populate()cannot map the handover FDT and the handover is dropped.Run
early_ioremap_setup()before the DT is parsed.Signed-off-by Chen Pei <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v4 2/4 riscv: Add support for KHO
In reply to Chen PeiThe generic kexec handover (KHO) paths are already in place on RISC-V:
the outgoing kernel publishes the handover FDT and the bootmem list in /chosen of the DTB built by of_kexec_alloc_and_setup_fdt(), and the incoming kernel picks both up while scanning that node. Only the architecture symbol is missing.
Set it to 64BIT && MMU: ARCH_SUPPORTS_KEXEC_FILE is already 64BIT only, and KEXEC_HANDOVER selects CMA, which depends on MMU.
--- arch/riscv/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
arch/riscv/Kconfig +3 -0
@@ -1125,6 +1125,9 @@ config ARCH_SELECTS_KEXEC_FILE config ARCH_SUPPORTS_KEXEC_PURGATORY def_bool ARCH_SUPPORTS_KEXEC_FILE +config ARCH_SUPPORTS_KEXEC_HANDOVER + def_bool 64BIT && MMU + config ARCH_SUPPORTS_CRASH_DUMP def_bool y
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v4 2/4] riscv: Add support for KHO
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
The generic kexec handover (KHO) paths are already in place on RISC-V:
the outgoing kernel publishes the handover FDT and the bootmem list in /chosen of the DTB built byof_kexec_alloc_and_setup_fdt(), and the incoming kernel picks both up while scanning that node. Only the architecture symbol is missing.Set it to 64BIT && MMU:
ARCH_SUPPORTS_KEXEC_FILEis already 64BIT only, andKEXEC_HANDOVERselects CMA, which depends on MMU.Signed-off-by Chen Pei <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH v4 3/4 selftests: kho: Add riscv support
In reply to Chen PeiDescribe the machine the KHO vmtest runner needs to boot riscv64, so the test stops being skipped on this architecture.
---
Test: qemu-system-riscv64 (virt, -cpu max, TCG), in-tree runner "tools/testing/selftests/kho/vmtest.sh -t riscv64" (boots the Image and kexec'es into the same Image).
KHO: found kexec handover data.
test_kho: KHO restore succeeded
ok 1 KHO succeeded
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
tools/testing/selftests/kho/riscv.conf | 9 +++++++++ tools/testing/selftests/kho/vmtest.sh | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/kho/riscv.conf
tools/testing/selftests/kho/riscv.conf new file +9 -0
@@ -0,0 +1,9 @@ +QEMU_CMD="qemu-system-riscv64 -M virt -cpu max" +QEMU_KCONFIG=" +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y +CONFIG_SPARSEMEM_MANUAL=y +" +KERNEL_IMAGE="Image" +KERNEL_CMDLINE="console=ttyS0"
tools/testing/selftests/kho/vmtest.sh +2 -1
@@ -21,7 +21,7 @@ Options: -d) path to the kernel build directory -j) number of jobs for compilation, similar to -j in make -t) run test for target_arch, requires CROSS_COMPILE set - supported targets: aarch64, x86_64 + supported targets: aarch64, x86_64, riscv64 -h) display this help EOF }
@@ -127,6 +127,7 @@ function target_to_arch() { case $target in aarch64) echo "arm64" ;; x86_64) echo "x86" ;; + riscv64) echo "riscv" ;; *) skip "architecture $target is not supported" esac }
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v4 3/4] selftests: kho: Add riscv support
Sashiko has reviewed this patch and found no issues.
Quoted 4 lines
Describe the machine the KHO vmtest runner needs to boot riscv64, so the test stops being skipped on this architecture.
Signed-off-by Chen Pei <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v4 4/4 selftests: liveupdate: Add riscv support
In reply to Chen PeiTeach the live update vmtest runners about riscv64, so the LUO tests can be run on this architecture.
LIVEUPDATE depends only on KEXEC_HANDOVER, enabled for riscv64 by the previous commit, so nothing in the tests stood in the way.
---
Test: qemu-system-riscv64 (virt, -cpu max, -m 1G, -smp 2, TCG), in-tree runner "tools/testing/selftests/liveupdate/vmtest.sh -t riscv64 -T <suite>", all four suites:
ok 1 luo_kexec_simple succeeded
ok 1 luo_multi_session succeeded
ok 1 luo_stress_files succeeded
ok 1 luo_stress_sessions succeeded
each with "# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0". The simple suite's serial log shows the handover round trip:
KHO: found kexec handover data.
luo: Retrieved live update data, liveupdate number: 1 # [STAGE 2] Test data verified successfully. --- SIMPLE KEXEC TEST PASSED ---
tools/testing/selftests/liveupdate/config.riscv64 | 3 +++ tools/testing/selftests/liveupdate/run-vmtests.sh | 2 +- tools/testing/selftests/liveupdate/vmtest.sh | 8 +++++++- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/liveupdate/config.riscv64
tools/testing/selftests/liveupdate/config.riscv64 new file +3 -0
@@ -0,0 +1,3 @@ +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_OF_PLATFORM=y
tools/testing/selftests/liveupdate/run-vmtests.sh +1 -1
@@ -4,7 +4,7 @@ SCRIPT_DIR=$(dirname "$(realpath "$0")") TEST_RUNNER="$SCRIPT_DIR/vmtest.sh" -TARGETS=("x86_64" "aarch64") +TARGETS=("x86_64" "aarch64" "riscv64") GREEN='\033[0;32m' RED='\033[0;31m'
tools/testing/selftests/liveupdate/vmtest.sh +7 -1
@@ -25,6 +25,10 @@ function get_arch_conf() { QEMU_CMD="qemu-system-x86_64" KERNEL_IMAGE="bzImage" KERNEL_CMDLINE="console=ttyS0" + elif [[ "$arch" == "riscv" ]]; then + QEMU_CMD="qemu-system-riscv64 -M virt -cpu max" + KERNEL_IMAGE="Image" + KERNEL_CMDLINE="console=ttyS0" else echo "Unsupported architecture: $arch" exit 1
@@ -37,7 +41,7 @@ $0 [-d build_dir] [-j jobs] [-t target_arch] [-T test_name] [-w workspace_dir] [ Options: -d) path to the kernel build directory (default: .luo_test_build.<arch>) -j) number of jobs for compilation - -t) run test for target_arch (aarch64, x86_64) + -t) run test for target_arch (aarch64, x86_64, riscv64) -T) test name to run (default: luo_kexec_simple) -w) custom workspace directory (default: creates temp dir) -k) keep workspace directory
@@ -87,6 +91,7 @@ function detect_cross_compile() { case "$target" in aarch64) candidate="aarch64-linux-gnu-" ;; x86_64) candidate="x86_64-linux-gnu-" ;; + riscv64) candidate="riscv64-linux-gnu-" ;; *) skip "Auto-detection for target '$target' not supported. Please set CROSS_COMPILE manually." ;; esac
@@ -194,6 +199,7 @@ function target_to_arch() { case $target in aarch64) echo "arm64" ;; x86_64) echo "x86" ;; + riscv64) echo "riscv" ;; *) skip "architecture $target is not supported" esac }
Signature · 1 line
2.50.1
[email protected]
AI reviewRe: [PATCH v4 4/4] selftests: liveupdate: Add riscv support
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
Teach the live update vmtest runners about riscv64, so the LUO tests can be run on this architecture.
LIVEUPDATE depends only on
KEXEC_HANDOVER, enabled for riscv64 by the previous commit, so nothing in the tests stood in the way.Signed-off-by Chen Pei <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4