| 1 |
|
| 2 | #ifndef LINUX_CRASH_CORE_H
|
| 3 | #define LINUX_CRASH_CORE_H
|
| 4 |
|
| 5 | #include <linux/linkage.h>
|
| 6 | #include <linux/elfcore.h>
|
| 7 | #include <linux/elf.h>
|
| 8 |
|
| 9 | struct kimage;
|
| 10 |
|
| 11 | struct crash_mem {
|
| 12 | unsigned int max_nr_ranges;
|
| 13 | unsigned int nr_ranges;
|
| 14 | struct range ranges[] __counted_by(max_nr_ranges);
|
| 15 | };
|
| 16 |
|
| 17 | #ifdef CONFIG_CRASH_DUMP
|
| 18 |
|
| 19 | int crash_shrink_memory(unsigned long new_size);
|
| 20 | ssize_t crash_get_memory_size(void);
|
| 21 |
|
| 22 | #ifndef arch_kexec_protect_crashkres
|
| 23 | |
| 24 | * Protection mechanism for crashkernel reserved memory after
|
| 25 | * the kdump kernel is loaded.
|
| 26 | *
|
| 27 | * Provide an empty default implementation here -- architecture
|
| 28 | * code may override this
|
| 29 |
|
| 30 | static inline void arch_kexec_protect_crashkres(void) { }
|
| 31 | #endif
|
| 32 |
|
| 33 | #ifndef arch_kexec_unprotect_crashkres
|
| 34 | static inline void arch_kexec_unprotect_crashkres(void) { }
|
| 35 | #endif
|
| 36 |
|
| 37 | #ifndef arch_crash_handle_hotplug_event
|
| 38 | static inline void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) { }
|
| 39 | #endif
|
| 40 |
|
| 41 | int crash_check_hotplug_support(void);
|
| 42 |
|
| 43 | #ifndef arch_crash_hotplug_support
|
| 44 | static inline int arch_crash_hotplug_support(struct kimage *image, unsigned long kexec_flags)
|
| 45 | {
|
| 46 | return 0;
|
| 47 | }
|
| 48 | #endif
|
| 49 |
|
| 50 | #ifndef crash_get_elfcorehdr_size
|
| 51 | static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; }
|
| 52 | #endif
|
| 53 |
|
| 54 |
|
| 55 | #define ELF_CORE_HEADER_ALIGN 4096
|
| 56 |
|
| 57 | extern int crash_exclude_mem_range(struct crash_mem *mem,
|
| 58 | unsigned long long mstart,
|
| 59 | unsigned long long mend);
|
| 60 | extern int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
|
| 61 | void **addr, unsigned long *sz);
|
| 62 | extern int crash_prepare_headers(int need_kernel_map, void **addr,
|
| 63 | unsigned long *sz, unsigned long *nr_mem_ranges);
|
| 64 | extern int crash_exclude_core_ranges(struct crash_mem **cmem);
|
| 65 |
|
| 66 | struct kimage;
|
| 67 | struct kexec_segment;
|
| 68 |
|
| 69 | #define KEXEC_CRASH_HP_NONE 0
|
| 70 | #define KEXEC_CRASH_HP_ADD_CPU 1
|
| 71 | #define KEXEC_CRASH_HP_REMOVE_CPU 2
|
| 72 | #define KEXEC_CRASH_HP_ADD_MEMORY 3
|
| 73 | #define KEXEC_CRASH_HP_REMOVE_MEMORY 4
|
| 74 | #define KEXEC_CRASH_HP_INVALID_CPU -1U
|
| 75 |
|
| 76 | extern void __crash_kexec(struct pt_regs *regs);
|
| 77 | extern void crash_kexec(struct pt_regs *regs);
|
| 78 | int kexec_should_crash(struct task_struct *p);
|
| 79 | int kexec_crash_loaded(void);
|
| 80 | void crash_save_cpu(struct pt_regs *regs, int cpu);
|
| 81 | extern int kimage_crash_copy_vmcoreinfo(struct kimage *image);
|
| 82 | extern unsigned int arch_get_system_nr_ranges(void);
|
| 83 | extern int arch_crash_populate_cmem(struct crash_mem *cmem);
|
| 84 | extern int arch_crash_exclude_ranges(struct crash_mem *cmem);
|
| 85 | extern int arch_crash_exclude_mem_range(struct crash_mem **mem,
|
| 86 | unsigned long long mstart,
|
| 87 | unsigned long long mend);
|
| 88 |
|
| 89 | #else
|
| 90 | struct pt_regs;
|
| 91 | struct task_struct;
|
| 92 | struct kimage;
|
| 93 | static inline void __crash_kexec(struct pt_regs *regs) { }
|
| 94 | static inline void crash_kexec(struct pt_regs *regs) { }
|
| 95 | static inline int kexec_should_crash(struct task_struct *p) { return 0; }
|
| 96 | static inline int kexec_crash_loaded(void) { return 0; }
|
| 97 | static inline void crash_save_cpu(struct pt_regs *regs, int cpu) {};
|
| 98 | static inline int kimage_crash_copy_vmcoreinfo(struct kimage *image) { return 0; };
|
| 99 | #endif
|
| 100 |
|
| 101 | #ifdef CONFIG_CRASH_DM_CRYPT
|
| 102 | int crash_load_dm_crypt_keys(struct kimage *image);
|
| 103 | ssize_t dm_crypt_keys_read(char *buf, size_t count, u64 *ppos);
|
| 104 | #else
|
| 105 | static inline int crash_load_dm_crypt_keys(struct kimage *image) {return 0; }
|
| 106 | #endif
|
| 107 |
|
| 108 | #endif
|