Skip to contentSkip to conversation

RISC-V: Add kexec support

PATCH Superseded Nick Kossifidis 1 participant 1 message Apr 16, 2019

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RISC-V: Add kexec support

This patch adds support for kexec on RISC-V. For now it doesn't include kexec_file or kdump / crashkernel support. I tested it on riscv64 QEMU on both an smp and a non-smp system. On SMP systems this disables all secondary harts through smp_send_stop(), until we get support for hart suspend/resume through SBI. The next kernel will start with "nosmp" appended to its cmdline as a temporary workaround (this is done on kexec-tools). On BBL this works fine, on OpenSBI there is an issue with trap delegation / redirection of *_ACCESS traps, a patch is on the way.

I submitted the patch for kexec-tools on the kexec list:
http://lists.infradead.org/pipermail/kexec/2019-April/022874.html

---
 arch/riscv/Kconfig                 |  11 ++
 arch/riscv/include/asm/kexec.h     |  43 +++++++
 arch/riscv/kernel/Makefile         |   4 +-
 arch/riscv/kernel/kexec_relocate.S | 175 ++++++++++++++++++++++++++
 arch/riscv/kernel/machine_kexec.c  | 191 +++++++++++++++++++++++++++++
 include/uapi/linux/kexec.h         |   1 +
 6 files changed, 424 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/include/asm/kexec.h
 create mode 100644 arch/riscv/kernel/kexec_relocate.S
 create mode 100644 arch/riscv/kernel/machine_kexec.c
arch/riscv/Kconfig +11 -0
index 515fc3cc9..0ed5f6d20 100644
@@ -228,6 +228,17 @@ menu "Kernel features"
 
 source "kernel/Kconfig.hz"
 
+config KEXEC
+	bool "Kexec system call"
+	select KEXEC_CORE
+	help
+	  kexec is a system call that implements the ability to shutdown your
+	  current kernel, and to start another kernel. It is like a reboot
+	  but it is independent of the system firmware. And like a reboot
+	  you can start any kernel with it, not just Linux.
+
+	  The name comes from the similarity to the exec system call.
+
 endmenu
 
 menu "Boot options"
arch/riscv/include/asm/kexec.h new file +43 -0

43 lines not on this page · raw message

arch/riscv/kernel/Makefile +3 -1
index f13f7f276..de50d5f96 100644
@@ -40,6 +40,8 @@ obj-$(CONFIG_MODULE_SECTIONS)	+= module-sections.o
 obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o ftrace.o
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= mcount-dyn.o
 
-obj-$(CONFIG_PERF_EVENTS)      += perf_event.o
+obj-$(CONFIG_PERF_EVENTS)	+= perf_event.o
+
+obj-${CONFIG_KEXEC}		+= kexec_relocate.o machine_kexec.o
 
 clean:
arch/riscv/kernel/kexec_relocate.S new file +175 -0

175 lines not on this page · raw message

arch/riscv/kernel/machine_kexec.c new file +191 -0

191 lines not on this page · raw message

include/uapi/linux/kexec.h +1 -0
index 6d1128682..87af2f17a 100644
@@ -41,6 +41,7 @@
 #define KEXEC_ARCH_MIPS_LE (10 << 16)
 #define KEXEC_ARCH_MIPS    ( 8 << 16)
 #define KEXEC_ARCH_AARCH64 (183 << 16)
+#define KEXEC_ARCH_RISCV   (243 << 16)
 
 /* The artificial cap on the number of segments passed to kexec_load. */
 #define KEXEC_SEGMENT_MAX 16
Signature · 7 lines
2.21.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec