mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
02aff84805
Currently, KEXEC_CORE select CRASH_CORE automatically because crash codes need be built in to avoid compiling error when building kexec code even though the crash dumping functionality is not enabled. E.g -------------------- CONFIG_CRASH_CORE=y CONFIG_KEXEC_CORE=y CONFIG_KEXEC=y CONFIG_KEXEC_FILE=y --------------------- After splitting out crashkernel reservation code and vmcoreinfo exporting code, there's only crash related code left in kernel/crash_core.c. Now move crash related codes from kexec_core.c to crash_core.c and only build it in when CONFIG_CRASH_DUMP=y. And also wrap up crash codes inside CONFIG_CRASH_DUMP ifdeffery scope, or replace inappropriate CONFIG_KEXEC_CORE ifdef with CONFIG_CRASH_DUMP ifdef in generic kernel files. With these changes, crash_core codes are abstracted from kexec codes and can be disabled at all if only kexec reboot feature is wanted. Link: https://lkml.kernel.org/r/20240124051254.67105-5-bhe@redhat.com Signed-off-by: Baoquan He <bhe@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Hari Bathini <hbathini@linux.ibm.com> Cc: Pingfan Liu <piliu@redhat.com> Cc: Klara Modin <klarasmodin@gmail.com> Cc: Michael Kelley <mhklinux@outlook.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Yang Li <yang.lee@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
95 lines
2.7 KiB
C
95 lines
2.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef LINUX_CRASH_CORE_H
|
|
#define LINUX_CRASH_CORE_H
|
|
|
|
#include <linux/linkage.h>
|
|
#include <linux/elfcore.h>
|
|
#include <linux/elf.h>
|
|
|
|
struct kimage;
|
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
|
|
|
int crash_shrink_memory(unsigned long new_size);
|
|
ssize_t crash_get_memory_size(void);
|
|
|
|
#ifndef arch_kexec_protect_crashkres
|
|
/*
|
|
* Protection mechanism for crashkernel reserved memory after
|
|
* the kdump kernel is loaded.
|
|
*
|
|
* Provide an empty default implementation here -- architecture
|
|
* code may override this
|
|
*/
|
|
static inline void arch_kexec_protect_crashkres(void) { }
|
|
#endif
|
|
|
|
#ifndef arch_kexec_unprotect_crashkres
|
|
static inline void arch_kexec_unprotect_crashkres(void) { }
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef arch_crash_handle_hotplug_event
|
|
static inline void arch_crash_handle_hotplug_event(struct kimage *image) { }
|
|
#endif
|
|
|
|
int crash_check_update_elfcorehdr(void);
|
|
|
|
#ifndef crash_hotplug_cpu_support
|
|
static inline int crash_hotplug_cpu_support(void) { return 0; }
|
|
#endif
|
|
|
|
#ifndef crash_hotplug_memory_support
|
|
static inline int crash_hotplug_memory_support(void) { return 0; }
|
|
#endif
|
|
|
|
#ifndef crash_get_elfcorehdr_size
|
|
static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; }
|
|
#endif
|
|
|
|
/* Alignment required for elf header segment */
|
|
#define ELF_CORE_HEADER_ALIGN 4096
|
|
|
|
struct crash_mem {
|
|
unsigned int max_nr_ranges;
|
|
unsigned int nr_ranges;
|
|
struct range ranges[] __counted_by(max_nr_ranges);
|
|
};
|
|
|
|
extern int crash_exclude_mem_range(struct crash_mem *mem,
|
|
unsigned long long mstart,
|
|
unsigned long long mend);
|
|
extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
|
|
void **addr, unsigned long *sz);
|
|
|
|
struct kimage;
|
|
struct kexec_segment;
|
|
|
|
#define KEXEC_CRASH_HP_NONE 0
|
|
#define KEXEC_CRASH_HP_ADD_CPU 1
|
|
#define KEXEC_CRASH_HP_REMOVE_CPU 2
|
|
#define KEXEC_CRASH_HP_ADD_MEMORY 3
|
|
#define KEXEC_CRASH_HP_REMOVE_MEMORY 4
|
|
#define KEXEC_CRASH_HP_INVALID_CPU -1U
|
|
|
|
extern void __crash_kexec(struct pt_regs *regs);
|
|
extern void crash_kexec(struct pt_regs *regs);
|
|
int kexec_should_crash(struct task_struct *p);
|
|
int kexec_crash_loaded(void);
|
|
void crash_save_cpu(struct pt_regs *regs, int cpu);
|
|
extern int kimage_crash_copy_vmcoreinfo(struct kimage *image);
|
|
|
|
#else /* !CONFIG_CRASH_DUMP*/
|
|
struct pt_regs;
|
|
struct task_struct;
|
|
struct kimage;
|
|
static inline void __crash_kexec(struct pt_regs *regs) { }
|
|
static inline void crash_kexec(struct pt_regs *regs) { }
|
|
static inline int kexec_should_crash(struct task_struct *p) { return 0; }
|
|
static inline int kexec_crash_loaded(void) { return 0; }
|
|
static inline void crash_save_cpu(struct pt_regs *regs, int cpu) {};
|
|
static inline int kimage_crash_copy_vmcoreinfo(struct kimage *image) { return 0; };
|
|
#endif /* CONFIG_CRASH_DUMP*/
|
|
|
|
#endif /* LINUX_CRASH_CORE_H */
|