crash_dump.h 2.8 KB

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