crash_dump.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef LINUX_CRASH_DUMP_H
  2. #define LINUX_CRASH_DUMP_H
  3. #ifdef CONFIG_CRASH_DUMP
  4. #include <linux/kexec.h>
  5. #include <linux/proc_fs.h>
  6. #include <linux/elf.h>
  7. #define ELFCORE_ADDR_MAX (-1ULL)
  8. #define ELFCORE_ADDR_ERR (-2ULL)
  9. extern unsigned long long elfcorehdr_addr;
  10. extern unsigned long long elfcorehdr_size;
  11. extern ssize_t copy_oldmem_page(unsigned long, char *, size_t,
  12. unsigned long, int);
  13. /* Architecture code defines this if there are other possible ELF
  14. * machine types, e.g. on bi-arch capable hardware. */
  15. #ifndef vmcore_elf_check_arch_cross
  16. #define vmcore_elf_check_arch_cross(x) 0
  17. #endif
  18. /*
  19. * Architecture code can redefine this if there are any special checks
  20. * needed for 64-bit ELF vmcores. In case of 32-bit only architecture,
  21. * this can be set to zero.
  22. */
  23. #ifndef vmcore_elf64_check_arch
  24. #define vmcore_elf64_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x))
  25. #endif
  26. /*
  27. * is_kdump_kernel() checks whether this kernel is booting after a panic of
  28. * previous kernel or not. This is determined by checking if previous kernel
  29. * has passed the elf core header address on command line.
  30. *
  31. * This is not just a test if CONFIG_CRASH_DUMP is enabled or not. It will
  32. * return 1 if CONFIG_CRASH_DUMP=y and if kernel is booting after a panic of
  33. * previous kernel.
  34. */
  35. static inline int is_kdump_kernel(void)
  36. {
  37. return (elfcorehdr_addr != ELFCORE_ADDR_MAX) ? 1 : 0;
  38. }
  39. /* is_vmcore_usable() checks if the kernel is booting after a panic and
  40. * the vmcore region is usable.
  41. *
  42. * This makes use of the fact that due to alignment -2ULL is not
  43. * a valid pointer, much in the vain of IS_ERR(), except
  44. * dealing directly with an unsigned long long rather than a pointer.
  45. */
  46. static inline int is_vmcore_usable(void)
  47. {
  48. return is_kdump_kernel() && elfcorehdr_addr != ELFCORE_ADDR_ERR ? 1 : 0;
  49. }
  50. /* vmcore_unusable() marks the vmcore as unusable,
  51. * without disturbing the logic of is_kdump_kernel()
  52. */
  53. static inline void vmcore_unusable(void)
  54. {
  55. if (is_kdump_kernel())
  56. elfcorehdr_addr = ELFCORE_ADDR_ERR;
  57. }
  58. #define HAVE_OLDMEM_PFN_IS_RAM 1
  59. extern int register_oldmem_pfn_is_ram(int (*fn)(unsigned long pfn));
  60. extern void unregister_oldmem_pfn_is_ram(void);
  61. #else /* !CONFIG_CRASH_DUMP */
  62. static inline int is_kdump_kernel(void) { return 0; }
  63. #endif /* CONFIG_CRASH_DUMP */
  64. extern unsigned long saved_max_pfn;
  65. #endif /* LINUX_CRASHDUMP_H */