5 # define PA_CONTROL_PAGE 0
6 # define VA_CONTROL_PAGE 1
13 # ifdef CONFIG_X86_PAE
23 # define PA_CONTROL_PAGE 0
24 # define VA_CONTROL_PAGE 1
39 # define PA_TABLE_PAGE 16
45 #include <linux/string.h>
48 #include <asm/ptrace.h>
51 * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
52 * I.e. Maximum page that is mapped directly into kernel memory,
53 * and kmap is not required.
55 * So far x86_64 is limited to 40 physical address bits.
58 /* Maximum physical address we can use pages from */
59 # define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
60 /* Maximum address we can reach in physical address mode */
61 # define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
62 /* Maximum address we can use for the control code buffer */
63 # define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
65 # define KEXEC_CONTROL_CODE_SIZE 4096
67 /* The native architecture */
68 # define KEXEC_ARCH KEXEC_ARCH_386
70 /* We can also handle crash dumps from 64 bit kernel. */
71 # define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
73 /* Maximum physical address we can use pages from */
74 # define KEXEC_SOURCE_MEMORY_LIMIT (0xFFFFFFFFFFUL)
75 /* Maximum address we can reach in physical address mode */
76 # define KEXEC_DESTINATION_MEMORY_LIMIT (0xFFFFFFFFFFUL)
77 /* Maximum address we can use for the control pages */
78 # define KEXEC_CONTROL_MEMORY_LIMIT (0xFFFFFFFFFFUL)
80 /* Allocate one page for the pdp and the second for the code */
81 # define KEXEC_CONTROL_CODE_SIZE (4096UL + 4096UL)
83 /* The native architecture */
84 # define KEXEC_ARCH KEXEC_ARCH_X86_64
88 * CPU does not save ss and sp on stack if execution is already
89 * running in kernel mode at the time of NMI occurrence. This code
92 static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
93 struct pt_regs *oldregs)
96 newregs->sp = (unsigned long)&(oldregs->sp);
98 "xorl %%eax, %%eax\n\t"
105 * This function is responsible for capturing register states if coming
106 * via panic otherwise just fix up the ss and sp if coming via kernel
109 static inline void crash_setup_regs(struct pt_regs *newregs,
110 struct pt_regs *oldregs)
113 memcpy(newregs, oldregs, sizeof(*newregs));
114 crash_fixup_ss_esp(newregs, oldregs);
117 __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->bx));
118 __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->cx));
119 __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->dx));
120 __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->si));
121 __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->di));
122 __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->bp));
123 __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->ax));
124 __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->sp));
125 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss));
126 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs));
127 __asm__ __volatile__("movl %%ds, %%eax;" :"=a"(newregs->ds));
128 __asm__ __volatile__("movl %%es, %%eax;" :"=a"(newregs->es));
129 __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->flags));
131 __asm__ __volatile__("movq %%rbx,%0" : "=m"(newregs->bx));
132 __asm__ __volatile__("movq %%rcx,%0" : "=m"(newregs->cx));
133 __asm__ __volatile__("movq %%rdx,%0" : "=m"(newregs->dx));
134 __asm__ __volatile__("movq %%rsi,%0" : "=m"(newregs->si));
135 __asm__ __volatile__("movq %%rdi,%0" : "=m"(newregs->di));
136 __asm__ __volatile__("movq %%rbp,%0" : "=m"(newregs->bp));
137 __asm__ __volatile__("movq %%rax,%0" : "=m"(newregs->ax));
138 __asm__ __volatile__("movq %%rsp,%0" : "=m"(newregs->sp));
139 __asm__ __volatile__("movq %%r8,%0" : "=m"(newregs->r8));
140 __asm__ __volatile__("movq %%r9,%0" : "=m"(newregs->r9));
141 __asm__ __volatile__("movq %%r10,%0" : "=m"(newregs->r10));
142 __asm__ __volatile__("movq %%r11,%0" : "=m"(newregs->r11));
143 __asm__ __volatile__("movq %%r12,%0" : "=m"(newregs->r12));
144 __asm__ __volatile__("movq %%r13,%0" : "=m"(newregs->r13));
145 __asm__ __volatile__("movq %%r14,%0" : "=m"(newregs->r14));
146 __asm__ __volatile__("movq %%r15,%0" : "=m"(newregs->r15));
147 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss));
148 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs));
149 __asm__ __volatile__("pushfq; popq %0" :"=m"(newregs->flags));
151 newregs->ip = (unsigned long)current_text_addr();
156 asmlinkage NORET_TYPE void
157 relocate_kernel(unsigned long indirection_page,
158 unsigned long control_page,
159 unsigned long start_address,
160 unsigned int has_pae) ATTRIB_NORET;
163 relocate_kernel(unsigned long indirection_page,
164 unsigned long page_list,
165 unsigned long start_address) ATTRIB_NORET;
168 #endif /* __ASSEMBLY__ */
170 #endif /* _KEXEC_H */