mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/4] riscv: Enable kexec handover and live update
@ 2026-11-18  9:15 Chen Pei
  2026-11-18  9:16 ` [PATCH v4 1/4] riscv: Call early_ioremap_setup() before parsing the DTB Chen Pei
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Chen Pei @ 2026-11-18  9:15 UTC (permalink / raw)
  To: pjw, palmer, alex, rppt, pasha.tatashin, pratyush, graf, shuah
  Cc: guoren, linux-riscv, linux-kernel, linux-mm, linux-kselftest, kexec

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/20261023054518.3258350-1-gthelen@google.com/
[2] https://lore.kernel.org/kexec/20261112-kho-bootmem-sizing-v3-0-f0c8d00295d5@kernel.org/
[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
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 1/4] riscv: Call early_ioremap_setup() before parsing the DTB
  2026-11-18  9:15 [PATCH v4 0/4] riscv: Enable kexec handover and live update Chen Pei
@ 2026-11-18  9:16 ` Chen Pei
  2026-11-18  9:16 ` [PATCH v4 2/4] riscv: Add support for KHO Chen Pei
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Chen Pei @ 2026-11-18  9:16 UTC (permalink / raw)
  To: pjw, palmer, alex, rppt, pasha.tatashin, pratyush, graf, shuah
  Cc: guoren, linux-riscv, linux-kernel, linux-mm, linux-kselftest, kexec

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.

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Acked-by: Paul Walmsley <pjw@kernel.org> # arch/riscv
---
 arch/riscv/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index d79f99b86033..45e2ef9d32fa 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -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();
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 2/4] riscv: Add support for KHO
  2026-11-18  9:15 [PATCH v4 0/4] riscv: Enable kexec handover and live update Chen Pei
  2026-11-18  9:16 ` [PATCH v4 1/4] riscv: Call early_ioremap_setup() before parsing the DTB Chen Pei
@ 2026-11-18  9:16 ` Chen Pei
  2026-11-18  9:16 ` [PATCH v4 3/4] selftests: kho: Add riscv support Chen Pei
  2026-11-18  9:16 ` [PATCH v4 4/4] selftests: liveupdate: " Chen Pei
  3 siblings, 0 replies; 5+ messages in thread
From: Chen Pei @ 2026-11-18  9:16 UTC (permalink / raw)
  To: pjw, palmer, alex, rppt, pasha.tatashin, pratyush, graf, shuah
  Cc: guoren, linux-riscv, linux-kernel, linux-mm, linux-kselftest, kexec

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 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.

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Acked-by: Paul Walmsley <pjw@kernel.org> # arch/riscv
---
 arch/riscv/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index bde1f1885038..bffef6b903e1 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -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
 
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 3/4] selftests: kho: Add riscv support
  2026-11-18  9:15 [PATCH v4 0/4] riscv: Enable kexec handover and live update Chen Pei
  2026-11-18  9:16 ` [PATCH v4 1/4] riscv: Call early_ioremap_setup() before parsing the DTB Chen Pei
  2026-11-18  9:16 ` [PATCH v4 2/4] riscv: Add support for KHO Chen Pei
@ 2026-11-18  9:16 ` Chen Pei
  2026-11-18  9:16 ` [PATCH v4 4/4] selftests: liveupdate: " Chen Pei
  3 siblings, 0 replies; 5+ messages in thread
From: Chen Pei @ 2026-11-18  9:16 UTC (permalink / raw)
  To: pjw, palmer, alex, rppt, pasha.tatashin, pratyush, graf, shuah
  Cc: guoren, linux-riscv, linux-kernel, linux-mm, linux-kselftest, kexec

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 <cp0613@linux.alibaba.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---

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

diff --git a/tools/testing/selftests/kho/riscv.conf b/tools/testing/selftests/kho/riscv.conf
new file mode 100644
index 000000000000..ec2a46cd45d5
--- /dev/null
+++ b/tools/testing/selftests/kho/riscv.conf
@@ -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"
diff --git a/tools/testing/selftests/kho/vmtest.sh b/tools/testing/selftests/kho/vmtest.sh
index 1e86ffcc3a79..56cac6ae3cf9 100755
--- a/tools/testing/selftests/kho/vmtest.sh
+++ b/tools/testing/selftests/kho/vmtest.sh
@@ -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
 }
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v4 4/4] selftests: liveupdate: Add riscv support
  2026-11-18  9:15 [PATCH v4 0/4] riscv: Enable kexec handover and live update Chen Pei
                   ` (2 preceding siblings ...)
  2026-11-18  9:16 ` [PATCH v4 3/4] selftests: kho: Add riscv support Chen Pei
@ 2026-11-18  9:16 ` Chen Pei
  3 siblings, 0 replies; 5+ messages in thread
From: Chen Pei @ 2026-11-18  9:16 UTC (permalink / raw)
  To: pjw, palmer, alex, rppt, pasha.tatashin, pratyush, graf, shuah
  Cc: guoren, linux-riscv, linux-kernel, linux-mm, linux-kselftest, kexec

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 <cp0613@linux.alibaba.com>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
---

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

diff --git a/tools/testing/selftests/liveupdate/config.riscv64 b/tools/testing/selftests/liveupdate/config.riscv64
new file mode 100644
index 000000000000..edbc551199b0
--- /dev/null
+++ b/tools/testing/selftests/liveupdate/config.riscv64
@@ -0,0 +1,3 @@
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
diff --git a/tools/testing/selftests/liveupdate/run-vmtests.sh b/tools/testing/selftests/liveupdate/run-vmtests.sh
index 6f592aec0f85..c3d828cfd63b 100755
--- a/tools/testing/selftests/liveupdate/run-vmtests.sh
+++ b/tools/testing/selftests/liveupdate/run-vmtests.sh
@@ -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'
diff --git a/tools/testing/selftests/liveupdate/vmtest.sh b/tools/testing/selftests/liveupdate/vmtest.sh
index dea5a6fb2abc..70a8d978077a 100755
--- a/tools/testing/selftests/liveupdate/vmtest.sh
+++ b/tools/testing/selftests/liveupdate/vmtest.sh
@@ -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
 }
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-18  9:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18  9:15 [PATCH v4 0/4] riscv: Enable kexec handover and live update Chen Pei
2026-11-18  9:16 ` [PATCH v4 1/4] riscv: Call early_ioremap_setup() before parsing the DTB Chen Pei
2026-11-18  9:16 ` [PATCH v4 2/4] riscv: Add support for KHO Chen Pei
2026-11-18  9:16 ` [PATCH v4 3/4] selftests: kho: Add riscv support Chen Pei
2026-11-18  9:16 ` [PATCH v4 4/4] selftests: liveupdate: " Chen Pei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®