kexec_internal.h 1.3 KB

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