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