]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/60015_xen3-auto-arch-x86_64.patch1
Imported xen patches.
[people/pmueller/ipfire-2.x.git] / src / patches / 60015_xen3-auto-arch-x86_64.patch1
1 Subject: xen3 arch-x86_64
2 From: http://xenbits.xensource.com/linux-2.6.18-xen.hg (tip 728:832aac894efd)
3 Patch-mainline: obsolete
4 Acked-by: jbeulich@novell.com
5
6 Index: head-2008-11-25/arch/x86/kernel/asm-offsets_64.c
7 ===================================================================
8 --- head-2008-11-25.orig/arch/x86/kernel/asm-offsets_64.c 2008-11-25 12:33:06.000000000 +0100
9 +++ head-2008-11-25/arch/x86/kernel/asm-offsets_64.c 2008-11-25 12:35:54.000000000 +0100
10 @@ -122,8 +122,10 @@ int main(void)
11 ENTRY(cr8);
12 BLANK();
13 #undef ENTRY
14 +#ifndef CONFIG_X86_NO_TSS
15 DEFINE(TSS_ist, offsetof(struct tss_struct, x86_tss.ist));
16 BLANK();
17 +#endif
18 DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
19 BLANK();
20 DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
21 Index: head-2008-11-25/arch/x86/kernel/machine_kexec_64.c
22 ===================================================================
23 --- head-2008-11-25.orig/arch/x86/kernel/machine_kexec_64.c 2008-08-18 10:13:08.000000000 +0200
24 +++ head-2008-11-25/arch/x86/kernel/machine_kexec_64.c 2008-11-25 12:35:54.000000000 +0100
25 @@ -27,6 +27,119 @@ static u64 kexec_pud1[512] PAGE_ALIGNED;
26 static u64 kexec_pmd1[512] PAGE_ALIGNED;
27 static u64 kexec_pte1[512] PAGE_ALIGNED;
28
29 +#ifdef CONFIG_XEN
30 +
31 +/* In the case of Xen, override hypervisor functions to be able to create
32 + * a regular identity mapping page table...
33 + */
34 +
35 +#include <xen/interface/kexec.h>
36 +#include <xen/interface/memory.h>
37 +
38 +#define x__pmd(x) ((pmd_t) { (x) } )
39 +#define x__pud(x) ((pud_t) { (x) } )
40 +#define x__pgd(x) ((pgd_t) { (x) } )
41 +
42 +#define x_pmd_val(x) ((x).pmd)
43 +#define x_pud_val(x) ((x).pud)
44 +#define x_pgd_val(x) ((x).pgd)
45 +
46 +static inline void x_set_pmd(pmd_t *dst, pmd_t val)
47 +{
48 + x_pmd_val(*dst) = x_pmd_val(val);
49 +}
50 +
51 +static inline void x_set_pud(pud_t *dst, pud_t val)
52 +{
53 + x_pud_val(*dst) = phys_to_machine(x_pud_val(val));
54 +}
55 +
56 +static inline void x_pud_clear (pud_t *pud)
57 +{
58 + x_pud_val(*pud) = 0;
59 +}
60 +
61 +static inline void x_set_pgd(pgd_t *dst, pgd_t val)
62 +{
63 + x_pgd_val(*dst) = phys_to_machine(x_pgd_val(val));
64 +}
65 +
66 +static inline void x_pgd_clear (pgd_t * pgd)
67 +{
68 + x_pgd_val(*pgd) = 0;
69 +}
70 +
71 +#define X__PAGE_KERNEL_LARGE_EXEC \
72 + _PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_PSE
73 +#define X_KERNPG_TABLE _PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY
74 +
75 +#define __ma(x) (pfn_to_mfn(__pa((x)) >> PAGE_SHIFT) << PAGE_SHIFT)
76 +
77 +#if PAGES_NR > KEXEC_XEN_NO_PAGES
78 +#error PAGES_NR is greater than KEXEC_XEN_NO_PAGES - Xen support will break
79 +#endif
80 +
81 +#if PA_CONTROL_PAGE != 0
82 +#error PA_CONTROL_PAGE is non zero - Xen support will break
83 +#endif
84 +
85 +void machine_kexec_setup_load_arg(xen_kexec_image_t *xki, struct kimage *image)
86 +{
87 + void *control_page;
88 + void *table_page;
89 +
90 + memset(xki->page_list, 0, sizeof(xki->page_list));
91 +
92 + control_page = page_address(image->control_code_page) + PAGE_SIZE;
93 + memcpy(control_page, relocate_kernel, PAGE_SIZE);
94 +
95 + table_page = page_address(image->control_code_page);
96 +
97 + xki->page_list[PA_CONTROL_PAGE] = __ma(control_page);
98 + xki->page_list[PA_TABLE_PAGE] = __ma(table_page);
99 +
100 + xki->page_list[PA_PGD] = __ma(kexec_pgd);
101 + xki->page_list[PA_PUD_0] = __ma(kexec_pud0);
102 + xki->page_list[PA_PUD_1] = __ma(kexec_pud1);
103 + xki->page_list[PA_PMD_0] = __ma(kexec_pmd0);
104 + xki->page_list[PA_PMD_1] = __ma(kexec_pmd1);
105 + xki->page_list[PA_PTE_0] = __ma(kexec_pte0);
106 + xki->page_list[PA_PTE_1] = __ma(kexec_pte1);
107 +}
108 +
109 +int __init machine_kexec_setup_resources(struct resource *hypervisor,
110 + struct resource *phys_cpus,
111 + int nr_phys_cpus)
112 +{
113 + int k;
114 +
115 + /* The per-cpu crash note resources belong to the hypervisor resource */
116 + for (k = 0; k < nr_phys_cpus; k++)
117 + request_resource(hypervisor, phys_cpus + k);
118 +
119 + return 0;
120 +}
121 +
122 +void machine_kexec_register_resources(struct resource *res) { ; }
123 +
124 +#else /* CONFIG_XEN */
125 +
126 +#define x__pmd(x) __pmd(x)
127 +#define x__pud(x) __pud(x)
128 +#define x__pgd(x) __pgd(x)
129 +
130 +#define x_set_pmd(x, y) set_pmd(x, y)
131 +#define x_set_pud(x, y) set_pud(x, y)
132 +#define x_set_pgd(x, y) set_pgd(x, y)
133 +
134 +#define x_pud_clear(x) pud_clear(x)
135 +#define x_pgd_clear(x) pgd_clear(x)
136 +
137 +#define X__PAGE_KERNEL_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC
138 +#define X_KERNPG_TABLE _KERNPG_TABLE
139 +
140 +#endif /* CONFIG_XEN */
141 +
142 static void init_level2_page(pmd_t *level2p, unsigned long addr)
143 {
144 unsigned long end_addr;
145 @@ -34,7 +147,7 @@ static void init_level2_page(pmd_t *leve
146 addr &= PAGE_MASK;
147 end_addr = addr + PUD_SIZE;
148 while (addr < end_addr) {
149 - set_pmd(level2p++, __pmd(addr | __PAGE_KERNEL_LARGE_EXEC));
150 + x_set_pmd(level2p++, x__pmd(addr | X__PAGE_KERNEL_LARGE_EXEC));
151 addr += PMD_SIZE;
152 }
153 }
154 @@ -59,12 +172,12 @@ static int init_level3_page(struct kimag
155 }
156 level2p = (pmd_t *)page_address(page);
157 init_level2_page(level2p, addr);
158 - set_pud(level3p++, __pud(__pa(level2p) | _KERNPG_TABLE));
159 + x_set_pud(level3p++, x__pud(__pa(level2p) | X_KERNPG_TABLE));
160 addr += PUD_SIZE;
161 }
162 /* clear the unused entries */
163 while (addr < end_addr) {
164 - pud_clear(level3p++);
165 + x_pud_clear(level3p++);
166 addr += PUD_SIZE;
167 }
168 out:
169 @@ -95,12 +208,12 @@ static int init_level4_page(struct kimag
170 if (result) {
171 goto out;
172 }
173 - set_pgd(level4p++, __pgd(__pa(level3p) | _KERNPG_TABLE));
174 + x_set_pgd(level4p++, x__pgd(__pa(level3p) | X_KERNPG_TABLE));
175 addr += PGDIR_SIZE;
176 }
177 /* clear the unused entries */
178 while (addr < end_addr) {
179 - pgd_clear(level4p++);
180 + x_pgd_clear(level4p++);
181 addr += PGDIR_SIZE;
182 }
183 out:
184 @@ -111,8 +224,14 @@ out:
185 static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
186 {
187 pgd_t *level4p;
188 + unsigned long x_max_pfn = max_pfn;
189 +
190 +#ifdef CONFIG_XEN
191 + x_max_pfn = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
192 +#endif
193 +
194 level4p = (pgd_t *)__va(start_pgtable);
195 - return init_level4_page(image, level4p, 0, max_pfn << PAGE_SHIFT);
196 + return init_level4_page(image, level4p, 0, x_max_pfn << PAGE_SHIFT);
197 }
198
199 int machine_kexec_prepare(struct kimage *image)
200 @@ -136,6 +255,7 @@ void machine_kexec_cleanup(struct kimage
201 return;
202 }
203
204 +#ifndef CONFIG_XEN
205 /*
206 * Do not allocate memory (or fail in any way) in machine_kexec().
207 * We are past the point of no return, committed to rebooting now.
208 @@ -176,6 +296,7 @@ void machine_kexec(struct kimage *image)
209 relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
210 image->start);
211 }
212 +#endif
213
214 void arch_crash_save_vmcoreinfo(void)
215 {
216 Index: head-2008-11-25/arch/x86/power/cpu_64.c
217 ===================================================================
218 --- head-2008-11-25.orig/arch/x86/power/cpu_64.c 2008-11-25 12:33:06.000000000 +0100
219 +++ head-2008-11-25/arch/x86/power/cpu_64.c 2008-11-25 12:35:54.000000000 +0100
220 @@ -135,6 +135,7 @@ void restore_processor_state(void)
221
222 static void fix_processor_context(void)
223 {
224 +#ifndef CONFIG_X86_NO_TSS
225 int cpu = smp_processor_id();
226 struct tss_struct *t = &per_cpu(init_tss, cpu);
227
228 @@ -146,6 +147,7 @@ static void fix_processor_context(void)
229 set_tss_desc(cpu, t);
230
231 get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
232 +#endif
233
234 syscall_init(); /* This sets MSR_*STAR and related */
235 load_TR_desc(); /* This does ltr */
236 Index: head-2008-11-25/arch/x86/vdso/Makefile
237 ===================================================================
238 --- head-2008-11-25.orig/arch/x86/vdso/Makefile 2008-11-25 12:33:06.000000000 +0100
239 +++ head-2008-11-25/arch/x86/vdso/Makefile 2008-11-25 12:35:54.000000000 +0100
240 @@ -65,6 +65,8 @@ obj-$(VDSO32-y) += vdso32-syms.lds
241 vdso32.so-$(VDSO32-y) += int80
242 vdso32.so-$(CONFIG_COMPAT) += syscall
243 vdso32.so-$(VDSO32-y) += sysenter
244 +xen-vdso32-$(subst 1,$(CONFIG_COMPAT),$(shell expr $(CONFIG_XEN_COMPAT)0 '<' 0x0302000)) += int80
245 +vdso32.so-$(CONFIG_XEN) += $(xen-vdso32-y)
246
247 vdso32-images = $(vdso32.so-y:%=vdso32-%.so)
248