Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Dave Young | a43cac0 | 2015-09-09 15:38:51 -0700 | [diff] [blame] | 2 | #ifndef LINUX_KEXEC_INTERNAL_H |
| 3 | #define LINUX_KEXEC_INTERNAL_H |
| 4 | |
| 5 | #include <linux/kexec.h> |
| 6 | |
| 7 | struct kimage *do_kimage_alloc_init(void); |
| 8 | int sanity_check_segment_list(struct kimage *image); |
| 9 | void kimage_free_page_list(struct list_head *list); |
| 10 | void kimage_free(struct kimage *image); |
| 11 | int kimage_load_segment(struct kimage *image, struct kexec_segment *segment); |
| 12 | void kimage_terminate(struct kimage *image); |
| 13 | int kimage_is_destination_range(struct kimage *image, |
| 14 | unsigned long start, unsigned long end); |
| 15 | |
Valentin Schneider | 05c6257 | 2022-06-30 23:32:58 +0100 | [diff] [blame] | 16 | /* |
| 17 | * Whatever is used to serialize accesses to the kexec_crash_image needs to be |
| 18 | * NMI safe, as __crash_kexec() can happen during nmi_panic(), so here we use a |
| 19 | * "simple" atomic variable that is acquired with a cmpxchg(). |
| 20 | */ |
| 21 | extern atomic_t __kexec_lock; |
| 22 | static inline bool kexec_trylock(void) |
| 23 | { |
| 24 | return atomic_cmpxchg_acquire(&__kexec_lock, 0, 1) == 0; |
| 25 | } |
| 26 | static inline void kexec_unlock(void) |
| 27 | { |
| 28 | atomic_set_release(&__kexec_lock, 0); |
| 29 | } |
Dave Young | a43cac0 | 2015-09-09 15:38:51 -0700 | [diff] [blame] | 30 | |
| 31 | #ifdef CONFIG_KEXEC_FILE |
Thomas Gleixner | 40c50c1 | 2017-03-10 13:17:18 +0100 | [diff] [blame] | 32 | #include <linux/purgatory.h> |
Dave Young | a43cac0 | 2015-09-09 15:38:51 -0700 | [diff] [blame] | 33 | void kimage_file_post_load_cleanup(struct kimage *image); |
Kees Cook | e2ae8ab | 2017-07-12 14:35:58 -0700 | [diff] [blame] | 34 | extern char kexec_purgatory[]; |
| 35 | extern size_t kexec_purgatory_size; |
Dave Young | a43cac0 | 2015-09-09 15:38:51 -0700 | [diff] [blame] | 36 | #else /* CONFIG_KEXEC_FILE */ |
| 37 | static inline void kimage_file_post_load_cleanup(struct kimage *image) { } |
| 38 | #endif /* CONFIG_KEXEC_FILE */ |
| 39 | #endif /* LINUX_KEXEC_INTERNAL_H */ |