2 * handle transition of Linux booting another kernel
3 * Copyright (C) 2002-2005 Eric Biederman <ebiederm@xmission.com>
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
10 #include <linux/kexec.h>
11 #include <linux/delay.h>
12 #include <linux/init.h>
13 #include <linux/numa.h>
14 #include <linux/ftrace.h>
16 #include <asm/pgtable.h>
17 #include <asm/pgalloc.h>
18 #include <asm/tlbflush.h>
19 #include <asm/mmu_context.h>
22 #include <asm/cpufeature.h>
24 #include <asm/system.h>
26 #define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
27 static u32 kexec_pgd
[1024] PAGE_ALIGNED
;
29 static u32 kexec_pmd0
[1024] PAGE_ALIGNED
;
30 static u32 kexec_pmd1
[1024] PAGE_ALIGNED
;
32 static u32 kexec_pte0
[1024] PAGE_ALIGNED
;
33 static u32 kexec_pte1
[1024] PAGE_ALIGNED
;
35 static void set_idt(void *newidt
, __u16 limit
)
37 struct desc_ptr curidt
;
39 /* ia32 supports unaliged loads & stores */
41 curidt
.address
= (unsigned long)newidt
;
47 static void set_gdt(void *newgdt
, __u16 limit
)
49 struct desc_ptr curgdt
;
51 /* ia32 supports unaligned loads & stores */
53 curgdt
.address
= (unsigned long)newgdt
;
58 static void load_segments(void)
61 #define STR(X) __STR(X)
63 __asm__
__volatile__ (
64 "\tljmp $"STR(__KERNEL_CS
)",$1f\n"
66 "\tmovl $"STR(__KERNEL_DS
)",%%eax\n"
78 * A architecture hook called to validate the
79 * proposed image and prepare the control pages
80 * as needed. The pages for KEXEC_CONTROL_CODE_SIZE
81 * have been allocated, but the segments have yet
82 * been copied into the kernel.
84 * Do what every setup is needed on image and the
85 * reboot code buffer to allow us to avoid allocations
90 int machine_kexec_prepare(struct kimage
*image
)
96 * Undo anything leftover by machine_kexec_prepare
97 * when an image is freed.
99 void machine_kexec_cleanup(struct kimage
*image
)
104 * Do not allocate memory (or fail in any way) in machine_kexec().
105 * We are past the point of no return, committed to rebooting now.
107 NORET_TYPE
void machine_kexec(struct kimage
*image
)
109 unsigned long page_list
[PAGES_NR
];
114 /* Interrupts aren't acceptable while we reboot */
117 control_page
= page_address(image
->control_code_page
);
118 memcpy(control_page
, relocate_kernel
, PAGE_SIZE
);
120 page_list
[PA_CONTROL_PAGE
] = __pa(control_page
);
121 page_list
[VA_CONTROL_PAGE
] = (unsigned long)relocate_kernel
;
122 page_list
[PA_PGD
] = __pa(kexec_pgd
);
123 page_list
[VA_PGD
] = (unsigned long)kexec_pgd
;
124 #ifdef CONFIG_X86_PAE
125 page_list
[PA_PMD_0
] = __pa(kexec_pmd0
);
126 page_list
[VA_PMD_0
] = (unsigned long)kexec_pmd0
;
127 page_list
[PA_PMD_1
] = __pa(kexec_pmd1
);
128 page_list
[VA_PMD_1
] = (unsigned long)kexec_pmd1
;
130 page_list
[PA_PTE_0
] = __pa(kexec_pte0
);
131 page_list
[VA_PTE_0
] = (unsigned long)kexec_pte0
;
132 page_list
[PA_PTE_1
] = __pa(kexec_pte1
);
133 page_list
[VA_PTE_1
] = (unsigned long)kexec_pte1
;
135 /* The segment registers are funny things, they have both a
136 * visible and an invisible part. Whenever the visible part is
137 * set to a specific selector, the invisible part is loaded
138 * with from a table in memory. At no other time is the
139 * descriptor table in memory accessed.
141 * I take advantage of this here by force loading the
142 * segments, before I zap the gdt with an invalid value.
145 /* The gdt & idt are now invalid.
146 * If you want to load them you must set up your own idt & gdt.
148 set_gdt(phys_to_virt(0),0);
149 set_idt(phys_to_virt(0),0);
152 relocate_kernel((unsigned long)image
->head
, (unsigned long)page_list
,
153 image
->start
, cpu_has_pae
);
156 void arch_crash_save_vmcoreinfo(void)
159 VMCOREINFO_SYMBOL(node_data
);
160 VMCOREINFO_LENGTH(node_data
, MAX_NUMNODES
);
162 #ifdef CONFIG_X86_PAE
163 VMCOREINFO_CONFIG(X86_PAE
);
This page took 0.042828 seconds and 5 git commands to generate.