Commit | Line | Data |
---|---|---|
5033cba0 EB |
1 | #ifndef _I386_KEXEC_H |
2 | #define _I386_KEXEC_H | |
3 | ||
3566561b MD |
4 | #define PA_CONTROL_PAGE 0 |
5 | #define VA_CONTROL_PAGE 1 | |
6 | #define PA_PGD 2 | |
7 | #define VA_PGD 3 | |
8 | #define PA_PTE_0 4 | |
9 | #define VA_PTE_0 5 | |
10 | #define PA_PTE_1 6 | |
11 | #define VA_PTE_1 7 | |
12 | #ifdef CONFIG_X86_PAE | |
13 | #define PA_PMD_0 8 | |
14 | #define VA_PMD_0 9 | |
15 | #define PA_PMD_1 10 | |
16 | #define VA_PMD_1 11 | |
17 | #define PAGES_NR 12 | |
18 | #else | |
19 | #define PAGES_NR 8 | |
20 | #endif | |
21 | ||
22 | #ifndef __ASSEMBLY__ | |
23 | ||
e996e581 | 24 | #include <asm/ptrace.h> |
f05b6902 | 25 | #include <asm/string.h> |
5033cba0 EB |
26 | |
27 | /* | |
28 | * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return. | |
29 | * I.e. Maximum page that is mapped directly into kernel memory, | |
30 | * and kmap is not required. | |
5033cba0 EB |
31 | */ |
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 | ||
40 | #define KEXEC_CONTROL_CODE_SIZE 4096 | |
41 | ||
42 | /* The native architecture */ | |
43 | #define KEXEC_ARCH KEXEC_ARCH_386 | |
44 | ||
79e03011 IC |
45 | /* We can also handle crash dumps from 64 bit kernel. */ |
46 | #define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64) | |
47 | ||
625f1c82 | 48 | #define MAX_NOTE_BYTES 1024 |
625f1c82 | 49 | |
e996e581 VG |
50 | /* CPU does not save ss and esp on stack if execution is already |
51 | * running in kernel mode at the time of NMI occurrence. This code | |
52 | * fixes it. | |
53 | */ | |
54 | static inline void crash_fixup_ss_esp(struct pt_regs *newregs, | |
55 | struct pt_regs *oldregs) | |
56 | { | |
57 | memcpy(newregs, oldregs, sizeof(*newregs)); | |
58 | newregs->esp = (unsigned long)&(oldregs->esp); | |
59 | __asm__ __volatile__( | |
60 | "xorl %%eax, %%eax\n\t" | |
61 | "movw %%ss, %%ax\n\t" | |
62 | :"=a"(newregs->xss)); | |
63 | } | |
64 | ||
65 | /* | |
66 | * This function is responsible for capturing register states if coming | |
67 | * via panic otherwise just fix up the ss and esp if coming via kernel | |
68 | * mode exception. | |
69 | */ | |
70 | static inline void crash_setup_regs(struct pt_regs *newregs, | |
71 | struct pt_regs *oldregs) | |
72 | { | |
73 | if (oldregs) | |
74 | crash_fixup_ss_esp(newregs, oldregs); | |
75 | else { | |
76 | __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx)); | |
77 | __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx)); | |
78 | __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx)); | |
79 | __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi)); | |
80 | __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi)); | |
81 | __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp)); | |
82 | __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax)); | |
83 | __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp)); | |
84 | __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss)); | |
85 | __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs)); | |
86 | __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds)); | |
87 | __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes)); | |
88 | __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags)); | |
89 | ||
90 | newregs->eip = (unsigned long)current_text_addr(); | |
91 | } | |
92 | } | |
3566561b MD |
93 | asmlinkage NORET_TYPE void |
94 | relocate_kernel(unsigned long indirection_page, | |
95 | unsigned long control_page, | |
96 | unsigned long start_address, | |
97 | unsigned int has_pae) ATTRIB_NORET; | |
98 | ||
99 | #endif /* __ASSEMBLY__ */ | |
e996e581 | 100 | |
5033cba0 | 101 | #endif /* _I386_KEXEC_H */ |