10 #include <linux/kexec.h>
19 #include <asm/pgtable.h>
20 #include <asm/pgalloc.h>
21 #include <asm/tlbflush.h>
22 #include <asm/mmu_context.h>
24 #include <asm/cpufeature.h>
26 #include <asm/cacheflush.h>
35 curidt.address = (
unsigned long)newidt;
47 curgdt.address = (
unsigned long)newgdt;
52 static void load_segments(
void)
55 #define STR(X) __STR(X)
66 : : :
"eax",
"memory");
71 static void machine_kexec_free_page_tables(
struct kimage *
image)
73 free_page((
unsigned long)image->arch.pgd);
75 free_page((
unsigned long)image->arch.pmd0);
76 free_page((
unsigned long)image->arch.pmd1);
78 free_page((
unsigned long)image->arch.pte0);
79 free_page((
unsigned long)image->arch.pte1);
82 static int machine_kexec_alloc_page_tables(
struct kimage *image)
91 if (!image->arch.pgd ||
93 !image->arch.pmd0 || !image->arch.pmd1 ||
95 !image->arch.pte0 || !image->arch.pte1) {
96 machine_kexec_free_page_tables(image);
102 static void machine_kexec_page_table_set_one(
109 #ifdef CONFIG_X86_PAE
115 if (!(
pmd_val(*pmd) & _PAGE_PRESENT))
121 static void machine_kexec_prepare_page_tables(
struct kimage *image)
127 #ifdef CONFIG_X86_PAE
128 pmd = image->arch.pmd0;
130 machine_kexec_page_table_set_one(
131 image->arch.pgd, pmd, image->arch.pte0,
132 (
unsigned long)control_page,
__pa(control_page));
133 #ifdef CONFIG_X86_PAE
134 pmd = image->arch.pmd1;
136 machine_kexec_page_table_set_one(
137 image->arch.pgd, pmd, image->arch.pte1,
138 __pa(control_page),
__pa(control_page));
161 error = machine_kexec_alloc_page_tables(image);
164 machine_kexec_prepare_page_tables(image);
175 machine_kexec_free_page_tables(image);
186 int save_ftrace_enabled;
188 (*relocate_kernel_ptr)(
unsigned long indirection_page,
189 unsigned long control_page,
190 unsigned long start_address,
191 unsigned int has_pae,
192 unsigned int preserve_context);
194 #ifdef CONFIG_KEXEC_JUMP
195 if (image->preserve_context)
199 save_ftrace_enabled = __ftrace_enabled_save();
203 hw_breakpoint_disable();
205 if (image->preserve_context) {
206 #ifdef CONFIG_X86_IO_APIC
221 relocate_kernel_ptr = control_page;
224 page_list[PA_PGD] =
__pa(image->arch.pgd);
226 if (image->type == KEXEC_TYPE_DEFAULT)
249 image->start = relocate_kernel_ptr((
unsigned long)image->head,
250 (
unsigned long)page_list,
251 image->start, cpu_has_pae,
252 image->preserve_context);
254 #ifdef CONFIG_KEXEC_JUMP
255 if (image->preserve_context)
259 __ftrace_enabled_restore(save_ftrace_enabled);
268 #ifdef CONFIG_X86_PAE
269 VMCOREINFO_CONFIG(X86_PAE);