diff options
-rw-r--r-- | arch/x86/include/asm/kexec.h | 31 | ||||
-rw-r--r-- | arch/x86/include/asm/reboot.h | 5 | ||||
-rw-r--r-- | arch/x86/kernel/crash.c | 67 | ||||
-rw-r--r-- | arch/x86/kernel/machine_kexec_32.c | 104 | ||||
-rw-r--r-- | arch/x86/kernel/reboot.c | 92 | ||||
-rw-r--r-- | arch/x86/kernel/relocate_kernel_32.S | 115 | ||||
-rw-r--r-- | include/linux/kexec.h | 4 |
7 files changed, 207 insertions, 211 deletions
diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h index a1f22771a15a..c61d8b2ab8b9 100644 --- a/arch/x86/include/asm/kexec.h +++ b/arch/x86/include/asm/kexec.h | |||
@@ -5,21 +5,8 @@ | |||
5 | # define PA_CONTROL_PAGE 0 | 5 | # define PA_CONTROL_PAGE 0 |
6 | # define VA_CONTROL_PAGE 1 | 6 | # define VA_CONTROL_PAGE 1 |
7 | # define PA_PGD 2 | 7 | # define PA_PGD 2 |
8 | # define VA_PGD 3 | 8 | # define PA_SWAP_PAGE 3 |
9 | # define PA_PTE_0 4 | 9 | # define PAGES_NR 4 |
10 | # define VA_PTE_0 5 | ||
11 | # define PA_PTE_1 6 | ||
12 | # define VA_PTE_1 7 | ||
13 | # define PA_SWAP_PAGE 8 | ||
14 | # ifdef CONFIG_X86_PAE | ||
15 | # define PA_PMD_0 9 | ||
16 | # define VA_PMD_0 10 | ||
17 | # define PA_PMD_1 11 | ||
18 | # define VA_PMD_1 12 | ||
19 | # define PAGES_NR 13 | ||
20 | # else | ||
21 | # define PAGES_NR 9 | ||
22 | # endif | ||
23 | #else | 10 | #else |
24 | # define PA_CONTROL_PAGE 0 | 11 | # define PA_CONTROL_PAGE 0 |
25 | # define VA_CONTROL_PAGE 1 | 12 | # define VA_CONTROL_PAGE 1 |
@@ -170,6 +157,20 @@ relocate_kernel(unsigned long indirection_page, | |||
170 | unsigned long start_address) ATTRIB_NORET; | 157 | unsigned long start_address) ATTRIB_NORET; |
171 | #endif | 158 | #endif |
172 | 159 | ||
160 | #ifdef CONFIG_X86_32 | ||
161 | #define ARCH_HAS_KIMAGE_ARCH | ||
162 | |||
163 | struct kimage_arch { | ||
164 | pgd_t *pgd; | ||
165 | #ifdef CONFIG_X86_PAE | ||
166 | pmd_t *pmd0; | ||
167 | pmd_t *pmd1; | ||
168 | #endif | ||
169 | pte_t *pte0; | ||
170 | pte_t *pte1; | ||
171 | }; | ||
172 | #endif | ||
173 | |||
173 | #endif /* __ASSEMBLY__ */ | 174 | #endif /* __ASSEMBLY__ */ |
174 | 175 | ||
175 | #endif /* _ASM_X86_KEXEC_H */ | 176 | #endif /* _ASM_X86_KEXEC_H */ |
diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h index df7710354f85..562d4fd31ba8 100644 --- a/arch/x86/include/asm/reboot.h +++ b/arch/x86/include/asm/reboot.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef _ASM_X86_REBOOT_H | 1 | #ifndef _ASM_X86_REBOOT_H |
2 | #define _ASM_X86_REBOOT_H | 2 | #define _ASM_X86_REBOOT_H |
3 | 3 | ||
4 | #include <linux/kdebug.h> | ||
5 | |||
4 | struct pt_regs; | 6 | struct pt_regs; |
5 | 7 | ||
6 | struct machine_ops { | 8 | struct machine_ops { |
@@ -18,4 +20,7 @@ void native_machine_crash_shutdown(struct pt_regs *regs); | |||
18 | void native_machine_shutdown(void); | 20 | void native_machine_shutdown(void); |
19 | void machine_real_restart(const unsigned char *code, int length); | 21 | void machine_real_restart(const unsigned char *code, int length); |
20 | 22 | ||
23 | typedef void (*nmi_shootdown_cb)(int, struct die_args*); | ||
24 | void nmi_shootdown_cpus(nmi_shootdown_cb callback); | ||
25 | |||
21 | #endif /* _ASM_X86_REBOOT_H */ | 26 | #endif /* _ASM_X86_REBOOT_H */ |
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 81e01f7b1d12..d84a852e4cd7 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c | |||
@@ -29,34 +29,17 @@ | |||
29 | 29 | ||
30 | #include <mach_ipi.h> | 30 | #include <mach_ipi.h> |
31 | 31 | ||
32 | /* This keeps a track of which one is crashing cpu. */ | ||
33 | static int crashing_cpu; | ||
34 | 32 | ||
35 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) | 33 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) |
36 | static atomic_t waiting_for_crash_ipi; | ||
37 | 34 | ||
38 | static int crash_nmi_callback(struct notifier_block *self, | 35 | static void kdump_nmi_callback(int cpu, struct die_args *args) |
39 | unsigned long val, void *data) | ||
40 | { | 36 | { |
41 | struct pt_regs *regs; | 37 | struct pt_regs *regs; |
42 | #ifdef CONFIG_X86_32 | 38 | #ifdef CONFIG_X86_32 |
43 | struct pt_regs fixed_regs; | 39 | struct pt_regs fixed_regs; |
44 | #endif | 40 | #endif |
45 | int cpu; | ||
46 | 41 | ||
47 | if (val != DIE_NMI_IPI) | 42 | regs = args->regs; |
48 | return NOTIFY_OK; | ||
49 | |||
50 | regs = ((struct die_args *)data)->regs; | ||
51 | cpu = raw_smp_processor_id(); | ||
52 | |||
53 | /* Don't do anything if this handler is invoked on crashing cpu. | ||
54 | * Otherwise, system will completely hang. Crashing cpu can get | ||
55 | * an NMI if system was initially booted with nmi_watchdog parameter. | ||
56 | */ | ||
57 | if (cpu == crashing_cpu) | ||
58 | return NOTIFY_STOP; | ||
59 | local_irq_disable(); | ||
60 | 43 | ||
61 | #ifdef CONFIG_X86_32 | 44 | #ifdef CONFIG_X86_32 |
62 | if (!user_mode_vm(regs)) { | 45 | if (!user_mode_vm(regs)) { |
@@ -65,51 +48,19 @@ static int crash_nmi_callback(struct notifier_block *self, | |||
65 | } | 48 | } |
66 | #endif | 49 | #endif |
67 | crash_save_cpu(regs, cpu); | 50 | crash_save_cpu(regs, cpu); |
68 | disable_local_APIC(); | ||
69 | atomic_dec(&waiting_for_crash_ipi); | ||
70 | /* Assume hlt works */ | ||
71 | halt(); | ||
72 | for (;;) | ||
73 | cpu_relax(); | ||
74 | |||
75 | return 1; | ||
76 | } | ||
77 | 51 | ||
78 | static void smp_send_nmi_allbutself(void) | 52 | disable_local_APIC(); |
79 | { | ||
80 | send_IPI_allbutself(NMI_VECTOR); | ||
81 | } | 53 | } |
82 | 54 | ||
83 | static struct notifier_block crash_nmi_nb = { | 55 | static void kdump_nmi_shootdown_cpus(void) |
84 | .notifier_call = crash_nmi_callback, | ||
85 | }; | ||
86 | |||
87 | static void nmi_shootdown_cpus(void) | ||
88 | { | 56 | { |
89 | unsigned long msecs; | 57 | nmi_shootdown_cpus(kdump_nmi_callback); |
90 | |||
91 | atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); | ||
92 | /* Would it be better to replace the trap vector here? */ | ||
93 | if (register_die_notifier(&crash_nmi_nb)) | ||
94 | return; /* return what? */ | ||
95 | /* Ensure the new callback function is set before sending | ||
96 | * out the NMI | ||
97 | */ | ||
98 | wmb(); | ||
99 | 58 | ||
100 | smp_send_nmi_allbutself(); | ||
101 | |||
102 | msecs = 1000; /* Wait at most a second for the other cpus to stop */ | ||
103 | while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { | ||
104 | mdelay(1); | ||
105 | msecs--; | ||
106 | } | ||
107 | |||
108 | /* Leave the nmi callback set */ | ||
109 | disable_local_APIC(); | 59 | disable_local_APIC(); |
110 | } | 60 | } |
61 | |||
111 | #else | 62 | #else |
112 | static void nmi_shootdown_cpus(void) | 63 | static void kdump_nmi_shootdown_cpus(void) |
113 | { | 64 | { |
114 | /* There are no cpus to shootdown */ | 65 | /* There are no cpus to shootdown */ |
115 | } | 66 | } |
@@ -128,9 +79,7 @@ void native_machine_crash_shutdown(struct pt_regs *regs) | |||
128 | /* The kernel is broken so disable interrupts */ | 79 | /* The kernel is broken so disable interrupts */ |
129 | local_irq_disable(); | 80 | local_irq_disable(); |
130 | 81 | ||
131 | /* Make a note of crashing cpu. Will be used in NMI callback.*/ | 82 | kdump_nmi_shootdown_cpus(); |
132 | crashing_cpu = safe_smp_processor_id(); | ||
133 | nmi_shootdown_cpus(); | ||
134 | lapic_shutdown(); | 83 | lapic_shutdown(); |
135 | #if defined(CONFIG_X86_IO_APIC) | 84 | #if defined(CONFIG_X86_IO_APIC) |
136 | disable_IO_APIC(); | 85 | disable_IO_APIC(); |
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c index 7a385746509a..37f420018a41 100644 --- a/arch/x86/kernel/machine_kexec_32.c +++ b/arch/x86/kernel/machine_kexec_32.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/numa.h> | 13 | #include <linux/numa.h> |
14 | #include <linux/ftrace.h> | 14 | #include <linux/ftrace.h> |
15 | #include <linux/suspend.h> | 15 | #include <linux/suspend.h> |
16 | #include <linux/gfp.h> | ||
16 | 17 | ||
17 | #include <asm/pgtable.h> | 18 | #include <asm/pgtable.h> |
18 | #include <asm/pgalloc.h> | 19 | #include <asm/pgalloc.h> |
@@ -25,15 +26,6 @@ | |||
25 | #include <asm/system.h> | 26 | #include <asm/system.h> |
26 | #include <asm/cacheflush.h> | 27 | #include <asm/cacheflush.h> |
27 | 28 | ||
28 | #define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE))) | ||
29 | static u32 kexec_pgd[1024] PAGE_ALIGNED; | ||
30 | #ifdef CONFIG_X86_PAE | ||
31 | static u32 kexec_pmd0[1024] PAGE_ALIGNED; | ||
32 | static u32 kexec_pmd1[1024] PAGE_ALIGNED; | ||
33 | #endif | ||
34 | static u32 kexec_pte0[1024] PAGE_ALIGNED; | ||
35 | static u32 kexec_pte1[1024] PAGE_ALIGNED; | ||
36 | |||
37 | static void set_idt(void *newidt, __u16 limit) | 29 | static void set_idt(void *newidt, __u16 limit) |
38 | { | 30 | { |
39 | struct desc_ptr curidt; | 31 | struct desc_ptr curidt; |
@@ -76,6 +68,76 @@ static void load_segments(void) | |||
76 | #undef __STR | 68 | #undef __STR |
77 | } | 69 | } |
78 | 70 | ||
71 | static void machine_kexec_free_page_tables(struct kimage *image) | ||
72 | { | ||
73 | free_page((unsigned long)image->arch.pgd); | ||
74 | #ifdef CONFIG_X86_PAE | ||
75 | free_page((unsigned long)image->arch.pmd0); | ||
76 | free_page((unsigned long)image->arch.pmd1); | ||
77 | #endif | ||
78 | free_page((unsigned long)image->arch.pte0); | ||
79 | free_page((unsigned long)image->arch.pte1); | ||
80 | } | ||
81 | |||
82 | static int machine_kexec_alloc_page_tables(struct kimage *image) | ||
83 | { | ||
84 | image->arch.pgd = (pgd_t *)get_zeroed_page(GFP_KERNEL); | ||
85 | #ifdef CONFIG_X86_PAE | ||
86 | image->arch.pmd0 = (pmd_t *)get_zeroed_page(GFP_KERNEL); | ||
87 | image->arch.pmd1 = (pmd_t *)get_zeroed_page(GFP_KERNEL); | ||
88 | #endif | ||
89 | image->arch.pte0 = (pte_t *)get_zeroed_page(GFP_KERNEL); | ||
90 | image->arch.pte1 = (pte_t *)get_zeroed_page(GFP_KERNEL); | ||
91 | if (!image->arch.pgd || | ||
92 | #ifdef CONFIG_X86_PAE | ||
93 | !image->arch.pmd0 || !image->arch.pmd1 || | ||
94 | #endif | ||
95 | !image->arch.pte0 || !image->arch.pte1) { | ||
96 | machine_kexec_free_page_tables(image); | ||
97 | return -ENOMEM; | ||
98 | } | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static void machine_kexec_page_table_set_one( | ||
103 | pgd_t *pgd, pmd_t *pmd, pte_t *pte, | ||
104 | unsigned long vaddr, unsigned long paddr) | ||
105 | { | ||
106 | pud_t *pud; | ||
107 | |||
108 | pgd += pgd_index(vaddr); | ||
109 | #ifdef CONFIG_X86_PAE | ||
110 | if (!(pgd_val(*pgd) & _PAGE_PRESENT)) | ||
111 | set_pgd(pgd, __pgd(__pa(pmd) | _PAGE_PRESENT)); | ||
112 | #endif | ||
113 | pud = pud_offset(pgd, vaddr); | ||
114 | pmd = pmd_offset(pud, vaddr); | ||
115 | if (!(pmd_val(*pmd) & _PAGE_PRESENT)) | ||
116 | set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE)); | ||
117 | pte = pte_offset_kernel(pmd, vaddr); | ||
118 | set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, PAGE_KERNEL_EXEC)); | ||
119 | } | ||
120 | |||
121 | static void machine_kexec_prepare_page_tables(struct kimage *image) | ||
122 | { | ||
123 | void *control_page; | ||
124 | pmd_t *pmd = 0; | ||
125 | |||
126 | control_page = page_address(image->control_code_page); | ||
127 | #ifdef CONFIG_X86_PAE | ||
128 | pmd = image->arch.pmd0; | ||
129 | #endif | ||
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; | ||
135 | #endif | ||
136 | machine_kexec_page_table_set_one( | ||
137 | image->arch.pgd, pmd, image->arch.pte1, | ||
138 | __pa(control_page), __pa(control_page)); | ||
139 | } | ||
140 | |||
79 | /* | 141 | /* |
80 | * A architecture hook called to validate the | 142 | * A architecture hook called to validate the |
81 | * proposed image and prepare the control pages | 143 | * proposed image and prepare the control pages |
@@ -87,12 +149,20 @@ static void load_segments(void) | |||
87 | * reboot code buffer to allow us to avoid allocations | 149 | * reboot code buffer to allow us to avoid allocations |
88 | * later. | 150 | * later. |
89 | * | 151 | * |
90 | * Make control page executable. | 152 | * - Make control page executable. |
153 | * - Allocate page tables | ||
154 | * - Setup page tables | ||
91 | */ | 155 | */ |
92 | int machine_kexec_prepare(struct kimage *image) | 156 | int machine_kexec_prepare(struct kimage *image) |
93 | { | 157 | { |
158 | int error; | ||
159 | |||
94 | if (nx_enabled) | 160 | if (nx_enabled) |
95 | set_pages_x(image->control_code_page, 1); | 161 | set_pages_x(image->control_code_page, 1); |
162 | error = machine_kexec_alloc_page_tables(image); | ||
163 | if (error) | ||
164 | return error; | ||
165 | machine_kexec_prepare_page_tables(image); | ||
96 | return 0; | 166 | return 0; |
97 | } | 167 | } |
98 | 168 | ||
@@ -104,6 +174,7 @@ void machine_kexec_cleanup(struct kimage *image) | |||
104 | { | 174 | { |
105 | if (nx_enabled) | 175 | if (nx_enabled) |
106 | set_pages_nx(image->control_code_page, 1); | 176 | set_pages_nx(image->control_code_page, 1); |
177 | machine_kexec_free_page_tables(image); | ||
107 | } | 178 | } |
108 | 179 | ||
109 | /* | 180 | /* |
@@ -150,18 +221,7 @@ void machine_kexec(struct kimage *image) | |||
150 | relocate_kernel_ptr = control_page; | 221 | relocate_kernel_ptr = control_page; |
151 | page_list[PA_CONTROL_PAGE] = __pa(control_page); | 222 | page_list[PA_CONTROL_PAGE] = __pa(control_page); |
152 | page_list[VA_CONTROL_PAGE] = (unsigned long)control_page; | 223 | page_list[VA_CONTROL_PAGE] = (unsigned long)control_page; |
153 | page_list[PA_PGD] = __pa(kexec_pgd); | 224 | page_list[PA_PGD] = __pa(image->arch.pgd); |
154 | page_list[VA_PGD] = (unsigned long)kexec_pgd; | ||
155 | #ifdef CONFIG_X86_PAE | ||
156 | page_list[PA_PMD_0] = __pa(kexec_pmd0); | ||
157 | page_list[VA_PMD_0] = (unsigned long)kexec_pmd0; | ||
158 | page_list[PA_PMD_1] = __pa(kexec_pmd1); | ||
159 | page_list[VA_PMD_1] = (unsigned long)kexec_pmd1; | ||
160 | #endif | ||
161 | page_list[PA_PTE_0] = __pa(kexec_pte0); | ||
162 | page_list[VA_PTE_0] = (unsigned long)kexec_pte0; | ||
163 | page_list[PA_PTE_1] = __pa(kexec_pte1); | ||
164 | page_list[VA_PTE_1] = (unsigned long)kexec_pte1; | ||
165 | 225 | ||
166 | if (image->type == KEXEC_TYPE_DEFAULT) | 226 | if (image->type == KEXEC_TYPE_DEFAULT) |
167 | page_list[PA_SWAP_PAGE] = (page_to_pfn(image->swap_page) | 227 | page_list[PA_SWAP_PAGE] = (page_to_pfn(image->swap_page) |
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 0e3dbc7b2bdb..ba7b9a0e6063 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c | |||
@@ -21,6 +21,9 @@ | |||
21 | # include <asm/iommu.h> | 21 | # include <asm/iommu.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <mach_ipi.h> | ||
25 | |||
26 | |||
24 | /* | 27 | /* |
25 | * Power off function, if any | 28 | * Power off function, if any |
26 | */ | 29 | */ |
@@ -548,3 +551,92 @@ void machine_crash_shutdown(struct pt_regs *regs) | |||
548 | machine_ops.crash_shutdown(regs); | 551 | machine_ops.crash_shutdown(regs); |
549 | } | 552 | } |
550 | #endif | 553 | #endif |
554 | |||
555 | |||
556 | #if defined(CONFIG_SMP) | ||
557 | |||
558 | /* This keeps a track of which one is crashing cpu. */ | ||
559 | static int crashing_cpu; | ||
560 | static nmi_shootdown_cb shootdown_callback; | ||
561 | |||
562 | static atomic_t waiting_for_crash_ipi; | ||
563 | |||
564 | static int crash_nmi_callback(struct notifier_block *self, | ||
565 | unsigned long val, void *data) | ||
566 | { | ||
567 | int cpu; | ||
568 | |||
569 | if (val != DIE_NMI_IPI) | ||
570 | return NOTIFY_OK; | ||
571 | |||
572 | cpu = raw_smp_processor_id(); | ||
573 | |||
574 | /* Don't do anything if this handler is invoked on crashing cpu. | ||
575 | * Otherwise, system will completely hang. Crashing cpu can get | ||
576 | * an NMI if system was initially booted with nmi_watchdog parameter. | ||
577 | */ | ||
578 | if (cpu == crashing_cpu) | ||
579 | return NOTIFY_STOP; | ||
580 | local_irq_disable(); | ||
581 | |||
582 | shootdown_callback(cpu, (struct die_args *)data); | ||
583 | |||
584 | atomic_dec(&waiting_for_crash_ipi); | ||
585 | /* Assume hlt works */ | ||
586 | halt(); | ||
587 | for (;;) | ||
588 | cpu_relax(); | ||
589 | |||
590 | return 1; | ||
591 | } | ||
592 | |||
593 | static void smp_send_nmi_allbutself(void) | ||
594 | { | ||
595 | send_IPI_allbutself(NMI_VECTOR); | ||
596 | } | ||
597 | |||
598 | static struct notifier_block crash_nmi_nb = { | ||
599 | .notifier_call = crash_nmi_callback, | ||
600 | }; | ||
601 | |||
602 | /* Halt all other CPUs, calling the specified function on each of them | ||
603 | * | ||
604 | * This function can be used to halt all other CPUs on crash | ||
605 | * or emergency reboot time. The function passed as parameter | ||
606 | * will be called inside a NMI handler on all CPUs. | ||
607 | */ | ||
608 | void nmi_shootdown_cpus(nmi_shootdown_cb callback) | ||
609 | { | ||
610 | unsigned long msecs; | ||
611 | local_irq_disable(); | ||
612 | |||
613 | /* Make a note of crashing cpu. Will be used in NMI callback.*/ | ||
614 | crashing_cpu = safe_smp_processor_id(); | ||
615 | |||
616 | shootdown_callback = callback; | ||
617 | |||
618 | atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); | ||
619 | /* Would it be better to replace the trap vector here? */ | ||
620 | if (register_die_notifier(&crash_nmi_nb)) | ||
621 | return; /* return what? */ | ||
622 | /* Ensure the new callback function is set before sending | ||
623 | * out the NMI | ||
624 | */ | ||
625 | wmb(); | ||
626 | |||
627 | smp_send_nmi_allbutself(); | ||
628 | |||
629 | msecs = 1000; /* Wait at most a second for the other cpus to stop */ | ||
630 | while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { | ||
631 | mdelay(1); | ||
632 | msecs--; | ||
633 | } | ||
634 | |||
635 | /* Leave the nmi callback set */ | ||
636 | } | ||
637 | #else /* !CONFIG_SMP */ | ||
638 | void nmi_shootdown_cpus(nmi_shootdown_cb callback) | ||
639 | { | ||
640 | /* No other CPUs to shoot down */ | ||
641 | } | ||
642 | #endif | ||
diff --git a/arch/x86/kernel/relocate_kernel_32.S b/arch/x86/kernel/relocate_kernel_32.S index 6f50664b2ba5..a160f3119725 100644 --- a/arch/x86/kernel/relocate_kernel_32.S +++ b/arch/x86/kernel/relocate_kernel_32.S | |||
@@ -10,15 +10,12 @@ | |||
10 | #include <asm/page.h> | 10 | #include <asm/page.h> |
11 | #include <asm/kexec.h> | 11 | #include <asm/kexec.h> |
12 | #include <asm/processor-flags.h> | 12 | #include <asm/processor-flags.h> |
13 | #include <asm/pgtable.h> | ||
14 | 13 | ||
15 | /* | 14 | /* |
16 | * Must be relocatable PIC code callable as a C function | 15 | * Must be relocatable PIC code callable as a C function |
17 | */ | 16 | */ |
18 | 17 | ||
19 | #define PTR(x) (x << 2) | 18 | #define PTR(x) (x << 2) |
20 | #define PAGE_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) | ||
21 | #define PAE_PGD_ATTR (_PAGE_PRESENT) | ||
22 | 19 | ||
23 | /* control_page + KEXEC_CONTROL_CODE_MAX_SIZE | 20 | /* control_page + KEXEC_CONTROL_CODE_MAX_SIZE |
24 | * ~ control_page + PAGE_SIZE are used as data storage and stack for | 21 | * ~ control_page + PAGE_SIZE are used as data storage and stack for |
@@ -39,7 +36,6 @@ | |||
39 | #define CP_PA_BACKUP_PAGES_MAP DATA(0x1c) | 36 | #define CP_PA_BACKUP_PAGES_MAP DATA(0x1c) |
40 | 37 | ||
41 | .text | 38 | .text |
42 | .align PAGE_SIZE | ||
43 | .globl relocate_kernel | 39 | .globl relocate_kernel |
44 | relocate_kernel: | 40 | relocate_kernel: |
45 | /* Save the CPU context, used for jumping back */ | 41 | /* Save the CPU context, used for jumping back */ |
@@ -60,117 +56,6 @@ relocate_kernel: | |||
60 | movl %cr4, %eax | 56 | movl %cr4, %eax |
61 | movl %eax, CR4(%edi) | 57 | movl %eax, CR4(%edi) |
62 | 58 | ||
63 | #ifdef CONFIG_X86_PAE | ||
64 | /* map the control page at its virtual address */ | ||
65 | |||
66 | movl PTR(VA_PGD)(%ebp), %edi | ||
67 | movl PTR(VA_CONTROL_PAGE)(%ebp), %eax | ||
68 | andl $0xc0000000, %eax | ||
69 | shrl $27, %eax | ||
70 | addl %edi, %eax | ||
71 | |||
72 | movl PTR(PA_PMD_0)(%ebp), %edx | ||
73 | orl $PAE_PGD_ATTR, %edx | ||
74 | movl %edx, (%eax) | ||
75 | |||
76 | movl PTR(VA_PMD_0)(%ebp), %edi | ||
77 | movl PTR(VA_CONTROL_PAGE)(%ebp), %eax | ||
78 | andl $0x3fe00000, %eax | ||
79 | shrl $18, %eax | ||
80 | addl %edi, %eax | ||
81 | |||
82 | movl PTR(PA_PTE_0)(%ebp), %edx | ||
83 | orl $PAGE_ATTR, %edx | ||
84 | movl %edx, (%eax) | ||
85 | |||
86 | movl PTR(VA_PTE_0)(%ebp), %edi | ||
87 | movl PTR(VA_CONTROL_PAGE)(%ebp), %eax | ||
88 | andl $0x001ff000, %eax | ||
89 | shrl $9, %eax | ||
90 | addl %edi, %eax | ||
91 | |||
92 | movl PTR(PA_CONTROL_PAGE)(%ebp), %edx | ||
93 | orl $PAGE_ATTR, %edx | ||
94 | movl %edx, (%eax) | ||
95 | |||
96 | /* identity map the control page at its physical address */ | ||
97 | |||
98 | movl PTR(VA_PGD)(%ebp), %edi | ||
99 | movl PTR(PA_CONTROL_PAGE)(%ebp), %eax | ||
100 | andl $0xc0000000, %eax | ||
101 | shrl $27, %eax | ||
102 | addl %edi, %eax | ||
103 | |||
104 | movl PTR(PA_PMD_1)(%ebp), %edx | ||
105 | orl $PAE_PGD_ATTR, %edx | ||
106 | movl %edx, (%eax) | ||
107 | |||
108 | movl PTR(VA_PMD_1)(%ebp), %edi | ||
109 | movl PTR(PA_CONTROL_PAGE)(%ebp), %eax | ||
110 | andl $0x3fe00000, %eax | ||
111 | shrl $18, %eax | ||
112 | addl %edi, %eax | ||
113 | |||
114 | movl PTR(PA_PTE_1)(%ebp), %edx | ||
115 | orl $PAGE_ATTR, %edx | ||
116 | movl %edx, (%eax) | ||
117 | |||
118 | movl PTR(VA_PTE_1)(%ebp), %edi | ||
119 | movl PTR(PA_CONTROL_PAGE)(%ebp), %eax | ||
120 | andl $0x001ff000, %eax | ||
121 | shrl $9, %eax | ||
122 | addl %edi, %eax | ||
123 | |||
124 | movl PTR(PA_CONTROL_PAGE)(%ebp), %edx | ||
125 | orl $PAGE_ATTR, %edx | ||
126 | movl %edx, (%eax) | ||
127 | #else | ||
128 | /* map the control page at its virtual address */ | ||
129 | |||
130 | movl PTR(VA_PGD)(%ebp), %edi | ||
131 | movl PTR(VA_CONTROL_PAGE)(%ebp), %eax | ||
132 | andl $0xffc00000, %eax | ||
133 | shrl $20, %eax | ||
134 | addl %edi, %eax | ||
135 | |||
136 | movl PTR(PA_PTE_0)(%ebp), %edx | ||
137 | orl $PAGE_ATTR, %edx | ||
138 | movl %edx, (%eax) | ||
139 | |||
140 | movl PTR(VA_PTE_0)(%ebp), %edi | ||
141 | movl PTR(VA_CONTROL_PAGE)(%ebp), %eax | ||
142 | andl $0x003ff000, %eax | ||
143 | shrl $10, %eax | ||
144 | addl %edi, %eax | ||
145 | |||
146 | movl PTR(PA_CONTROL_PAGE)(%ebp), %edx | ||
147 | orl $PAGE_ATTR, %edx | ||
148 | movl %edx, (%eax) | ||
149 | |||
150 | /* identity map the control page at its physical address */ | ||
151 | |||
152 | movl PTR(VA_PGD)(%ebp), %edi | ||
153 | movl PTR(PA_CONTROL_PAGE)(%ebp), %eax | ||
154 | andl $0xffc00000, %eax | ||
155 | shrl $20, %eax | ||
156 | addl %edi, %eax | ||
157 | |||
158 | movl PTR(PA_PTE_1)(%ebp), %edx | ||
159 | orl $PAGE_ATTR, %edx | ||
160 | movl %edx, (%eax) | ||
161 | |||
162 | movl PTR(VA_PTE_1)(%ebp), %edi | ||
163 | movl PTR(PA_CONTROL_PAGE)(%ebp), %eax | ||
164 | andl $0x003ff000, %eax | ||
165 | shrl $10, %eax | ||
166 | addl %edi, %eax | ||
167 | |||
168 | movl PTR(PA_CONTROL_PAGE)(%ebp), %edx | ||
169 | orl $PAGE_ATTR, %edx | ||
170 | movl %edx, (%eax) | ||
171 | #endif | ||
172 | |||
173 | relocate_new_kernel: | ||
174 | /* read the arguments and say goodbye to the stack */ | 59 | /* read the arguments and say goodbye to the stack */ |
175 | movl 20+4(%esp), %ebx /* page_list */ | 60 | movl 20+4(%esp), %ebx /* page_list */ |
176 | movl 20+8(%esp), %ebp /* list of pages */ | 61 | movl 20+8(%esp), %ebp /* list of pages */ |
diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 17f76fc05173..adc34f2c6eff 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h | |||
@@ -100,6 +100,10 @@ struct kimage { | |||
100 | #define KEXEC_TYPE_DEFAULT 0 | 100 | #define KEXEC_TYPE_DEFAULT 0 |
101 | #define KEXEC_TYPE_CRASH 1 | 101 | #define KEXEC_TYPE_CRASH 1 |
102 | unsigned int preserve_context : 1; | 102 | unsigned int preserve_context : 1; |
103 | |||
104 | #ifdef ARCH_HAS_KIMAGE_ARCH | ||
105 | struct kimage_arch arch; | ||
106 | #endif | ||
103 | }; | 107 | }; |
104 | 108 | ||
105 | 109 | ||