Merge tag 'mm-hotfixes-stable-2025-07-11-16-16' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-block.git] / kernel / kexec_internal.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef LINUX_KEXEC_INTERNAL_H
3#define LINUX_KEXEC_INTERNAL_H
4
5#include <linux/kexec.h>
6
7struct kexec_segment;
8
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
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 int old = 0;
27 return atomic_try_cmpxchg_acquire(&__kexec_lock, &old, 1);
28}
29static inline void kexec_unlock(void)
30{
31 atomic_set_release(&__kexec_lock, 0);
32}
33
34#ifdef CONFIG_KEXEC_FILE
35#include <linux/purgatory.h>
36void kimage_file_post_load_cleanup(struct kimage *image);
37extern char kexec_purgatory[];
38extern size_t kexec_purgatory_size;
39#else /* CONFIG_KEXEC_FILE */
40static inline void kimage_file_post_load_cleanup(struct kimage *image) { }
41#endif /* CONFIG_KEXEC_FILE */
42
43struct kexec_buf;
44
45#ifdef CONFIG_KEXEC_HANDOVER
46int kho_locate_mem_hole(struct kexec_buf *kbuf,
47 int (*func)(struct resource *, void *));
48int kho_fill_kimage(struct kimage *image);
49#else
50static inline int kho_locate_mem_hole(struct kexec_buf *kbuf,
51 int (*func)(struct resource *, void *))
52{
53 return 1;
54}
55
56static inline int kho_fill_kimage(struct kimage *image) { return 0; }
57#endif /* CONFIG_KEXEC_HANDOVER */
58#endif /* LINUX_KEXEC_INTERNAL_H */