Skip to contentSkip to conversation

kexec support for PARISC

PATCH In review Sven Schnelle 2 participants 7 messages Sep 8, 2019 – Sep 17, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover kexec support for PARISC

Hi,

this series adds support for the kexec syscalls to the PARISC architecture. Note that kexec() on PA8800/PA8900 doesn't work yet as i haven't figured out how to restart the CPUs on these systems.

For testing you can use my patched kexec-tools:

https://git.stackframe.org/cgit/kexec-tools/log/

I will submit these patches as soon as kexec is merged into the linux kernel.

Thanks,
Sven

Sven Schnelle (4):
parisc: add __pdc_cpu_rendezvous()
parisc: add kexec syscall support
parisc: wire up kexec_file_load syscall
parisc: add support for kexec_file_load() syscall

 arch/parisc/Kconfig                     |  23 ++++
 arch/parisc/include/asm/fixmap.h        |   1 +
 arch/parisc/include/asm/kexec.h         |  37 ++++++
 arch/parisc/include/asm/pdc.h           |   1 +
 arch/parisc/kernel/Makefile             |   2 +
 arch/parisc/kernel/firmware.c           |  13 +++
 arch/parisc/kernel/kexec.c              | 109 +++++++++++++++++
 arch/parisc/kernel/kexec_file.c         |  86 ++++++++++++++
 arch/parisc/kernel/relocate_kernel.S    | 149 ++++++++++++++++++++++++
 arch/parisc/kernel/smp.c                |   1 +
 arch/parisc/kernel/syscalls/syscall.tbl |   3 +-
 include/uapi/linux/kexec.h              |   1 +
 12 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 arch/parisc/include/asm/kexec.h
 create mode 100644 arch/parisc/kernel/kexec.c
 create mode 100644 arch/parisc/kernel/kexec_file.c
 create mode 100644 arch/parisc/kernel/relocate_kernel.S
Signature · 1 line
2.23.0.rc1
#1 lore raw

PATCH 1/4 parisc: add __pdc_cpu_rendezvous()

When stopping SMP cpus send them into rendezvous, so we can start them again later (when kexec'ing a new kernel).

---
 arch/parisc/include/asm/pdc.h |  1 +
 arch/parisc/kernel/firmware.c | 13 +++++++++++++
 arch/parisc/kernel/smp.c      |  1 +
 3 files changed, 15 insertions(+)
arch/parisc/include/asm/pdc.h +1 -0
index 19bb2e46cd36..b388d8176588 100644
@@ -91,6 +91,7 @@ int pdc_sti_call(unsigned long func, unsigned long flags,
                  unsigned long inptr, unsigned long outputr,
                  unsigned long glob_cfg);
 
+int __pdc_cpu_rendezvous(void);
 static inline char * os_id_to_string(u16 os_id) {
 	switch(os_id) {
 	case OS_ID_NONE:	return "No OS";
arch/parisc/kernel/firmware.c +13 -0
index 58cc08e7fd12..1d976f2ebff0 100644
@@ -311,6 +311,19 @@ int pdc_chassis_disp(unsigned long disp)
 	return retval;
 }
 
+/**
+ * pdc_cpu_rendenzvous - Stop currently executing CPU
+ * @retval: -1 on error, 0 on success
+ */
+int __pdc_cpu_rendezvous(void)
+{
+	if (is_pdc_pat())
+		return mem_pdc_call(PDC_PAT_CPU, PDC_PAT_CPU_RENDEZVOUS);
+	else
+		return mem_pdc_call(PDC_PROC, 1, 0);
+}
+
+
 /**
  * pdc_chassis_warn - Fetches chassis warnings
  * @retval: -1 on error, 0 on success
arch/parisc/kernel/smp.c +1 -0
index cbd074ba22da..e202c37e56af 100644
@@ -109,6 +109,7 @@ halt_processor(void)
 	/* REVISIT : does PM *know* this CPU isn't available? */
 	set_cpu_online(smp_processor_id(), false);
 	local_irq_disable();
+	__pdc_cpu_rendezvous();
 	for (;;)
 		;
 }
Signature · 1 line
2.23.0.rc1
#2 lore raw

PATCH 2/4 parisc: add kexec syscall support

In reply to Sven Schnelle
---
 arch/parisc/Kconfig                  |  13 +++
 arch/parisc/include/asm/fixmap.h     |   1 +
 arch/parisc/include/asm/kexec.h      |  37 +++++++
 arch/parisc/kernel/Makefile          |   1 +
 arch/parisc/kernel/kexec.c           | 102 ++++++++++++++++++
 arch/parisc/kernel/relocate_kernel.S | 149 +++++++++++++++++++++++++++
 include/uapi/linux/kexec.h           |   1 +
 7 files changed, 304 insertions(+)
 create mode 100644 arch/parisc/include/asm/kexec.h
 create mode 100644 arch/parisc/kernel/kexec.c
 create mode 100644 arch/parisc/kernel/relocate_kernel.S
arch/parisc/Kconfig +13 -0
index ee59171edffe..548c767f4358 100644
@@ -346,6 +346,19 @@ config NR_CPUS
 	depends on SMP
 	default "4"
 
+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.
+
+	  It is an ongoing process to be certain the hardware in a machine
+	  shutdown, so do not be surprised if this code does not
+	  initially work for you.
+
 endmenu
 
 
arch/parisc/include/asm/fixmap.h +1 -0
index 288da73d4cc0..e480b2c05407 100644
@@ -30,6 +30,7 @@
 enum fixed_addresses {
 	/* Support writing RO kernel text via kprobes, jump labels, etc. */
 	FIX_TEXT_POKE0,
+	FIX_TEXT_KEXEC,
 	FIX_BITMAP_COUNT
 };
 
arch/parisc/include/asm/kexec.h new file +37 -0
new file mode 100644
index 000000000000..a99ea747d7ed
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_PARISC_KEXEC_H
+#define _ASM_PARISC_KEXEC_H
+
+#ifdef CONFIG_KEXEC
+
+/* Maximum physical address we can use pages from */
+#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
+/* Maximum address we can reach in physical address mode */
+#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
+/* Maximum address we can use for the control code buffer */
+#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
+
+#define KEXEC_CONTROL_PAGE_SIZE	4096
+
+#define KEXEC_ARCH KEXEC_ARCH_PARISC
+#define ARCH_HAS_KIMAGE_ARCH
+
+#ifndef __ASSEMBLY__
+
+struct kimage_arch {
+	unsigned long initrd_start;
+	unsigned long initrd_end;
+	unsigned long cmdline;
+};
+
+static inline void crash_setup_regs(struct pt_regs *newregs,
+				    struct pt_regs *oldregs)
+{
+	/* Dummy implementation for now */
+}
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* CONFIG_KEXEC */
+
+#endif /* _ASM_PARISC_KEXEC_H */
arch/parisc/kernel/Makefile +1 -0
index c232266b517c..487cf88866a8 100644
@@ -37,3 +37,4 @@ obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
 obj-$(CONFIG_JUMP_LABEL)		+= jump_label.o
 obj-$(CONFIG_KGDB)			+= kgdb.o
 obj-$(CONFIG_KPROBES)			+= kprobes.o
+obj-$(CONFIG_KEXEC)			+= kexec.o relocate_kernel.o
arch/parisc/kernel/kexec.c new file +102 -0

102 lines not on this page · raw message

arch/parisc/kernel/relocate_kernel.S new file +149 -0

149 lines not on this page · raw message

include/uapi/linux/kexec.h +1 -0
index 6d112868272d..05669c87a0af 100644
@@ -31,6 +31,7 @@
 #define KEXEC_ARCH_DEFAULT ( 0 << 16)
 #define KEXEC_ARCH_386     ( 3 << 16)
 #define KEXEC_ARCH_68K     ( 4 << 16)
+#define KEXEC_ARCH_PARISC  (15 << 16)
 #define KEXEC_ARCH_X86_64  (62 << 16)
 #define KEXEC_ARCH_PPC     (20 << 16)
 #define KEXEC_ARCH_PPC64   (21 << 16)
Signature · 1 line
2.23.0.rc1
#3 lore raw

PATCH 3/4 parisc: wire up kexec_file_load syscall

In reply to Sven Schnelle
---
 arch/parisc/kernel/syscalls/syscall.tbl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/parisc/kernel/syscalls/syscall.tbl +2 -1
index 670d1371aca1..285ff516150c 100644
@@ -399,7 +399,8 @@
 352	common	pkey_alloc		sys_pkey_alloc
 353	common	pkey_free		sys_pkey_free
 354	common	rseq			sys_rseq
-# 355 through 402 are unassigned to sync up with generic numbers
+355	common	kexec_file_load		sys_kexec_file_load		sys_kexec_file_load
+# up to 402 is unassigned and reserved for arch specific syscalls
 403	32	clock_gettime64			sys_clock_gettime		sys_clock_gettime
 404	32	clock_settime64			sys_clock_settime		sys_clock_settime
 405	32	clock_adjtime64			sys_clock_adjtime		sys_clock_adjtime
Signature · 1 line
2.23.0.rc1
#4 lore raw

PATCH 4/4 parisc: add support for kexec_file_load() syscall

In reply to Sven Schnelle
---
 arch/parisc/Kconfig             | 10 ++++
 arch/parisc/kernel/Makefile     |  1 +
 arch/parisc/kernel/kexec.c      |  7 +++
 arch/parisc/kernel/kexec_file.c | 86 +++++++++++++++++++++++++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 arch/parisc/kernel/kexec_file.c
arch/parisc/Kconfig +10 -0
index 548c767f4358..2e757c785239 100644
@@ -359,6 +359,16 @@ config KEXEC
 	  shutdown, so do not be surprised if this code does not
 	  initially work for you.
 
+config KEXEC_FILE
+	bool "kexec file based system call"
+	select KEXEC_CORE
+	select KEXEC_ELF
+	help
+	  This enables the kexec_file_load() System call. This is
+	  file based and takes file descriptors as system call argument
+	  for kernel and initramfs as opposed to list of segments as
+	  accepted by previous system call.
+
 endmenu
 
 
arch/parisc/kernel/Makefile +1 -0
index 487cf88866a8..2663c8f8be11 100644
@@ -38,3 +38,4 @@ obj-$(CONFIG_JUMP_LABEL)		+= jump_label.o
 obj-$(CONFIG_KGDB)			+= kgdb.o
 obj-$(CONFIG_KPROBES)			+= kprobes.o
 obj-$(CONFIG_KEXEC)			+= kexec.o relocate_kernel.o
+obj-$(CONFIG_KEXEC_FILE)		+= kexec_file.o
arch/parisc/kernel/kexec.c +7 -0
index deeb0466d359..3d0716ded552 100644
@@ -37,6 +37,13 @@ static void kexec_image_info(const struct kimage *kimage)
 
 	for (i = 0; i < kimage->nr_segments; i++)
 		kexec_show_segment_info(kimage, i);
+
+#ifdef CONFIG_KEXEC_FILE
+	if (kimage->file_mode) {
+		pr_debug("cmdline: %.*s\n", (int)kimage->cmdline_buf_len,
+			 kimage->cmdline_buf);
+	}
+#endif
 }
 
 void machine_kexec_cleanup(struct kimage *kimage)
arch/parisc/kernel/kexec_file.c new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
2.23.0.rc1
maintainer
#5 lore raw
In reply to Sven Schnelle
Quoted 10 lines · Sven Schnelle

this series adds support for the kexec syscalls to the PARISC architecture. Note that kexec() on PA8800/PA8900 doesn't work yet as i haven't figured out how to restart the CPUs on these systems.

For testing you can use my patched kexec-tools:

https://git.stackframe.org/cgit/kexec-tools/log/

I will submit these patches as soon as kexec is merged into the linux kernel.

Thanks!
Patch series applied to the parisc for-next tree:
https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git/log/?h=for-next

Helge

Quoted 28 lines

Thanks,
Sven

Sven Schnelle (4):
parisc: add __pdc_cpu_rendezvous()
parisc: add kexec syscall support
parisc: wire up kexec_file_load syscall
parisc: add support for kexec_file_load() syscall

 arch/parisc/Kconfig                     |  23 ++++
 arch/parisc/include/asm/fixmap.h        |   1 +
 arch/parisc/include/asm/kexec.h         |  37 ++++++
 arch/parisc/include/asm/pdc.h           |   1 +
 arch/parisc/kernel/Makefile             |   2 +
 arch/parisc/kernel/firmware.c           |  13 +++
 arch/parisc/kernel/kexec.c              | 109 +++++++++++++++++
 arch/parisc/kernel/kexec_file.c         |  86 ++++++++++++++
 arch/parisc/kernel/relocate_kernel.S    | 149 ++++++++++++++++++++++++
 arch/parisc/kernel/smp.c                |   1 +
 arch/parisc/kernel/syscalls/syscall.tbl |   3 +-
 include/uapi/linux/kexec.h              |   1 +
 12 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 arch/parisc/include/asm/kexec.h
 create mode 100644 arch/parisc/kernel/kexec.c
 create mode 100644 arch/parisc/kernel/kexec_file.c
 create mode 100644 arch/parisc/kernel/relocate_kernel.S
maintainer
#6 lore raw

Hi Sven,

Quoted 7 lines · Helge Deller
Quoted 6 lines · Sven Schnelle

this series adds support for the kexec syscalls to the PARISC architecture.
....
For testing you can use my patched kexec-tools:
https://git.stackframe.org/cgit/kexec-tools/log/

I will submit these patches as soon as kexec is merged into the linux kernel.

All kexec patches have been merged upstream and will be part of kernel v5.4.
So, you may now push your patches to userspace kexec-tools upstream too.

Thanks!
Helge