kexec_32.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef _I386_KEXEC_H
  2. #define _I386_KEXEC_H
  3. #define PA_CONTROL_PAGE 0
  4. #define VA_CONTROL_PAGE 1
  5. #define PA_PGD 2
  6. #define VA_PGD 3
  7. #define PA_PTE_0 4
  8. #define VA_PTE_0 5
  9. #define PA_PTE_1 6
  10. #define VA_PTE_1 7
  11. #ifdef CONFIG_X86_PAE
  12. #define PA_PMD_0 8
  13. #define VA_PMD_0 9
  14. #define PA_PMD_1 10
  15. #define VA_PMD_1 11
  16. #define PAGES_NR 12
  17. #else
  18. #define PAGES_NR 8
  19. #endif
  20. #ifndef __ASSEMBLY__
  21. #include <asm/ptrace.h>
  22. #include <asm/string.h>
  23. /*
  24. * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
  25. * I.e. Maximum page that is mapped directly into kernel memory,
  26. * and kmap is not required.
  27. */
  28. /* Maximum physical address we can use pages from */
  29. #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
  30. /* Maximum address we can reach in physical address mode */
  31. #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
  32. /* Maximum address we can use for the control code buffer */
  33. #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
  34. #define KEXEC_CONTROL_CODE_SIZE 4096
  35. /* The native architecture */
  36. #define KEXEC_ARCH KEXEC_ARCH_386
  37. /* We can also handle crash dumps from 64 bit kernel. */
  38. #define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
  39. /* CPU does not save ss and esp on stack if execution is already
  40. * running in kernel mode at the time of NMI occurrence. This code
  41. * fixes it.
  42. */
  43. static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
  44. struct pt_regs *oldregs)
  45. {
  46. memcpy(newregs, oldregs, sizeof(*newregs));
  47. newregs->esp = (unsigned long)&(oldregs->esp);
  48. __asm__ __volatile__(
  49. "xorl %%eax, %%eax\n\t"
  50. "movw %%ss, %%ax\n\t"
  51. :"=a"(newregs->xss));
  52. }
  53. /*
  54. * This function is responsible for capturing register states if coming
  55. * via panic otherwise just fix up the ss and esp if coming via kernel
  56. * mode exception.
  57. */
  58. static inline void crash_setup_regs(struct pt_regs *newregs,
  59. struct pt_regs *oldregs)
  60. {
  61. if (oldregs)
  62. crash_fixup_ss_esp(newregs, oldregs);
  63. else {
  64. __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx));
  65. __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx));
  66. __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx));
  67. __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi));
  68. __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi));
  69. __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp));
  70. __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax));
  71. __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp));
  72. __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss));
  73. __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs));
  74. __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds));
  75. __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes));
  76. __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags));
  77. newregs->eip = (unsigned long)current_text_addr();
  78. }
  79. }
  80. asmlinkage NORET_TYPE void
  81. relocate_kernel(unsigned long indirection_page,
  82. unsigned long control_page,
  83. unsigned long start_address,
  84. unsigned int has_pae) ATTRIB_NORET;
  85. #endif /* __ASSEMBLY__ */
  86. #endif /* _I386_KEXEC_H */