Skip to contentSkip to conversation

kexec: refactor CONFIG_KEXEC/CONFIG_KEXEC_FILE Kconfig

PATCH Superseded [email protected] 2 participants 14 messages Jul 13, 2015 – Jul 15, 2015

Subsystems (19)
Arm (32-bit) x86 VFS PowerPC +15 more subsystems

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover kexec: refactor CONFIG_KEXEC/CONFIG_KEXEC_FILE Kconfig

Previously Theodore Ts'o brought up an issue about kexec_load syscall bypassing signature verification:
https://lkml.org/lkml/2015/6/14/280

Because we have two kexec load syscall, one kexec_load, another kexec_file_load, the latter one was introduced by Vivek Goyal, it is mainly for supporting UEFI secure boot. kexec_file_load verifies kernel signature, but even if with CONFIG_KEXEC_VERIFY_SIG=y and CONFIG_KEXEC_FILE=y, kexec-tools still can use old syscall and bypass signature verification.

KEXEC_FILE can also be used without UEFI, so kexec can always verify kernel signature for security purpose.

The suggestion in above thread is add a new Kconfig option for kexec common code, here I use KEXEC_CORE, KEXEC and KEXEC_FILE select KEXEC_CORE so one can compile only KEXEC_FILE without old kexec_load syscall.

There's checkpatch warnings and errors, I would like to send furthuer cleanup patches after this series. Please let me know if you have other suggestions. checkpatch errors are for cases such as assign a value to static variables.

PATCH 3/3 can be sort out from the series if people do not like. It is a cleanup for a macro.

Below is the diffstat of the patches:

---
 arch/arm/Kconfig              |    4 
 arch/ia64/Kconfig             |    4 
 arch/m68k/Kconfig             |    4 
 arch/mips/Kconfig             |    4 
 arch/powerpc/Kconfig          |    4 
 arch/sh/Kconfig               |    4 
 arch/tile/Kconfig             |    4 
 arch/x86/Kconfig              |    6 
 arch/x86/boot/header.S        |    2 
 arch/x86/include/asm/kdebug.h |    5 
 arch/x86/kernel/Makefile      |    4 
 arch/x86/kernel/kvmclock.c    |    4 
 arch/x86/kernel/reboot.c      |    4 
 arch/x86/kernel/setup.c       |    2 
 arch/x86/kernel/vmlinux.lds.S |    2 
 arch/x86/kvm/vmx.c            |    8 
 arch/x86/platform/efi/efi.c   |    4 
 arch/x86/platform/uv/uv_nmi.c |    6 
 drivers/firmware/efi/Kconfig  |    2 
 drivers/pci/pci-driver.c      |    2 
 include/linux/kexec.h         |   12 
 init/initramfs.c              |    4 
 kernel/Makefile               |    2 
 kernel/events/core.c          |    2 
 kernel/kexec.c                | 2633 ------------------------------------------
 kernel/kexec_core.c           | 1594 +++++++++++++++++++++++++
 kernel/kexec_file.c           | 1044 ++++++++++++++++
 kernel/kexec_internal.h       |   22 
 kernel/ksysfs.c               |    6 
 kernel/printk/printk.c        |    2 
 kernel/reboot.c               |    2 
 kernel/sysctl.c               |    2 
 32 files changed, 2745 insertions(+), 2659 deletions(-)

Thanks
Dave

#1 lore raw

PATCH 1/3 kexec: split kexec_file syscall code to kexec_file.c

Split kexec_file syscall related code to another file kernel/kexec_file.c so that the #ifdef CONFIG_KEXEC_FILE in kexec.c can be dropped.

Sharing variables and functions are moved to kernel/kexec_internal.h per suggestion from Vivek and Petr.

---
 kernel/Makefile         |    1 +
 kernel/kexec.c          | 1055 +----------------------------------------------
 kernel/kexec_file.c     | 1044 ++++++++++++++++++++++++++++++++++++++++++++++
 kernel/kexec_internal.h |   22 +
 4 files changed, 1077 insertions(+), 1045 deletions(-)
 create mode 100644 kernel/kexec_file.c
 create mode 100644 kernel/kexec_internal.h
kernel/Makefile +1 -0
index 43c4c92..f178fe4 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_MODULE_SIG) += module_signing.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
 obj-$(CONFIG_KEXEC) += kexec.o
+obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
 obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
 obj-$(CONFIG_COMPAT) += compat.o
 obj-$(CONFIG_CGROUPS) += cgroup.o
kernel/kexec.c +10 -1045

1,145 lines not on this page · raw message

kernel/kexec_file.c new file +1044 -0

1,044 lines not on this page · raw message

kernel/kexec_internal.h new file +22 -0
new file mode 100644
index 0000000..e4392a6
@@ -0,0 +1,22 @@
+#ifndef LINUX_KEXEC_INTERNAL_H
+#define LINUX_KEXEC_INTERNAL_H
+
+#include <linux/kexec.h>
+
+struct kimage *do_kimage_alloc_init(void);
+int sanity_check_segment_list(struct kimage *image);
+void kimage_free_page_list(struct list_head *list);
+void kimage_free(struct kimage *image);
+int kimage_load_segment(struct kimage *image, struct kexec_segment *segment);
+void kimage_terminate(struct kimage *image);
+int kimage_is_destination_range(struct kimage *image,
+				unsigned long start, unsigned long end);
+
+extern struct mutex kexec_mutex;
+
+#ifdef CONFIG_KEXEC_FILE
+void kimage_file_post_load_cleanup(struct kimage *image);
+#else /* CONFIG_KEXEC_FILE */
+static inline void kimage_file_post_load_cleanup(struct kimage *image) { }
+#endif /* CONFIG_KEXEC_FILE */
+#endif /* LINUX_KEXEC_INTERNAL_H */
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/3 kexec: split kexec_load syscall from kexec core code

In reply to [email protected]

Now there's two kexec load syscall, one is kexec_load another is kexec_file_load, kexec_file_load has been splited as kernel/kexec_file.c. In this patch I split kexec_load syscall code to kernel/kexec.c.

And add a new kconfig option KEXEC_CORE, so we can disable kexec_load and use kexec_file_load only, or vice verse.

The original requirement is from Tedso, he want kexec kernel signature being checked with CONFIG_KEXEC_VERIFY_SIG enabled. But kexec-tools use kexec_load syscall can bypass the checking.

Vivek Goyal proposed to create a common kconfig option so user can compile in only one syscall for loading kexec kernel. KEXEC/KEXEC_FILE selects KEXEC_CORE so that old config files still work.

Because there's general code need CONFIG_KEXEC_CORE, so I updated all the architecture Kconfig with a new option KEXEC_CORE, and let KEXEC selects KEXEC_CORE in arch Kconfig. Also updated general kernel code with to kexec_load syscall.

---
 arch/arm/Kconfig              |    4 +
 arch/ia64/Kconfig             |    4 +
 arch/m68k/Kconfig             |    4 +
 arch/mips/Kconfig             |    4 +
 arch/powerpc/Kconfig          |    4 +
 arch/sh/Kconfig               |    4 +
 arch/tile/Kconfig             |    4 +
 arch/x86/Kconfig              |    6 +-
 arch/x86/boot/header.S        |    2 +-
 arch/x86/include/asm/kdebug.h |    2 +-
 arch/x86/kernel/Makefile      |    4 +-
 arch/x86/kernel/kvmclock.c    |    4 +-
 arch/x86/kernel/reboot.c      |    4 +-
 arch/x86/kernel/setup.c       |    2 +-
 arch/x86/kernel/vmlinux.lds.S |    2 +-
 arch/x86/kvm/vmx.c            |    8 +-
 arch/x86/platform/efi/efi.c   |    4 +-
 arch/x86/platform/uv/uv_nmi.c |    6 +-
 drivers/firmware/efi/Kconfig  |    2 +-
 drivers/pci/pci-driver.c      |    2 +-
 include/linux/kexec.h         |   12 +-
 init/initramfs.c              |    4 +-
 kernel/Makefile               |    1 +
 kernel/events/core.c          |    2 +-
 kernel/kexec.c                | 1578 +---------------------------------------
 kernel/kexec_core.c           | 1594 +++++++++++++++++++++++++++++++++++++++++
 kernel/ksysfs.c               |    6 +-
 kernel/printk/printk.c        |    2 +-
 kernel/reboot.c               |    2 +-
 kernel/sysctl.c               |    2 +-
 30 files changed, 1668 insertions(+), 1611 deletions(-)
 create mode 100644 kernel/kexec_core.c
arch/arm/Kconfig +4 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
 	  be linked for and stored to.  This address is dependent on your
 	  own flash usage.
 
+config KEXEC_CORE
+	bool
+
 config KEXEC
 	bool "Kexec system call (EXPERIMENTAL)"
 	depends on (!SMP || PM_SLEEP_SMP)
 	depends on !CPU_V7M
+	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
arch/ia64/Kconfig +4 -0
index 42a91a7..7db8fb7 100644
@@ -515,9 +515,13 @@ config IA64_HP_AML_NFW
 
 source "drivers/sn/Kconfig"
 
+config KEXEC_CORE
+	bool
+
 config KEXEC
 	bool "kexec system call"
 	depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
+	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
arch/m68k/Kconfig +4 -0
index 2dd8f63..875c518 100644
@@ -92,9 +92,13 @@ config MMU_SUN3
 	bool
 	depends on MMU && !MMU_MOTOROLA && !MMU_COLDFIRE
 
+config KEXEC_CORE
+	bool
+
 config KEXEC
 	bool "kexec system call"
 	depends on M68KCLASSIC
+	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
arch/mips/Kconfig +4 -0
index 2a14585..0084fb6 100644
@@ -2594,8 +2594,12 @@ config SCHED_HRTICK
 
 source "kernel/Kconfig.preempt"
 
+config KEXEC_CORE
+	bool
+
 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
arch/powerpc/Kconfig +4 -0
index 5ef2711..68d6674 100644
@@ -412,9 +412,13 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
 	default "y" if PPC_POWERNV
 	select ARCH_SUPPORTS_MEMORY_FAILURE
 
+config KEXEC_CORE
+	bool
+
 config KEXEC
 	bool "kexec system call"
 	depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
+	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
arch/sh/Kconfig +4 -0
index 50057fe..9edd1cc 100644
@@ -599,9 +599,13 @@ menu "Kernel features"
 
 source kernel/Kconfig.hz
 
+config KEXEC_CORE
+	bool
+
 config KEXEC
 	bool "kexec system call (EXPERIMENTAL)"
 	depends on SUPERH32 && MMU
+	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
arch/tile/Kconfig +4 -0
index 9def1f5..aa533a7 100644
@@ -202,8 +202,12 @@ endif
 
 source "kernel/Kconfig.hz"
 
+config KEXEC_CORE
+	bool
+
 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
arch/x86/Kconfig +5 -1
index 55bced1..290a912 100644
@@ -1716,8 +1716,12 @@ config SECCOMP
 
 source kernel/Kconfig.hz
 
+config KEXEC_CORE
+	bool
+
 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
@@ -1734,8 +1738,8 @@ config KEXEC
 
 config KEXEC_FILE
 	bool "kexec file based system call"
+	select KEXEC_CORE
 	select BUILD_BIN2C
-	depends on KEXEC
 	depends on X86_64
 	depends on CRYPTO=y
 	depends on CRYPTO_SHA256=y
arch/x86/boot/header.S +1 -1
index 16ef025..2d6b309 100644
@@ -414,7 +414,7 @@ xloadflags:
 # define XLF23 0
 #endif
 
-#if defined(CONFIG_X86_64) && defined(CONFIG_EFI) && defined(CONFIG_KEXEC)
+#if defined(CONFIG_X86_64) && defined(CONFIG_EFI) && defined(CONFIG_KEXEC_CORE)
 # define XLF4 XLF_EFI_KEXEC
 #else
 # define XLF4 0
arch/x86/include/asm/kdebug.h +1 -1
index 32ce713..b130d59 100644
@@ -29,7 +29,7 @@ extern void show_trace(struct task_struct *t, struct pt_regs *regs,
 extern void __show_regs(struct pt_regs *regs, int all);
 extern unsigned long oops_begin(void);
 extern void oops_end(unsigned long, struct pt_regs *, int signr);
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 extern int in_crash_kexec;
 #else
 /* no crash dump is ever in progress if no crash kernel can be kexec'd */
arch/x86/kernel/Makefile +2 -2
index 0f15af4..d538d42 100644
@@ -69,8 +69,8 @@ obj-$(CONFIG_LIVEPATCH)		+= livepatch.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
 obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
 obj-$(CONFIG_X86_TSC)		+= trace_clock.o
-obj-$(CONFIG_KEXEC)		+= machine_kexec_$(BITS).o
-obj-$(CONFIG_KEXEC)		+= relocate_kernel_$(BITS).o crash.o
+obj-$(CONFIG_KEXEC_CORE)	+= machine_kexec_$(BITS).o
+obj-$(CONFIG_KEXEC_CORE)	+= relocate_kernel_$(BITS).o crash.o
 obj-$(CONFIG_KEXEC_FILE)	+= kexec-bzimage64.o
 obj-$(CONFIG_CRASH_DUMP)	+= crash_dump_$(BITS).o
 obj-y				+= kprobes/
arch/x86/kernel/kvmclock.c +2 -2
index 49487b4..2c7aafa 100644
@@ -200,7 +200,7 @@ static void kvm_setup_secondary_clock(void)
  * kind of shutdown from our side, we unregister the clock by writting anything
  * that does not have the 'enable' bit set in the msr
  */
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 static void kvm_crash_shutdown(struct pt_regs *regs)
 {
 	native_write_msr(msr_kvm_system_time, 0, 0);
@@ -259,7 +259,7 @@ void __init kvmclock_init(void)
 	x86_platform.save_sched_clock_state = kvm_save_sched_clock_state;
 	x86_platform.restore_sched_clock_state = kvm_restore_sched_clock_state;
 	machine_ops.shutdown  = kvm_shutdown;
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	machine_ops.crash_shutdown  = kvm_crash_shutdown;
 #endif
 	kvm_get_preset_lpj();
arch/x86/kernel/reboot.c +2 -2
index 86db4bc..02693dd 100644
@@ -673,7 +673,7 @@ struct machine_ops machine_ops = {
 	.emergency_restart = native_machine_emergency_restart,
 	.restart = native_machine_restart,
 	.halt = native_machine_halt,
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	.crash_shutdown = native_machine_crash_shutdown,
 #endif
 };
@@ -703,7 +703,7 @@ void machine_halt(void)
 	machine_ops.halt();
 }
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 void machine_crash_shutdown(struct pt_regs *regs)
 {
 	machine_ops.crash_shutdown(regs);
arch/x86/kernel/setup.c +1 -1
index 80f874b..1c0faa7 100644
@@ -498,7 +498,7 @@ static void __init memblock_x86_reserve_range_setup_data(void)
  * --------- Crashkernel reservation ------------------------------
  */
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 
 /*
  * Keep the crash kernel below this limit.  On 32 bits earlier kernels
arch/x86/kernel/vmlinux.lds.S +1 -1
index 00bf300..74e4bf1 100644
@@ -364,7 +364,7 @@ INIT_PER_CPU(irq_stack_union);
 
 #endif /* CONFIG_X86_32 */
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 #include <asm/kexec.h>
 
 . = ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
arch/x86/kvm/vmx.c +4 -4
index e856dd5..32e61e9 100644
@@ -1264,7 +1264,7 @@ static void vmcs_load(struct vmcs *vmcs)
 		       vmcs, phys_addr);
 }
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 /*
  * This bitmap is used to indicate whether the vmclear
  * operation is enabled on all cpus. All disabled by
@@ -1302,7 +1302,7 @@ static void crash_vmclear_local_loaded_vmcss(void)
 #else
 static inline void crash_enable_local_vmclear(int cpu) { }
 static inline void crash_disable_local_vmclear(int cpu) { }
-#endif /* CONFIG_KEXEC */
+#endif /* CONFIG_KEXEC_CORE */
 
 static void __loaded_vmcs_clear(void *arg)
 {
@@ -10430,7 +10430,7 @@ static int __init vmx_init(void)
 	if (r)
 		return r;
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	rcu_assign_pointer(crash_vmclear_loaded_vmcss,
 			   crash_vmclear_local_loaded_vmcss);
 #endif
@@ -10440,7 +10440,7 @@ static int __init vmx_init(void)
 
 static void __exit vmx_exit(void)
 {
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	RCU_INIT_POINTER(crash_vmclear_loaded_vmcss, NULL);
 	synchronize_rcu();
 #endif
arch/x86/platform/efi/efi.c +2 -2
index cfba30f..f1e5419 100644
@@ -650,7 +650,7 @@ static void __init get_systab_virt_addr(efi_memory_desc_t *md)
 
 static void __init save_runtime_map(void)
 {
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	efi_memory_desc_t *md;
 	void *tmp, *p, *q = NULL;
 	int count = 0;
@@ -748,7 +748,7 @@ static void * __init efi_map_regions(int *count, int *pg_shift)
 
 static void __init kexec_enter_virtual_mode(void)
 {
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	efi_memory_desc_t *md;
 	void *p;
 
arch/x86/platform/uv/uv_nmi.c +3 -3
index 020c101..5c9f63f 100644
@@ -492,7 +492,7 @@ static void uv_nmi_touch_watchdogs(void)
 	touch_nmi_watchdog();
 }
 
-#if defined(CONFIG_KEXEC)
+#if defined(CONFIG_KEXEC_CORE)
 static atomic_t uv_nmi_kexec_failed;
 static void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs)
 {
@@ -519,13 +519,13 @@ static void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs)
 	uv_nmi_sync_exit(0);
 }
 
-#else /* !CONFIG_KEXEC */
+#else /* !CONFIG_KEXEC_CORE */
 static inline void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs)
 {
 	if (master)
 		pr_err("UV: NMI kdump: KEXEC not supported in this kernel\n");
 }
-#endif /* !CONFIG_KEXEC */
+#endif /* !CONFIG_KEXEC_CORE */
 
 #ifdef CONFIG_KGDB
 #ifdef CONFIG_KGDB_KDB
drivers/firmware/efi/Kconfig +1 -1
index 54071c1..84533e0 100644
@@ -43,7 +43,7 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE
 
 config EFI_RUNTIME_MAP
 	bool "Export efi runtime maps to sysfs"
-	depends on X86 && EFI && KEXEC
+	depends on X86 && EFI && KEXEC_CORE
 	default y
 	help
 	  Export efi runtime memory maps to /sys/firmware/efi/runtime-map.
drivers/pci/pci-driver.c +1 -1
index 3cb2210..2bf9532 100644
@@ -453,7 +453,7 @@ static void pci_device_shutdown(struct device *dev)
 	pci_msi_shutdown(pci_dev);
 	pci_msix_shutdown(pci_dev);
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	/*
 	 * If this is a kexec reboot, turn off Bus Master bit on the
 	 * device to tell it to not continue to do DMA. Don't touch
include/linux/kexec.h +9 -3
index e804306..79c1bca 100644
@@ -16,7 +16,7 @@
 
 #include <uapi/linux/kexec.h>
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 #include <linux/list.h>
 #include <linux/linkage.h>
 #include <linux/compat.h>
@@ -318,12 +318,18 @@ int crash_shrink_memory(unsigned long new_size);
 size_t crash_get_memory_size(void);
 void crash_free_reserved_phys_range(unsigned long begin, unsigned long end);
 
-#else /* !CONFIG_KEXEC */
+#ifdef CONFIG_KEXEC
+int kimage_alloc_init(struct kimage **rimage, unsigned long entry,
+			     unsigned long nr_segments,
+			     struct kexec_segment __user *segments,
+			     unsigned long flags);
+#endif
+#else /* !CONFIG_KEXEC_CORE */
 struct pt_regs;
 struct task_struct;
 static inline void crash_kexec(struct pt_regs *regs) { }
 static inline int kexec_should_crash(struct task_struct *p) { return 0; }
-#endif /* CONFIG_KEXEC */
+#endif /* CONFIG_KEXEC_CORE */
 
 #endif /* !defined(__ASSEBMLY__) */
 
init/initramfs.c +2 -2
index ad1bd77..b32ad7d 100644
@@ -526,14 +526,14 @@ extern unsigned long __initramfs_size;
 
 static void __init free_initrd(void)
 {
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
 	unsigned long crashk_end   = (unsigned long)__va(crashk_res.end);
 #endif
 	if (do_retain_initrd)
 		goto skip;
 
-#ifdef CONFIG_KEXEC
+#ifdef CONFIG_KEXEC_CORE
 	/*
 	 * If the initrd region is overlapped with crashkernel reserved region,
 	 * free only memory that is not part of crashkernel region.
kernel/Makefile +1 -0
index f178fe4..af9708d 100644
@@ -50,6 +50,7 @@ obj-$(CONFIG_MODULES) += module.o
 obj-$(CONFIG_MODULE_SIG) += module_signing.o
 obj-$(CONFIG_KALLSYMS) += kallsyms.o
 obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
+obj-$(CONFIG_KEXEC_CORE) += kexec_core.o
 obj-$(CONFIG_KEXEC) += kexec.o
 obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
 obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o
kernel/events/core.c +1 -1
index d3dae34..a9a6bc1 100644
@@ -8872,7 +8872,7 @@ static void perf_event_init_cpu(int cpu)
 	mutex_unlock(&swhash->hlist_mutex);
 }
 
-#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC
+#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE
 static void __perf_event_exit_context(void *__info)
 {
 	struct remove_event re = { .detach_group = true };
kernel/kexec.c +1 -1577

1,612 lines not on this page · raw message

kernel/kexec_core.c new file +1594 -0

1,057 lines not on this page · raw message

kernel/ksysfs.c +3 -3
index 6683cce..e83b264 100644

Lines of this file are not shown. View the raw message.

kernel/printk/printk.c +1 -1
index cf8c242..8f0324e 100644

Lines of this file are not shown. View the raw message.

kernel/reboot.c +1 -1
index d20c85d..bd30a97 100644

Lines of this file are not shown. View the raw message.

kernel/sysctl.c +1 -1
index 19b62b5..715cc57 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 9 lines
1.8.3.1




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

Part of the diff is not shown here. View the raw message.

#3 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Quoted 49 lines · On Mon, Jul 13, 2015 at 4:13 AM, <[email protected]> wrote:

Because there's general code need CONFIG_KEXEC_CORE, so I updated all the architecture Kconfig with a new option KEXEC_CORE, and let KEXEC selects KEXEC_CORE in arch Kconfig. Also updated general kernel code with to kexec_load syscall.

---
 arch/arm/Kconfig              |    4 +
 arch/ia64/Kconfig             |    4 +
 arch/m68k/Kconfig             |    4 +
 arch/mips/Kconfig             |    4 +
 arch/powerpc/Kconfig          |    4 +
 arch/sh/Kconfig               |    4 +
 arch/tile/Kconfig             |    4 +
 arch/x86/Kconfig              |    6 +-
 arch/x86/boot/header.S        |    2 +-
 arch/x86/include/asm/kdebug.h |    2 +-
 arch/x86/kernel/Makefile      |    4 +-
 arch/x86/kernel/kvmclock.c    |    4 +-
 arch/x86/kernel/reboot.c      |    4 +-
 arch/x86/kernel/setup.c       |    2 +-
 arch/x86/kernel/vmlinux.lds.S |    2 +-
 arch/x86/kvm/vmx.c            |    8 +-
 arch/x86/platform/efi/efi.c   |    4 +-
 arch/x86/platform/uv/uv_nmi.c |    6 +-
 drivers/firmware/efi/Kconfig  |    2 +-
 drivers/pci/pci-driver.c      |    2 +-
 include/linux/kexec.h         |   12 +-
 init/initramfs.c              |    4 +-
 kernel/Makefile               |    1 +
 kernel/events/core.c          |    2 +-
 kernel/kexec.c                | 1578 +---------------------------------------
 kernel/kexec_core.c           | 1594 +++++++++++++++++++++++++++++++++++++++++
 kernel/ksysfs.c               |    6 +-
 kernel/printk/printk.c        |    2 +-
 kernel/reboot.c               |    2 +-
 kernel/sysctl.c               |    2 +-
 30 files changed, 1668 insertions(+), 1611 deletions(-)
 create mode 100644 kernel/kexec_core.c
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#4 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Hi, Geert

Sorry for reply late, I'm occupied by other things.

Quoted 65 lines · Geert Uytterhoeven
Quoted 49 lines · On Mon, Jul 13, 2015 at 4:13 AM, <[email protected]> wrote:

Because there's general code need CONFIG_KEXEC_CORE, so I updated all the architecture Kconfig with a new option KEXEC_CORE, and let KEXEC selects KEXEC_CORE in arch Kconfig. Also updated general kernel code with to kexec_load syscall.

---
 arch/arm/Kconfig              |    4 +
 arch/ia64/Kconfig             |    4 +
 arch/m68k/Kconfig             |    4 +
 arch/mips/Kconfig             |    4 +
 arch/powerpc/Kconfig          |    4 +
 arch/sh/Kconfig               |    4 +
 arch/tile/Kconfig             |    4 +
 arch/x86/Kconfig              |    6 +-
 arch/x86/boot/header.S        |    2 +-
 arch/x86/include/asm/kdebug.h |    2 +-
 arch/x86/kernel/Makefile      |    4 +-
 arch/x86/kernel/kvmclock.c    |    4 +-
 arch/x86/kernel/reboot.c      |    4 +-
 arch/x86/kernel/setup.c       |    2 +-
 arch/x86/kernel/vmlinux.lds.S |    2 +-
 arch/x86/kvm/vmx.c            |    8 +-
 arch/x86/platform/efi/efi.c   |    4 +-
 arch/x86/platform/uv/uv_nmi.c |    6 +-
 drivers/firmware/efi/Kconfig  |    2 +-
 drivers/pci/pci-driver.c      |    2 +-
 include/linux/kexec.h         |   12 +-
 init/initramfs.c              |    4 +-
 kernel/Makefile               |    1 +
 kernel/events/core.c          |    2 +-
 kernel/kexec.c                | 1578 +---------------------------------------
 kernel/kexec_core.c           | 1594 +++++++++++++++++++++++++++++++++++++++++
 kernel/ksysfs.c               |    6 +-
 kernel/printk/printk.c        |    2 +-
 kernel/reboot.c               |    2 +-
 kernel/sysctl.c               |    2 +-
 30 files changed, 1668 insertions(+), 1611 deletions(-)
 create mode 100644 kernel/kexec_core.c
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Quoted 2 lines

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

How about simply move below chunk to arch/Kconfig instead of introducing another ARCH_HAS_KEXEC:
config KEXEC_CORE
bool

BTW, I found I missed one arch that is s390, I need update the patches and resend.

Thanks
Dave

#5 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Hi Dave,

Quoted 24 lines · Dave Young
Quoted 24 lines
Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Quoted 5 lines
Quoted 2 lines

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

No, ARCH_HAS_KEXEC and all other KEXEC config options in arch/Kconfig. All other KEXEC config options should depend on ARCH_HAS_KEXEC, which can be selected by architectures that support kexec.

Quoted 4 lines

How about simply move below chunk to arch/Kconfig instead of introducing another ARCH_HAS_KEXEC:
config KEXEC_CORE
bool

Not all architectures support kexec, hence my proposed dependency on ARCH_HAS_KEXEC.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#6 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Quoted 30 lines · Geert Uytterhoeven

Hi Dave,

Quoted 27 lines · Dave Young
Quoted 26 lines
Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

Quoted 6 lines
Quoted 2 lines

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

No, ARCH_HAS_KEXEC and all other KEXEC config options in arch/Kconfig. All other KEXEC config options should depend on ARCH_HAS_KEXEC, which can be selected by architectures that support kexec.

So it will be like below? problem is KEXEC_FILE is x86 only now, how to handle it then?

arch/Kconfig:
config ARCH_HAS_KEXEC

	...
config KEXEC_CORE
	...	
config KEXEC
	...
config KEXEC_FILE
	...

arch/arm/Kconfig:
select ARCH_HAS_KEXEC

Quoted 8 lines
Quoted 5 lines

How about simply move below chunk to arch/Kconfig instead of introducing another ARCH_HAS_KEXEC:
config KEXEC_CORE
bool

Not all architectures support kexec, hence my proposed dependency on ARCH_HAS_KEXEC.

KEXEC_CORE is not visible in menuconfig, it is selected by KEXEC and KEXEC_FILE so move it in arch/Kconfig is ok?

Quoted 11 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#7 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Hi Dave,

Quoted 39 lines · Dave Young
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Dave Young
Quoted 26 lines
Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

Quoted 6 lines
Quoted 2 lines

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

No, ARCH_HAS_KEXEC and all other KEXEC config options in arch/Kconfig. All other KEXEC config options should depend on ARCH_HAS_KEXEC, which can be selected by architectures that support kexec.

So it will be like below? problem is KEXEC_FILE is x86 only now, how to handle it then?

Quoted 6 lines

arch/Kconfig:
config ARCH_HAS_KEXEC

        ...
config KEXEC_CORE
        ...

config KEXEC

depends on ARCH_HAS_KEXEC

Quoted 2 lines
        ...

config KEXEC_FILE

depends on ARCH_HAS_KEXEC

Quoted 4 lines
        ...

arch/arm/Kconfig:
select ARCH_HAS_KEXEC

Right, that's the idea.

(Minor nit: ARM has dependencies for kexec, so it should be
"select ARCH_HAS_KEXEC if (!SMP || PM_SLEEP_SMP) && !CPU_V7M")

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

How about simply move below chunk to arch/Kconfig instead of introducing another ARCH_HAS_KEXEC:
config KEXEC_CORE
bool

Not all architectures support kexec, hence my proposed dependency on ARCH_HAS_KEXEC.

KEXEC_CORE is not visible in menuconfig, it is selected by KEXEC and KEXEC_FILE so move it in arch/Kconfig is ok?

Yes.

Thanks!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#8 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Hi, Geert

Quoted 49 lines · Geert Uytterhoeven

Hi Dave,

Quoted 39 lines · Dave Young
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Dave Young
Quoted 26 lines
Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

Quoted 6 lines
Quoted 2 lines

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

No, ARCH_HAS_KEXEC and all other KEXEC config options in arch/Kconfig. All other KEXEC config options should depend on ARCH_HAS_KEXEC, which can be selected by architectures that support kexec.

So it will be like below? problem is KEXEC_FILE is x86 only now, how to handle it then?

Quoted 6 lines

arch/Kconfig:
config ARCH_HAS_KEXEC

        ...
config KEXEC_CORE
        ...

config KEXEC

Quoted 6 lines

depends on ARCH_HAS_KEXEC

Quoted 2 lines
        ...

config KEXEC_FILE

depends on ARCH_HAS_KEXEC

But only x86 has KEXEC_FILE, if we make this change one will see KEXEC_FILE on arches other than x86..

Quoted 16 lines
Quoted 5 lines
        ...

arch/arm/Kconfig:
select ARCH_HAS_KEXEC

Right, that's the idea.

(Minor nit: ARM has dependencies for kexec, so it should be
"select ARCH_HAS_KEXEC if (!SMP || PM_SLEEP_SMP) && !CPU_V7M")

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

How about simply move below chunk to arch/Kconfig instead of introducing another ARCH_HAS_KEXEC:
config KEXEC_CORE
bool

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Not all architectures support kexec, hence my proposed dependency on ARCH_HAS_KEXEC.

KEXEC_CORE is not visible in menuconfig, it is selected by KEXEC and KEXEC_FILE so move it in arch/Kconfig is ok?

Yes.

I means how about only moving KEXEC_CORE to general Kconfig, but do not introduce ARCH_HAS_KEXEC..

Thanks
Dave

#9 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Hi Dave,

Quoted 50 lines · Dave Young
Quoted 49 lines · Geert Uytterhoeven
Quoted 39 lines · Dave Young
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Dave Young
Quoted 26 lines
Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

Quoted 6 lines
Quoted 2 lines

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

No, ARCH_HAS_KEXEC and all other KEXEC config options in arch/Kconfig. All other KEXEC config options should depend on ARCH_HAS_KEXEC, which can be selected by architectures that support kexec.

So it will be like below? problem is KEXEC_FILE is x86 only now, how to handle it then?

Quoted 6 lines

arch/Kconfig:
config ARCH_HAS_KEXEC

        ...
config KEXEC_CORE
        ...

config KEXEC

depends on ARCH_HAS_KEXEC

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
        ...

config KEXEC_FILE

depends on ARCH_HAS_KEXEC

But only x86 has KEXEC_FILE, if we make this change one will see KEXEC_FILE on arches other than x86..

Is there any technical reason why it's limited to x86? Else we may need ARCH_HAS_KEXEC_FILE, too :-(

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#10 lore raw

Re: [PATCH 2/3] [PATCH 2/3] kexec: split kexec_load syscall from kexec core code

Hi, Geert

Quoted 56 lines · Geert Uytterhoeven

Hi Dave,

Quoted 53 lines · Dave Young
Quoted 52 lines · Geert Uytterhoeven
Quoted 39 lines · Dave Young
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Dave Young
Quoted 26 lines
Quoted 9 lines
arch/arm/Kconfig +1 -0
index 1c50210..20c48b3 100644
@@ -2001,10 +2001,14 @@ config XIP_PHYS_ADDR
          be linked for and stored to.  This address is dependent on your
          own flash usage.
 
+config KEXEC_CORE

arch/arm/Kconfig config XIP_PHYS_ADDR · line 2014

Quoted 10 lines
arch/arm/Kconfig +3 -0
+       bool
+
 config KEXEC
        bool "Kexec system call (EXPERIMENTAL)"
        depends on (!SMP || PM_SLEEP_SMP)
        depends on !CPU_V7M
+       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

As this KEXEC_CORE is appearing in all arch/*/Kconfig files, I think it's time to add an ARCH_HAS_KEXEC symbol (to a common Kconfig file), and let arch/*/Kconfig select that if the architecture has kexec support.

Then KEXEC and KEXEC_CORE can live in the common Kconfig file, without the need to duplicate it.

Quoted 6 lines
Quoted 2 lines

I'm not sure I understand your idea well, do you means like in arch/Kconfig add ARCH_HAS_KEXEC which depends on KEXEC_CORE?

No, ARCH_HAS_KEXEC and all other KEXEC config options in arch/Kconfig. All other KEXEC config options should depend on ARCH_HAS_KEXEC, which can be selected by architectures that support kexec.

So it will be like below? problem is KEXEC_FILE is x86 only now, how to handle it then?

Quoted 6 lines

arch/Kconfig:
config ARCH_HAS_KEXEC

        ...
config KEXEC_CORE
        ...

config KEXEC

depends on ARCH_HAS_KEXEC

Quoted 2 lines
        ...

config KEXEC_FILE

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

depends on ARCH_HAS_KEXEC

But only x86 has KEXEC_FILE, if we make this change one will see KEXEC_FILE on arches other than x86..

Is there any technical reason why it's limited to x86?

It was implemented for UEFI secure boot, til now only done in x86. Of course it is also doable for other archtecture even if there's no secure boot. Basiclly one need port the userspace code in kexec-tools to kernel space, also need code to verify kernel signature.

Quoted 1 line

Else we may need ARCH_HAS_KEXEC_FILE, too :-(

Hmm, I'm not sure it will have much benefits now to add two ARCH_HAS options. I would prefer current solution, but I can move the KEXEC_CORE to arch/Kconfig

Thanks
Dave

#11 lore raw

PATCH 3/3 kexec-x86-kdebug-h-drop-useless-macro

In reply to [email protected]

in_crash_kexec is only useful for kdump, it will not be used without CONFIG_KEXEC_CORE, thus remove the #else section

---
 arch/x86/include/asm/kdebug.h | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/include/asm/kdebug.h +0 -3
index b130d59..ad83f6d 100644
@@ -31,9 +31,6 @@ extern unsigned long oops_begin(void);
 extern void oops_end(unsigned long, struct pt_regs *, int signr);
 #ifdef CONFIG_KEXEC_CORE
 extern int in_crash_kexec;
-#else
-/* no crash dump is ever in progress if no crash kernel can be kexec'd */
-#define in_crash_kexec 0
 #endif
 
 #endif /* _ASM_X86_KDEBUG_H */
Signature · 1 line
1.8.3.1
author
#12 lore raw
In reply to [email protected]
Quoted 17 lines · Dave Young

Previously Theodore Ts'o brought up an issue about kexec_load syscall bypassing signature verification:
https://lkml.org/lkml/2015/6/14/280

Because we have two kexec load syscall, one kexec_load, another kexec_file_load, the latter one was introduced by Vivek Goyal, it is mainly for supporting UEFI secure boot. kexec_file_load verifies kernel signature, but even if with CONFIG_KEXEC_VERIFY_SIG=y and CONFIG_KEXEC_FILE=y, kexec-tools still can use old syscall and bypass signature verification.

KEXEC_FILE can also be used without UEFI, so kexec can always verify kernel signature for security purpose.

The suggestion in above thread is add a new Kconfig option for kexec common code, here I use KEXEC_CORE, KEXEC and KEXEC_FILE select KEXEC_CORE so one can compile only KEXEC_FILE without old kexec_load syscall.

Quoted 6 lines

There's checkpatch warnings and errors, I would like to send furthuer cleanup patches after this series. Please let me know if you have other suggestions. checkpatch errors are for cases such as assign a value to static variables.

PATCH 3/3 can be sort out from the series if people do not like. It is a cleanup for a macro.

Since it is not related to the Kconfig cleanup thus I will drop it in next update, will send out as a standalone patch later.

Also there's a kexec-tools patch needed for testing KEXEC_FILE only, I forgot to mention, will take it in cover letter when I repost:

---
 kexec/crashdump-elf.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kexec/crashdump-elf.c +5 -4
@@ -145,11 +145,12 @@ int FUNC(struct kexec_info *info,
 
 	count_cpu = nr_cpus;
 	for (i = 0; count_cpu > 0; i++) {
-		if (get_note_info(i, &notes_addr, &notes_len) < 0) {
-			/* This cpu is not present. Skip it. */
-			continue;
-		}
+		int ret;
+
+		ret = get_note_info(i, &notes_addr, &notes_len);
 		count_cpu--;
+		if (ret < 0) /* This cpu is not present. Skip it. */
+			continue;
 
 		phdr = (PHDR *) bufp;
 		bufp += sizeof(PHDR);

Thanks
Dave

author
#13 lore raw
Quoted 22 lines · Dave Young
Quoted 21 lines · Dave Young

Previously Theodore Ts'o brought up an issue about kexec_load syscall bypassing signature verification:
https://lkml.org/lkml/2015/6/14/280

Because we have two kexec load syscall, one kexec_load, another kexec_file_load, the latter one was introduced by Vivek Goyal, it is mainly for supporting UEFI secure boot. kexec_file_load verifies kernel signature, but even if with CONFIG_KEXEC_VERIFY_SIG=y and CONFIG_KEXEC_FILE=y, kexec-tools still can use old syscall and bypass signature verification.

KEXEC_FILE can also be used without UEFI, so kexec can always verify kernel signature for security purpose.

The suggestion in above thread is add a new Kconfig option for kexec common code, here I use KEXEC_CORE, KEXEC and KEXEC_FILE select KEXEC_CORE so one can compile only KEXEC_FILE without old kexec_load syscall.

There's checkpatch warnings and errors, I would like to send furthuer cleanup patches after this series. Please let me know if you have other suggestions. checkpatch errors are for cases such as assign a value to static variables.

Quoted 8 lines
Quoted 2 lines

PATCH 3/3 can be sort out from the series if people do not like. It is a cleanup for a macro.

Since it is not related to the Kconfig cleanup thus I will drop it in next update, will send out as a standalone patch later.

Also there's a kexec-tools patch needed for testing KEXEC_FILE only, I forgot to mention, will take it in cover letter when I repost:

BTW, it is the case below:
kernel: CONFIG_KEXEC_FILE only,
kexec-tools: do not use '-s' option, it should check kexec_load(2) earlier and fail out. but below code is still a fix to a code problem.

kexec -s -p work ok without the fix.

Quoted 34 lines
---
 kexec/crashdump-elf.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
kexec/crashdump-elf.c +5 -4
@@ -145,11 +145,12 @@ int FUNC(struct kexec_info *info,
 
 	count_cpu = nr_cpus;
 	for (i = 0; count_cpu > 0; i++) {
-		if (get_note_info(i, &notes_addr, &notes_len) < 0) {
-			/* This cpu is not present. Skip it. */
-			continue;
-		}
+		int ret;
+
+		ret = get_note_info(i, &notes_addr, &notes_len);
 		count_cpu--;
+		if (ret < 0) /* This cpu is not present. Skip it. */
+			continue;
 
 		phdr = (PHDR *) bufp;
 		bufp += sizeof(PHDR);

Thanks
Dave

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