Merge tag 'mailbox-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar...
[linux-2.6-block.git] / kernel / kexec_internal.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
a43cac0d
DY
2#ifndef LINUX_KEXEC_INTERNAL_H
3#define LINUX_KEXEC_INTERNAL_H
4
5#include <linux/kexec.h>
6
2c44b67e
BH
7struct kexec_segment;
8
a43cac0d
DY
9struct kimage *do_kimage_alloc_init(void);
10int sanity_check_segment_list(struct kimage *image);
11void kimage_free_page_list(struct list_head *list);
12void kimage_free(struct kimage *image);
13int kimage_load_segment(struct kimage *image, struct kexec_segment *segment);
14void kimage_terminate(struct kimage *image);
15int kimage_is_destination_range(struct kimage *image,
16 unsigned long start, unsigned long end);
17
05c62574
VS
18/*
19 * Whatever is used to serialize accesses to the kexec_crash_image needs to be
20 * NMI safe, as __crash_kexec() can happen during nmi_panic(), so here we use a
21 * "simple" atomic variable that is acquired with a cmpxchg().
22 */
23extern atomic_t __kexec_lock;
24static inline bool kexec_trylock(void)
25{
26 return atomic_cmpxchg_acquire(&__kexec_lock, 0, 1) == 0;
27}
28static inline void kexec_unlock(void)
29{
30 atomic_set_release(&__kexec_lock, 0);
31}
a43cac0d
DY
32
33#ifdef CONFIG_KEXEC_FILE
40c50c1f 34#include <linux/purgatory.h>
a43cac0d 35void kimage_file_post_load_cleanup(struct kimage *image);
e2ae8ab4
KC
36extern char kexec_purgatory[];
37extern size_t kexec_purgatory_size;
a43cac0d
DY
38#else /* CONFIG_KEXEC_FILE */
39static inline void kimage_file_post_load_cleanup(struct kimage *image) { }
40#endif /* CONFIG_KEXEC_FILE */
41#endif /* LINUX_KEXEC_INTERNAL_H */