kexec.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/fixmap.h>
  22. #include <asm/ptrace.h>
  23. #include <asm/string.h>
  24. /*
  25. * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
  26. * I.e. Maximum page that is mapped directly into kernel memory,
  27. * and kmap is not required.
  28. *
  29. * Someone correct me if FIXADDR_START - PAGEOFFSET is not the correct
  30. * calculation for the amount of memory directly mappable into the
  31. * kernel memory space.
  32. */
  33. /* Maximum physical address we can use pages from */
  34. #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
  35. /* Maximum address we can reach in physical address mode */
  36. #define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
  37. /* Maximum address we can use for the control code buffer */
  38. #define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
  39. #define KEXEC_CONTROL_CODE_SIZE 4096
  40. /* The native architecture */
  41. #define KEXEC_ARCH KEXEC_ARCH_386
  42. #define MAX_NOTE_BYTES 1024
  43. /* CPU does not save ss and esp on stack if execution is already
  44. * running in kernel mode at the time of NMI occurrence. This code
  45. * fixes it.
  46. */
  47. static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
  48. struct pt_regs *oldregs)
  49. {
  50. memcpy(newregs, oldregs, sizeof(*newregs));
  51. newregs->esp = (unsigned long)&(oldregs->esp);
  52. __asm__ __volatile__(
  53. "xorl %%eax, %%eax\n\t"
  54. "movw %%ss, %%ax\n\t"
  55. :"=a"(newregs->xss));
  56. }
  57. /*
  58. * This function is responsible for capturing register states if coming
  59. * via panic otherwise just fix up the ss and esp if coming via kernel
  60. * mode exception.
  61. */
  62. static inline void crash_setup_regs(struct pt_regs *newregs,
  63. struct pt_regs *oldregs)
  64. {
  65. if (oldregs)
  66. crash_fixup_ss_esp(newregs, oldregs);
  67. else {
  68. __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx));
  69. __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx));
  70. __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx));
  71. __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi));
  72. __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi));
  73. __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp));
  74. __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax));
  75. __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp));
  76. __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss));
  77. __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs));
  78. __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds));
  79. __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes));
  80. __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags));
  81. newregs->eip = (unsigned long)current_text_addr();
  82. }
  83. }
  84. asmlinkage NORET_TYPE void
  85. relocate_kernel(unsigned long indirection_page,
  86. unsigned long control_page,
  87. unsigned long start_address,
  88. unsigned int has_pae) ATTRIB_NORET;
  89. #endif /* __ASSEMBLY__ */
  90. #endif /* _I386_KEXEC_H */