kexec_64.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _X86_64_KEXEC_H
  2. #define _X86_64_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_PUD_0 4
  8. #define VA_PUD_0 5
  9. #define PA_PMD_0 6
  10. #define VA_PMD_0 7
  11. #define PA_PTE_0 8
  12. #define VA_PTE_0 9
  13. #define PA_PUD_1 10
  14. #define VA_PUD_1 11
  15. #define PA_PMD_1 12
  16. #define VA_PMD_1 13
  17. #define PA_PTE_1 14
  18. #define VA_PTE_1 15
  19. #define PA_TABLE_PAGE 16
  20. #define PAGES_NR 17
  21. #ifndef __ASSEMBLY__
  22. #include <linux/string.h>
  23. #include <asm/page.h>
  24. #include <asm/ptrace.h>
  25. /*
  26. * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
  27. * I.e. Maximum page that is mapped directly into kernel memory,
  28. * and kmap is not required.
  29. *
  30. * So far x86_64 is limited to 40 physical address bits.
  31. */
  32. /* Maximum physical address we can use pages from */
  33. #define KEXEC_SOURCE_MEMORY_LIMIT (0xFFFFFFFFFFUL)
  34. /* Maximum address we can reach in physical address mode */
  35. #define KEXEC_DESTINATION_MEMORY_LIMIT (0xFFFFFFFFFFUL)
  36. /* Maximum address we can use for the control pages */
  37. #define KEXEC_CONTROL_MEMORY_LIMIT (0xFFFFFFFFFFUL)
  38. /* Allocate one page for the pdp and the second for the code */
  39. #define KEXEC_CONTROL_CODE_SIZE (4096UL + 4096UL)
  40. /* The native architecture */
  41. #define KEXEC_ARCH KEXEC_ARCH_X86_64
  42. /*
  43. * Saving the registers of the cpu on which panic occured in
  44. * crash_kexec to save a valid sp. The registers of other cpus
  45. * will be saved in machine_crash_shutdown while shooting down them.
  46. */
  47. static inline void crash_setup_regs(struct pt_regs *newregs,
  48. struct pt_regs *oldregs)
  49. {
  50. if (oldregs)
  51. memcpy(newregs, oldregs, sizeof(*newregs));
  52. else {
  53. __asm__ __volatile__("movq %%rbx,%0" : "=m"(newregs->rbx));
  54. __asm__ __volatile__("movq %%rcx,%0" : "=m"(newregs->rcx));
  55. __asm__ __volatile__("movq %%rdx,%0" : "=m"(newregs->rdx));
  56. __asm__ __volatile__("movq %%rsi,%0" : "=m"(newregs->rsi));
  57. __asm__ __volatile__("movq %%rdi,%0" : "=m"(newregs->rdi));
  58. __asm__ __volatile__("movq %%rbp,%0" : "=m"(newregs->rbp));
  59. __asm__ __volatile__("movq %%rax,%0" : "=m"(newregs->rax));
  60. __asm__ __volatile__("movq %%rsp,%0" : "=m"(newregs->rsp));
  61. __asm__ __volatile__("movq %%r8,%0" : "=m"(newregs->r8));
  62. __asm__ __volatile__("movq %%r9,%0" : "=m"(newregs->r9));
  63. __asm__ __volatile__("movq %%r10,%0" : "=m"(newregs->r10));
  64. __asm__ __volatile__("movq %%r11,%0" : "=m"(newregs->r11));
  65. __asm__ __volatile__("movq %%r12,%0" : "=m"(newregs->r12));
  66. __asm__ __volatile__("movq %%r13,%0" : "=m"(newregs->r13));
  67. __asm__ __volatile__("movq %%r14,%0" : "=m"(newregs->r14));
  68. __asm__ __volatile__("movq %%r15,%0" : "=m"(newregs->r15));
  69. __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss));
  70. __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs));
  71. __asm__ __volatile__("pushfq; popq %0" :"=m"(newregs->eflags));
  72. newregs->rip = (unsigned long)current_text_addr();
  73. }
  74. }
  75. NORET_TYPE void
  76. relocate_kernel(unsigned long indirection_page,
  77. unsigned long page_list,
  78. unsigned long start_address) ATTRIB_NORET;
  79. #endif /* __ASSEMBLY__ */
  80. #endif /* _X86_64_KEXEC_H */