Skip to content

Commit 2965faa

Browse files
daveyoungtorvalds
authored andcommitted
kexec: split kexec_load syscall from kexec core code
There are two kexec load syscalls, kexec_load another and 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 Ted Ts'o, 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. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Dave Young <dyoung@redhat.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Petr Tesarik <ptesarik@suse.cz> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Josh Boyer <jwboyer@fedoraproject.org> Cc: David Howells <dhowells@redhat.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a43cac0 commit 2965faa

File tree

32 files changed

+1560
-1527
lines changed

32 files changed

+1560
-1527
lines changed

arch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# General architecture dependent options
33
#
44

5+
config KEXEC_CORE
6+
bool
7+
58
config OPROFILE
69
tristate "OProfile system profiling"
710
depends on PROFILING

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,7 @@ config KEXEC
20202020
bool "Kexec system call (EXPERIMENTAL)"
20212021
depends on (!SMP || PM_SLEEP_SMP)
20222022
depends on !CPU_V7M
2023+
select KEXEC_CORE
20232024
help
20242025
kexec is a system call that implements the ability to shutdown your
20252026
current kernel, and to start another kernel. It is like a reboot

arch/ia64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ source "drivers/sn/Kconfig"
518518
config KEXEC
519519
bool "kexec system call"
520520
depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
521+
select KEXEC_CORE
521522
help
522523
kexec is a system call that implements the ability to shutdown your
523524
current kernel, and to start another kernel. It is like a reboot

arch/m68k/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ config MMU_SUN3
9595
config KEXEC
9696
bool "kexec system call"
9797
depends on M68KCLASSIC
98+
select KEXEC_CORE
9899
help
99100
kexec is a system call that implements the ability to shutdown your
100101
current kernel, and to start another kernel. It is like a reboot

arch/mips/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,6 +2597,7 @@ source "kernel/Kconfig.preempt"
25972597

25982598
config KEXEC
25992599
bool "Kexec system call"
2600+
select KEXEC_CORE
26002601
help
26012602
kexec is a system call that implements the ability to shutdown your
26022603
current kernel, and to start another kernel. It is like a reboot

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ config PPC64_SUPPORTS_MEMORY_FAILURE
420420
config KEXEC
421421
bool "kexec system call"
422422
depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
423+
select KEXEC_CORE
423424
help
424425
kexec is a system call that implements the ability to shutdown your
425426
current kernel, and to start another kernel. It is like a reboot

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
4848

4949
config KEXEC
5050
def_bool y
51+
select KEXEC_CORE
5152

5253
config AUDIT_ARCH
5354
def_bool y

arch/sh/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ source kernel/Kconfig.hz
602602
config KEXEC
603603
bool "kexec system call (EXPERIMENTAL)"
604604
depends on SUPERH32 && MMU
605+
select KEXEC_CORE
605606
help
606607
kexec is a system call that implements the ability to shutdown your
607608
current kernel, and to start another kernel. It is like a reboot

arch/tile/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ source "kernel/Kconfig.hz"
205205

206206
config KEXEC
207207
bool "kexec system call"
208+
select KEXEC_CORE
208209
---help---
209210
kexec is a system call that implements the ability to shutdown your
210211
current kernel, and to start another kernel. It is like a reboot

arch/x86/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ source kernel/Kconfig.hz
17541754

17551755
config KEXEC
17561756
bool "kexec system call"
1757+
select KEXEC_CORE
17571758
---help---
17581759
kexec is a system call that implements the ability to shutdown your
17591760
current kernel, and to start another kernel. It is like a reboot
@@ -1770,8 +1771,8 @@ config KEXEC
17701771

17711772
config KEXEC_FILE
17721773
bool "kexec file based system call"
1774+
select KEXEC_CORE
17731775
select BUILD_BIN2C
1774-
depends on KEXEC
17751776
depends on X86_64
17761777
depends on CRYPTO=y
17771778
depends on CRYPTO_SHA256=y

arch/x86/boot/header.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ xloadflags:
414414
# define XLF23 0
415415
#endif
416416

417-
#if defined(CONFIG_X86_64) && defined(CONFIG_EFI) && defined(CONFIG_KEXEC)
417+
#if defined(CONFIG_X86_64) && defined(CONFIG_EFI) && defined(CONFIG_KEXEC_CORE)
418418
# define XLF4 XLF_EFI_KEXEC
419419
#else
420420
# define XLF4 0

arch/x86/include/asm/kdebug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern void show_trace(struct task_struct *t, struct pt_regs *regs,
2929
extern void __show_regs(struct pt_regs *regs, int all);
3030
extern unsigned long oops_begin(void);
3131
extern void oops_end(unsigned long, struct pt_regs *, int signr);
32-
#ifdef CONFIG_KEXEC
32+
#ifdef CONFIG_KEXEC_CORE
3333
extern int in_crash_kexec;
3434
#else
3535
/* no crash dump is ever in progress if no crash kernel can be kexec'd */

arch/x86/kernel/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ obj-$(CONFIG_LIVEPATCH) += livepatch.o
7171
obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
7272
obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
7373
obj-$(CONFIG_X86_TSC) += trace_clock.o
74-
obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
75-
obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
74+
obj-$(CONFIG_KEXEC_CORE) += machine_kexec_$(BITS).o
75+
obj-$(CONFIG_KEXEC_CORE) += relocate_kernel_$(BITS).o crash.o
7676
obj-$(CONFIG_KEXEC_FILE) += kexec-bzimage64.o
7777
obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
7878
obj-y += kprobes/

arch/x86/kernel/kvmclock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static void kvm_setup_secondary_clock(void)
200200
* kind of shutdown from our side, we unregister the clock by writting anything
201201
* that does not have the 'enable' bit set in the msr
202202
*/
203-
#ifdef CONFIG_KEXEC
203+
#ifdef CONFIG_KEXEC_CORE
204204
static void kvm_crash_shutdown(struct pt_regs *regs)
205205
{
206206
native_write_msr(msr_kvm_system_time, 0, 0);
@@ -259,7 +259,7 @@ void __init kvmclock_init(void)
259259
x86_platform.save_sched_clock_state = kvm_save_sched_clock_state;
260260
x86_platform.restore_sched_clock_state = kvm_restore_sched_clock_state;
261261
machine_ops.shutdown = kvm_shutdown;
262-
#ifdef CONFIG_KEXEC
262+
#ifdef CONFIG_KEXEC_CORE
263263
machine_ops.crash_shutdown = kvm_crash_shutdown;
264264
#endif
265265
kvm_get_preset_lpj();

arch/x86/kernel/reboot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ struct machine_ops machine_ops = {
673673
.emergency_restart = native_machine_emergency_restart,
674674
.restart = native_machine_restart,
675675
.halt = native_machine_halt,
676-
#ifdef CONFIG_KEXEC
676+
#ifdef CONFIG_KEXEC_CORE
677677
.crash_shutdown = native_machine_crash_shutdown,
678678
#endif
679679
};
@@ -703,7 +703,7 @@ void machine_halt(void)
703703
machine_ops.halt();
704704
}
705705

706-
#ifdef CONFIG_KEXEC
706+
#ifdef CONFIG_KEXEC_CORE
707707
void machine_crash_shutdown(struct pt_regs *regs)
708708
{
709709
machine_ops.crash_shutdown(regs);

arch/x86/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static void __init memblock_x86_reserve_range_setup_data(void)
478478
* --------- Crashkernel reservation ------------------------------
479479
*/
480480

481-
#ifdef CONFIG_KEXEC
481+
#ifdef CONFIG_KEXEC_CORE
482482

483483
/*
484484
* Keep the crash kernel below this limit. On 32 bits earlier kernels

arch/x86/kernel/vmlinux.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ INIT_PER_CPU(irq_stack_union);
364364

365365
#endif /* CONFIG_X86_32 */
366366

367-
#ifdef CONFIG_KEXEC
367+
#ifdef CONFIG_KEXEC_CORE
368368
#include <asm/kexec.h>
369369

370370
. = ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,

arch/x86/kvm/vmx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ static void vmcs_load(struct vmcs *vmcs)
12641264
vmcs, phys_addr);
12651265
}
12661266

1267-
#ifdef CONFIG_KEXEC
1267+
#ifdef CONFIG_KEXEC_CORE
12681268
/*
12691269
* This bitmap is used to indicate whether the vmclear
12701270
* operation is enabled on all cpus. All disabled by
@@ -1302,7 +1302,7 @@ static void crash_vmclear_local_loaded_vmcss(void)
13021302
#else
13031303
static inline void crash_enable_local_vmclear(int cpu) { }
13041304
static inline void crash_disable_local_vmclear(int cpu) { }
1305-
#endif /* CONFIG_KEXEC */
1305+
#endif /* CONFIG_KEXEC_CORE */
13061306

13071307
static void __loaded_vmcs_clear(void *arg)
13081308
{
@@ -10411,7 +10411,7 @@ static int __init vmx_init(void)
1041110411
if (r)
1041210412
return r;
1041310413

10414-
#ifdef CONFIG_KEXEC
10414+
#ifdef CONFIG_KEXEC_CORE
1041510415
rcu_assign_pointer(crash_vmclear_loaded_vmcss,
1041610416
crash_vmclear_local_loaded_vmcss);
1041710417
#endif
@@ -10421,7 +10421,7 @@ static int __init vmx_init(void)
1042110421

1042210422
static void __exit vmx_exit(void)
1042310423
{
10424-
#ifdef CONFIG_KEXEC
10424+
#ifdef CONFIG_KEXEC_CORE
1042510425
RCU_INIT_POINTER(crash_vmclear_loaded_vmcss, NULL);
1042610426
synchronize_rcu();
1042710427
#endif

arch/x86/platform/efi/efi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ static void __init get_systab_virt_addr(efi_memory_desc_t *md)
650650

651651
static void __init save_runtime_map(void)
652652
{
653-
#ifdef CONFIG_KEXEC
653+
#ifdef CONFIG_KEXEC_CORE
654654
efi_memory_desc_t *md;
655655
void *tmp, *p, *q = NULL;
656656
int count = 0;
@@ -748,7 +748,7 @@ static void * __init efi_map_regions(int *count, int *pg_shift)
748748

749749
static void __init kexec_enter_virtual_mode(void)
750750
{
751-
#ifdef CONFIG_KEXEC
751+
#ifdef CONFIG_KEXEC_CORE
752752
efi_memory_desc_t *md;
753753
void *p;
754754

arch/x86/platform/uv/uv_nmi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static void uv_nmi_touch_watchdogs(void)
492492
touch_nmi_watchdog();
493493
}
494494

495-
#if defined(CONFIG_KEXEC)
495+
#if defined(CONFIG_KEXEC_CORE)
496496
static atomic_t uv_nmi_kexec_failed;
497497
static void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs)
498498
{
@@ -519,13 +519,13 @@ static void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs)
519519
uv_nmi_sync_exit(0);
520520
}
521521

522-
#else /* !CONFIG_KEXEC */
522+
#else /* !CONFIG_KEXEC_CORE */
523523
static inline void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs)
524524
{
525525
if (master)
526526
pr_err("UV: NMI kdump: KEXEC not supported in this kernel\n");
527527
}
528-
#endif /* !CONFIG_KEXEC */
528+
#endif /* !CONFIG_KEXEC_CORE */
529529

530530
#ifdef CONFIG_KGDB
531531
#ifdef CONFIG_KGDB_KDB

drivers/firmware/efi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ config EFI_VARS_PSTORE_DEFAULT_DISABLE
4343

4444
config EFI_RUNTIME_MAP
4545
bool "Export efi runtime maps to sysfs"
46-
depends on X86 && EFI && KEXEC
46+
depends on X86 && EFI && KEXEC_CORE
4747
default y
4848
help
4949
Export efi runtime memory maps to /sys/firmware/efi/runtime-map.

drivers/pci/pci-driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static void pci_device_shutdown(struct device *dev)
467467
pci_msi_shutdown(pci_dev);
468468
pci_msix_shutdown(pci_dev);
469469

470-
#ifdef CONFIG_KEXEC
470+
#ifdef CONFIG_KEXEC_CORE
471471
/*
472472
* If this is a kexec reboot, turn off Bus Master bit on the
473473
* device to tell it to not continue to do DMA. Don't touch

include/linux/kexec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <uapi/linux/kexec.h>
1818

19-
#ifdef CONFIG_KEXEC
19+
#ifdef CONFIG_KEXEC_CORE
2020
#include <linux/list.h>
2121
#include <linux/linkage.h>
2222
#include <linux/compat.h>
@@ -329,13 +329,13 @@ int __weak arch_kexec_apply_relocations_add(const Elf_Ehdr *ehdr,
329329
int __weak arch_kexec_apply_relocations(const Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
330330
unsigned int relsec);
331331

332-
#else /* !CONFIG_KEXEC */
332+
#else /* !CONFIG_KEXEC_CORE */
333333
struct pt_regs;
334334
struct task_struct;
335335
static inline void crash_kexec(struct pt_regs *regs) { }
336336
static inline int kexec_should_crash(struct task_struct *p) { return 0; }
337337
#define kexec_in_progress false
338-
#endif /* CONFIG_KEXEC */
338+
#endif /* CONFIG_KEXEC_CORE */
339339

340340
#endif /* !defined(__ASSEBMLY__) */
341341

init/initramfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,14 @@ extern unsigned long __initramfs_size;
526526

527527
static void __init free_initrd(void)
528528
{
529-
#ifdef CONFIG_KEXEC
529+
#ifdef CONFIG_KEXEC_CORE
530530
unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
531531
unsigned long crashk_end = (unsigned long)__va(crashk_res.end);
532532
#endif
533533
if (do_retain_initrd)
534534
goto skip;
535535

536-
#ifdef CONFIG_KEXEC
536+
#ifdef CONFIG_KEXEC_CORE
537537
/*
538538
* If the initrd region is overlapped with crashkernel reserved region,
539539
* free only memory that is not part of crashkernel region.

kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ obj-$(CONFIG_MODULES) += module.o
4949
obj-$(CONFIG_MODULE_SIG) += module_signing.o
5050
obj-$(CONFIG_KALLSYMS) += kallsyms.o
5151
obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
52+
obj-$(CONFIG_KEXEC_CORE) += kexec_core.o
5253
obj-$(CONFIG_KEXEC) += kexec.o
5354
obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
5455
obj-$(CONFIG_BACKTRACE_SELF_TEST) += backtracetest.o

kernel/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9094,7 +9094,7 @@ static void perf_event_init_cpu(int cpu)
90949094
mutex_unlock(&swhash->hlist_mutex);
90959095
}
90969096

9097-
#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC
9097+
#if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE
90989098
static void __perf_event_exit_context(void *__info)
90999099
{
91009100
struct remove_event re = { .detach_group = true };

0 commit comments

Comments
 (0)