1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef LINUX_CRASH_CORE_H
3 #define LINUX_CRASH_CORE_H
5 #include <linux/linkage.h>
6 #include <linux/elfcore.h>
12 unsigned int max_nr_ranges
;
13 unsigned int nr_ranges
;
14 struct range ranges
[] __counted_by(max_nr_ranges
);
17 #ifdef CONFIG_CRASH_DUMP
19 int crash_shrink_memory(unsigned long new_size
);
20 ssize_t
crash_get_memory_size(void);
22 #ifndef arch_kexec_protect_crashkres
24 * Protection mechanism for crashkernel reserved memory after
25 * the kdump kernel is loaded.
27 * Provide an empty default implementation here -- architecture
28 * code may override this
30 static inline void arch_kexec_protect_crashkres(void) { }
33 #ifndef arch_kexec_unprotect_crashkres
34 static inline void arch_kexec_unprotect_crashkres(void) { }
39 #ifndef arch_crash_handle_hotplug_event
40 static inline void arch_crash_handle_hotplug_event(struct kimage
*image
, void *arg
) { }
43 int crash_check_hotplug_support(void);
45 #ifndef arch_crash_hotplug_support
46 static inline int arch_crash_hotplug_support(struct kimage
*image
, unsigned long kexec_flags
)
52 #ifndef crash_get_elfcorehdr_size
53 static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; }
56 /* Alignment required for elf header segment */
57 #define ELF_CORE_HEADER_ALIGN 4096
59 extern int crash_exclude_mem_range(struct crash_mem
*mem
,
60 unsigned long long mstart
,
61 unsigned long long mend
);
62 extern int crash_prepare_elf64_headers(struct crash_mem
*mem
, int need_kernel_map
,
63 void **addr
, unsigned long *sz
);
68 #define KEXEC_CRASH_HP_NONE 0
69 #define KEXEC_CRASH_HP_ADD_CPU 1
70 #define KEXEC_CRASH_HP_REMOVE_CPU 2
71 #define KEXEC_CRASH_HP_ADD_MEMORY 3
72 #define KEXEC_CRASH_HP_REMOVE_MEMORY 4
73 #define KEXEC_CRASH_HP_INVALID_CPU -1U
75 extern void __crash_kexec(struct pt_regs
*regs
);
76 extern void crash_kexec(struct pt_regs
*regs
);
77 int kexec_should_crash(struct task_struct
*p
);
78 int kexec_crash_loaded(void);
79 void crash_save_cpu(struct pt_regs
*regs
, int cpu
);
80 extern int kimage_crash_copy_vmcoreinfo(struct kimage
*image
);
82 #else /* !CONFIG_CRASH_DUMP*/
86 static inline void __crash_kexec(struct pt_regs
*regs
) { }
87 static inline void crash_kexec(struct pt_regs
*regs
) { }
88 static inline int kexec_should_crash(struct task_struct
*p
) { return 0; }
89 static inline int kexec_crash_loaded(void) { return 0; }
90 static inline void crash_save_cpu(struct pt_regs
*regs
, int cpu
) {};
91 static inline int kimage_crash_copy_vmcoreinfo(struct kimage
*image
) { return 0; };
92 #endif /* CONFIG_CRASH_DUMP*/
94 #endif /* LINUX_CRASH_CORE_H */