crash_dump.h 2.1 KB

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