ia64/linux-2.6.18-xen.hg

view arch/i386/kernel/machine_kexec.c @ 450:b7f980c60a61

kexec: add xen_machine_kexec_register_resources() and machine_kexec_register_resources()

Add xen_machine_kexec_register_resources() and
machine_kexec_register_resources() to allow architecture specific
handling of iomem resources.

At this time xen_machine_kexec_register_resources() does the
same parenting of per-cpu resources on all architectures.
And machine_kexec_register_resources does nothing on all
architectures.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 28 10:54:20 2008 +0000 (2008-02-28)
parents a533be77c572
children
line source
1 /*
2 * machine_kexec.c - handle transition of Linux booting another kernel
3 * Copyright (C) 2002-2005 Eric Biederman <ebiederm@xmission.com>
4 *
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
7 */
9 #include <linux/mm.h>
10 #include <linux/kexec.h>
11 #include <linux/delay.h>
12 #include <asm/pgtable.h>
13 #include <asm/pgalloc.h>
14 #include <asm/tlbflush.h>
15 #include <asm/mmu_context.h>
16 #include <asm/io.h>
17 #include <asm/apic.h>
18 #include <asm/cpufeature.h>
19 #include <asm/desc.h>
20 #include <asm/system.h>
22 #ifdef CONFIG_XEN
23 #include <xen/interface/kexec.h>
24 #endif
26 #define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
27 static u32 kexec_pgd[1024] PAGE_ALIGNED;
28 #ifdef CONFIG_X86_PAE
29 static u32 kexec_pmd0[1024] PAGE_ALIGNED;
30 static u32 kexec_pmd1[1024] PAGE_ALIGNED;
31 #endif
32 static u32 kexec_pte0[1024] PAGE_ALIGNED;
33 static u32 kexec_pte1[1024] PAGE_ALIGNED;
35 #ifdef CONFIG_XEN
37 #define __ma(x) (pfn_to_mfn(__pa((x)) >> PAGE_SHIFT) << PAGE_SHIFT)
39 #if PAGES_NR > KEXEC_XEN_NO_PAGES
40 #error PAGES_NR is greater than KEXEC_XEN_NO_PAGES - Xen support will break
41 #endif
43 #if PA_CONTROL_PAGE != 0
44 #error PA_CONTROL_PAGE is non zero - Xen support will break
45 #endif
47 void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, struct kimage *image)
48 {
49 void *control_page;
51 memset(xki->page_list, 0, sizeof(xki->page_list));
53 control_page = page_address(image->control_code_page);
54 memcpy(control_page, relocate_kernel, PAGE_SIZE);
56 xki->page_list[PA_CONTROL_PAGE] = __ma(control_page);
57 xki->page_list[PA_PGD] = __ma(kexec_pgd);
58 #ifdef CONFIG_X86_PAE
59 xki->page_list[PA_PMD_0] = __ma(kexec_pmd0);
60 xki->page_list[PA_PMD_1] = __ma(kexec_pmd1);
61 #endif
62 xki->page_list[PA_PTE_0] = __ma(kexec_pte0);
63 xki->page_list[PA_PTE_1] = __ma(kexec_pte1);
65 }
67 int __init machine_kexec_setup_resources(struct resource *hypervisor,
68 struct resource *phys_cpus,
69 int nr_phys_cpus)
70 {
71 int k;
73 /* The per-cpu crash note resources belong to the hypervisor resource */
74 for (k = 0; k < nr_phys_cpus; k++)
75 request_resource(hypervisor, phys_cpus + k);
77 return 0;
78 }
80 void machine_kexec_register_resources(struct resource *res) { ; }
82 #endif /* CONFIG_XEN */
84 /*
85 * A architecture hook called to validate the
86 * proposed image and prepare the control pages
87 * as needed. The pages for KEXEC_CONTROL_CODE_SIZE
88 * have been allocated, but the segments have yet
89 * been copied into the kernel.
90 *
91 * Do what every setup is needed on image and the
92 * reboot code buffer to allow us to avoid allocations
93 * later.
94 *
95 * Currently nothing.
96 */
97 int machine_kexec_prepare(struct kimage *image)
98 {
99 return 0;
100 }
102 /*
103 * Undo anything leftover by machine_kexec_prepare
104 * when an image is freed.
105 */
106 void machine_kexec_cleanup(struct kimage *image)
107 {
108 }
110 #ifndef CONFIG_XEN
111 /*
112 * Do not allocate memory (or fail in any way) in machine_kexec().
113 * We are past the point of no return, committed to rebooting now.
114 */
115 NORET_TYPE void machine_kexec(struct kimage *image)
116 {
117 unsigned long page_list[PAGES_NR];
118 void *control_page;
120 /* Interrupts aren't acceptable while we reboot */
121 local_irq_disable();
123 control_page = page_address(image->control_code_page);
124 memcpy(control_page, relocate_kernel, PAGE_SIZE);
126 page_list[PA_CONTROL_PAGE] = __pa(control_page);
127 page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel;
128 page_list[PA_PGD] = __pa(kexec_pgd);
129 page_list[VA_PGD] = (unsigned long)kexec_pgd;
130 #ifdef CONFIG_X86_PAE
131 page_list[PA_PMD_0] = __pa(kexec_pmd0);
132 page_list[VA_PMD_0] = (unsigned long)kexec_pmd0;
133 page_list[PA_PMD_1] = __pa(kexec_pmd1);
134 page_list[VA_PMD_1] = (unsigned long)kexec_pmd1;
135 #endif
136 page_list[PA_PTE_0] = __pa(kexec_pte0);
137 page_list[VA_PTE_0] = (unsigned long)kexec_pte0;
138 page_list[PA_PTE_1] = __pa(kexec_pte1);
139 page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
141 relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
142 image->start, cpu_has_pae);
143 }
144 #endif