5 # define PA_CONTROL_PAGE 0
6 # define VA_CONTROL_PAGE 1
13 # define PA_SWAP_PAGE 8
14 # ifdef CONFIG_X86_PAE
24 # define PA_CONTROL_PAGE 0
25 # define VA_CONTROL_PAGE 1
40 # define PA_TABLE_PAGE 16
46 #include <linux/string.h>
49 #include <asm/ptrace.h>
52 * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
53 * I.e. Maximum page that is mapped directly into kernel memory,
54 * and kmap is not required.
56 * So far x86_64 is limited to 40 physical address bits.
59 /* Maximum physical address we can use pages from */
60 # define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
61 /* Maximum address we can reach in physical address mode */
62 # define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
63 /* Maximum address we can use for the control code buffer */
64 # define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
66 # define KEXEC_CONTROL_CODE_SIZE 4096
68 /* The native architecture */
69 # define KEXEC_ARCH KEXEC_ARCH_386
71 /* We can also handle crash dumps from 64 bit kernel. */
72 # define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
74 /* Maximum physical address we can use pages from */
75 # define KEXEC_SOURCE_MEMORY_LIMIT (0xFFFFFFFFFFUL)
76 /* Maximum address we can reach in physical address mode */
77 # define KEXEC_DESTINATION_MEMORY_LIMIT (0xFFFFFFFFFFUL)
78 /* Maximum address we can use for the control pages */
79 # define KEXEC_CONTROL_MEMORY_LIMIT (0xFFFFFFFFFFUL)
81 /* Allocate one page for the pdp and the second for the code */
82 # define KEXEC_CONTROL_CODE_SIZE (4096UL + 4096UL)
84 /* The native architecture */
85 # define KEXEC_ARCH KEXEC_ARCH_X86_64
89 * CPU does not save ss and sp on stack if execution is already
90 * running in kernel mode at the time of NMI occurrence. This code
93 static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
94 struct pt_regs *oldregs)
97 newregs->sp = (unsigned long)&(oldregs->sp);
98 asm volatile("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 unsigned long
157 relocate_kernel(unsigned long indirection_page,
158 unsigned long control_page,
159 unsigned long start_address,
160 unsigned int has_pae,
161 unsigned int preserve_context);
164 relocate_kernel(unsigned long indirection_page,
165 unsigned long page_list,
166 unsigned long start_address) ATTRIB_NORET;
169 #endif /* __ASSEMBLY__ */
171 #endif /* _KEXEC_H */