kexec.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #define MAX_NOTE_BYTES 1024
  38. /* CPU does not save ss and esp on stack if execution is already
  39. * running in kernel mode at the time of NMI occurrence. This code
  40. * fixes it.
  41. */
  42. static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
  43. struct pt_regs *oldregs)
  44. {
  45. memcpy(newregs, oldregs, sizeof(*newregs));
  46. newregs->esp = (unsigned long)&(oldregs->esp);
  47. __asm__ __volatile__(
  48. "xorl %%eax, %%eax\n\t"
  49. "movw %%ss, %%ax\n\t"
  50. :"=a"(newregs->xss));
  51. }
  52. /*
  53. * This function is responsible for capturing register states if coming
  54. * via panic otherwise just fix up the ss and esp if coming via kernel
  55. * mode exception.
  56. */
  57. static inline void crash_setup_regs(struct pt_regs *newregs,
  58. struct pt_regs *oldregs)
  59. {
  60. if (oldregs)
  61. crash_fixup_ss_esp(newregs, oldregs);
  62. else {
  63. __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx));
  64. __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx));
  65. __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx));
  66. __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi));
  67. __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi));
  68. __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp));
  69. __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax));
  70. __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp));
  71. __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss));
  72. __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs));
  73. __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds));
  74. __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes));
  75. __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags));
  76. newregs->eip = (unsigned long)current_text_addr();
  77. }
  78. }
  79. asmlinkage NORET_TYPE void
  80. relocate_kernel(unsigned long indirection_page,
  81. unsigned long control_page,
  82. unsigned long start_address,
  83. unsigned int has_pae) ATTRIB_NORET;
  84. #endif /* __ASSEMBLY__ */
  85. #endif /* _I386_KEXEC_H */