mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-28 16:52:18 +00:00
79365026f8
Commit a72bbec70d
("crash: hotplug support for kexec_load()")
introduced a new kexec flag, `KEXEC_UPDATE_ELFCOREHDR`. Kexec tool uses
this flag to indicate to the kernel that it is safe to modify the
elfcorehdr of the kdump image loaded using the kexec_load system call.
However, it is possible that architectures may need to update kexec
segments other then elfcorehdr. For example, FDT (Flatten Device Tree)
on PowerPC. Introducing a new kexec flag for every new kexec segment
may not be a good solution. Hence, a generic kexec flag bit,
`KEXEC_CRASH_HOTPLUG_SUPPORT`, is introduced to share the CPU/Memory
hotplug support intent between the kexec tool and the kernel for the
kexec_load system call.
Now we have two kexec flags that enables crash hotplug support for
kexec_load system call. First is KEXEC_UPDATE_ELFCOREHDR (only used in
x86), and second is KEXEC_CRASH_HOTPLUG_SUPPORT (for all architectures).
To simplify the process of finding and reporting the crash hotplug
support the following changes are introduced.
1. Define arch specific function to process the kexec flags and
determine crash hotplug support
2. Rename the @update_elfcorehdr member of struct kimage to
@hotplug_support and populate it for both kexec_load and
kexec_file_load syscalls, because architecture can update more than
one kexec segment
3. Let generic function crash_check_hotplug_support report hotplug
support for loaded kdump image based on value of @hotplug_support
To bring the x86 crash hotplug support in line with the above points,
the following changes have been made:
- Introduce the arch_crash_hotplug_support function to process kexec
flags and determine crash hotplug support
- Remove the arch_crash_hotplug_[cpu|memory]_support functions
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Acked-by: Baoquan He <bhe@redhat.com>
Acked-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240326055413.186534-3-sourabhjain@linux.ibm.com
95 lines
2.6 KiB
C
95 lines
2.6 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;
|
|
|
|
struct crash_mem {
|
|
unsigned int max_nr_ranges;
|
|
unsigned int nr_ranges;
|
|
struct range ranges[] __counted_by(max_nr_ranges);
|
|
};
|
|
|
|
#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, void *arg) { }
|
|
#endif
|
|
|
|
int crash_check_hotplug_support(void);
|
|
|
|
#ifndef arch_crash_hotplug_support
|
|
static inline int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags)
|
|
{
|
|
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
|
|
|
|
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 */
|