/[pkg-src]/tags/kernel26-xen-2_6_25_r1-fedora9-patches/kernel26-xen/patches-2.6.25-r1/1059-2.6.25-xen-Lots-of-unrelated-changes.patch |
Annotation of /tags/kernel26-xen-2_6_25_r1-fedora9-patches/kernel26-xen/patches-2.6.25-r1/1059-2.6.25-xen-Lots-of-unrelated-changes.patch
Parent Directory
|
Revision Log
Revision 608 -
(hide annotations)
(download)
Fri May 23 12:17:32 2008 UTC (16 years, 1 month ago) by (unknown author)
File size: 17251 byte(s)
Fri May 23 12:17:32 2008 UTC (16 years, 1 month ago) by (unknown author)
File size: 17251 byte(s)
This commit was manufactured by cvs2svn to create tag 'kernel26-xen-2_6_25_r1-fedora9-patches'.
1 | niro | 606 | From 33b7f521facc760c3a8139bd956330cda1a389af Mon Sep 17 00:00:00 2001 |
2 | From: Eduardo Habkost <ehabkost@redhat.com> | ||
3 | Date: Tue, 11 Dec 2007 16:14:09 -0200 | ||
4 | Subject: [PATCH] Lots of unrelated changes | ||
5 | |||
6 | Debugging + changes to make pagetable initialization code work. | ||
7 | |||
8 | This must be splitted in smaller changesets and changed to avoid adding | ||
9 | a new .c file just for the xen_init_pt() function. | ||
10 | |||
11 | Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> | ||
12 | --- | ||
13 | arch/x86/xen/Makefile | 6 ++ | ||
14 | arch/x86/xen/enlighten.c | 41 +++++++++- | ||
15 | arch/x86/xen/init.h | 10 +++ | ||
16 | arch/x86/xen/init_32.c | 3 + | ||
17 | arch/x86/xen/init_64.c | 188 +++++++++++++++++++++++++++++++++++++++++++++ | ||
18 | arch/x86/xen/mmu.c | 86 +++++++++++++++----- | ||
19 | arch/x86/xen/mmu.h | 8 ++ | ||
20 | arch/x86/xen/multicalls.c | 13 ++- | ||
21 | arch/x86/xen/xen-ops.h | 7 ++ | ||
22 | include/xen/page.h | 9 ++- | ||
23 | 10 files changed, 342 insertions(+), 29 deletions(-) | ||
24 | create mode 100644 arch/x86/xen/init.h | ||
25 | create mode 100644 arch/x86/xen/init_32.c | ||
26 | create mode 100644 arch/x86/xen/init_64.c | ||
27 | |||
28 | diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile | ||
29 | index 343df24..e2dc9c1 100644 | ||
30 | --- a/arch/x86/xen/Makefile | ||
31 | +++ b/arch/x86/xen/Makefile | ||
32 | @@ -1,4 +1,10 @@ | ||
33 | obj-y := enlighten.o setup.o features.o multicalls.o mmu.o \ | ||
34 | events.o time.o manage.o xen-asm.o | ||
35 | |||
36 | +ifeq ($(CONFIG_X86_32),y) | ||
37 | +obj-y += init_32.o | ||
38 | +else | ||
39 | +obj-y += init_64.o | ||
40 | +endif | ||
41 | + | ||
42 | obj-$(CONFIG_SMP) += smp.o | ||
43 | diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c | ||
44 | index a676a23..1828284 100644 | ||
45 | --- a/arch/x86/xen/enlighten.c | ||
46 | +++ b/arch/x86/xen/enlighten.c | ||
47 | @@ -51,6 +51,7 @@ | ||
48 | #include "xen-ops.h" | ||
49 | #include "mmu.h" | ||
50 | #include "multicalls.h" | ||
51 | +#include "init.h" | ||
52 | |||
53 | EXPORT_SYMBOL_GPL(hypercall_page); | ||
54 | |||
55 | @@ -702,6 +703,25 @@ static void xen_write_cr3(unsigned long cr3) | ||
56 | xen_mc_issue(PARAVIRT_LAZY_CPU); /* interrupts restored */ | ||
57 | } | ||
58 | |||
59 | +static void xen_new_user_baseptr(unsigned long pfn) | ||
60 | +{ | ||
61 | + struct mmuext_op *op; | ||
62 | + struct multicall_space mcs; | ||
63 | + unsigned long mfn = pfn_to_mfn(PFN_DOWN(pfn)); | ||
64 | + | ||
65 | + xprintk("%s: %lx\n", __func__, pfn); | ||
66 | + | ||
67 | + mcs = xen_mc_entry(sizeof(*op)); /* disables interrupts */ | ||
68 | + | ||
69 | + op = mcs.args; | ||
70 | + op->cmd = MMUEXT_NEW_USER_BASEPTR; | ||
71 | + op->arg1.mfn = mfn; | ||
72 | + | ||
73 | + MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); | ||
74 | + | ||
75 | + xen_mc_issue(PARAVIRT_LAZY_CPU); /* interrupts restored */ | ||
76 | +} | ||
77 | + | ||
78 | /* Early in boot, while setting up the initial pagetable, assume | ||
79 | everything is pinned. */ | ||
80 | static __init void xen_alloc_pt_init(struct mm_struct *mm, u32 pfn) | ||
81 | @@ -961,10 +981,12 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf, | ||
82 | goto patch_site | ||
83 | |||
84 | switch (type) { | ||
85 | +#ifdef CONFIG_X86_32 | ||
86 | SITE(pv_irq_ops, irq_enable); | ||
87 | SITE(pv_irq_ops, irq_disable); | ||
88 | SITE(pv_irq_ops, save_fl); | ||
89 | SITE(pv_irq_ops, restore_fl); | ||
90 | +#endif | ||
91 | #undef SITE | ||
92 | |||
93 | patch_site: | ||
94 | @@ -1161,7 +1183,8 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = { | ||
95 | .make_pte = xen_make_pte, | ||
96 | .make_pgd = xen_make_pgd, | ||
97 | |||
98 | -#ifdef CONFIG_X86_PAE | ||
99 | +#ifdef CONFIG_X86_32 | ||
100 | +# ifdef CONFIG_X86_PAE | ||
101 | .set_pte_atomic = xen_set_pte_atomic, | ||
102 | .set_pte_present = xen_set_pte_at, | ||
103 | .set_pud = xen_set_pud, | ||
104 | @@ -1170,7 +1193,14 @@ static const struct pv_mmu_ops xen_mmu_ops __initdata = { | ||
105 | |||
106 | .make_pmd = xen_make_pmd, | ||
107 | .pmd_val = xen_pmd_val, | ||
108 | -#endif /* PAE */ | ||
109 | +# endif /* PAE */ | ||
110 | +#else | ||
111 | + .set_pgd = xen_set_pgd, | ||
112 | + .make_pud = xen_make_pud, | ||
113 | + | ||
114 | + .make_pmd = xen_make_pmd, | ||
115 | + .pmd_val = xen_pmd_val, | ||
116 | +#endif | ||
117 | |||
118 | .activate_mm = xen_activate_mm, | ||
119 | .dup_mmap = xen_dup_mmap, | ||
120 | @@ -1262,6 +1292,8 @@ asmlinkage void __init xen_start_kernel(void) | ||
121 | |||
122 | BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0); | ||
123 | |||
124 | + xprintk("hello, world!\n"); | ||
125 | + | ||
126 | #ifdef CONFIG_X86_64 | ||
127 | { | ||
128 | /*FIXME: move this to common code | ||
129 | @@ -1302,6 +1334,7 @@ asmlinkage void __init xen_start_kernel(void) | ||
130 | pgd = (pgd_t *)xen_start_info->pt_base; | ||
131 | |||
132 | #ifdef CONFIG_X86_32 | ||
133 | + /*FIXME: x86_64 equivalent */ | ||
134 | init_pg_tables_end = __pa(pgd) + xen_start_info->nr_pt_frames*PAGE_SIZE; | ||
135 | #endif | ||
136 | |||
137 | @@ -1316,6 +1349,10 @@ asmlinkage void __init xen_start_kernel(void) | ||
138 | possible map and a non-dummy shared_info. */ | ||
139 | per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; | ||
140 | |||
141 | + xprintk("xen_init_pt:\n"); | ||
142 | + xen_init_pt(); | ||
143 | + xprintk("xen_init_pt returned.\n"); | ||
144 | + | ||
145 | pv_info.kernel_rpl = 1; | ||
146 | if (xen_feature(XENFEAT_supervisor_mode_kernel)) | ||
147 | pv_info.kernel_rpl = 0; | ||
148 | diff --git a/arch/x86/xen/init.h b/arch/x86/xen/init.h | ||
149 | new file mode 100644 | ||
150 | index 0000000..9cd3954 | ||
151 | --- /dev/null | ||
152 | +++ b/arch/x86/xen/init.h | ||
153 | @@ -0,0 +1,10 @@ | ||
154 | +#ifndef __X86_XEN_INIT_H | ||
155 | +#define __X86_XEN_INIT_H | ||
156 | + | ||
157 | +void xen_init_pt(void); | ||
158 | + | ||
159 | +extern pud_t level3_user_pgt[512]; | ||
160 | +extern pgd_t init_level4_user_pgt[]; | ||
161 | + | ||
162 | + | ||
163 | +#endif /* __X86_XEN_INIT_H */ | ||
164 | diff --git a/arch/x86/xen/init_32.c b/arch/x86/xen/init_32.c | ||
165 | new file mode 100644 | ||
166 | index 0000000..6b49e40 | ||
167 | --- /dev/null | ||
168 | +++ b/arch/x86/xen/init_32.c | ||
169 | @@ -0,0 +1,3 @@ | ||
170 | +void xen_init_pt(void) | ||
171 | +{ | ||
172 | +} | ||
173 | diff --git a/arch/x86/xen/init_64.c b/arch/x86/xen/init_64.c | ||
174 | new file mode 100644 | ||
175 | index 0000000..f025c21 | ||
176 | --- /dev/null | ||
177 | +++ b/arch/x86/xen/init_64.c | ||
178 | @@ -0,0 +1,188 @@ | ||
179 | +#include <linux/kernel.h> | ||
180 | +#include <linux/init.h> | ||
181 | + | ||
182 | +#include <asm/pgtable.h> | ||
183 | + | ||
184 | +#include <asm/xen/hypercall.h> | ||
185 | +#include <xen/page.h> | ||
186 | +#include <xen/hvc-console.h> | ||
187 | + | ||
188 | +#include "xen-ops.h" | ||
189 | +#include "init.h" | ||
190 | +#include "mmu.h" | ||
191 | + | ||
192 | +#define addr_to_page(addr, page) \ | ||
193 | + (addr) &= PHYSICAL_PAGE_MASK; \ | ||
194 | + (page) = ((unsigned long *) ((unsigned long) \ | ||
195 | + (((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) + \ | ||
196 | + __START_KERNEL_map))) | ||
197 | + | ||
198 | + | ||
199 | +static void __meminit early_make_page_readonly(void *va, unsigned int feature) | ||
200 | +{ | ||
201 | + unsigned long addr, _va = (unsigned long)va; | ||
202 | + int r; | ||
203 | + unsigned long idx; | ||
204 | + pte_t pte, *ptep; | ||
205 | + unsigned long *page = (unsigned long *) init_level4_pgt; | ||
206 | + | ||
207 | + if (xen_feature(feature)) | ||
208 | + return; | ||
209 | + | ||
210 | + idx = pgd_index(_va); | ||
211 | + | ||
212 | + addr = (unsigned long) page[idx]; | ||
213 | + addr_to_page(addr, page); | ||
214 | + | ||
215 | + idx = pud_index(_va); | ||
216 | + addr = page[idx]; | ||
217 | + | ||
218 | + addr_to_page(addr, page); | ||
219 | + | ||
220 | + idx = pmd_index(_va); | ||
221 | + addr = page[idx]; | ||
222 | + addr_to_page(addr, page); | ||
223 | + | ||
224 | + idx =pte_index(_va); | ||
225 | + ptep = (pte_t *) &page[idx]; | ||
226 | + | ||
227 | + pte.pte = ptep->pte & ~_PAGE_RW; | ||
228 | + | ||
229 | + if ( (r = HYPERVISOR_update_va_mapping(_va, pte, 0)) ) { | ||
230 | + xprintk("%s: failure: %d :(\n", __func__, r); | ||
231 | + BUG(); | ||
232 | + } | ||
233 | +} | ||
234 | + | ||
235 | + | ||
236 | + | ||
237 | +void __init xen_init_pt(void) | ||
238 | +{ | ||
239 | + unsigned long addr, *page; | ||
240 | + | ||
241 | + xprintk("%s starting\n", __func__); | ||
242 | + | ||
243 | + xprintk("xen_cr3: %lx. xen_cur_cr3: %lx\n", x86_read_percpu(xen_cr3), x86_read_percpu(xen_current_cr3)); | ||
244 | + | ||
245 | + /* Find the initial pte page that was built for us. */ | ||
246 | + page = (unsigned long *)xen_start_info->pt_base; | ||
247 | + xprintk("page1: %p\n", page); | ||
248 | + addr = page[pgd_index(__START_KERNEL_map)]; | ||
249 | + xprintk("addr1: %lx\n", addr); | ||
250 | + addr_to_page(addr, page); | ||
251 | + xprintk("addr1, page2: %lx, %p\n", addr, page); | ||
252 | + | ||
253 | + addr = page[pud_index(__START_KERNEL_map)]; | ||
254 | + xprintk("addr2: %lx\n", addr); | ||
255 | + | ||
256 | + addr_to_page(addr, page); | ||
257 | + xprintk("addr2,page2: %lx, %p\n", addr, page); | ||
258 | + | ||
259 | + | ||
260 | +#if 0 /* CONFIG_XEN_COMPAT <= 0x030002 */ | ||
261 | + /* On Xen 3.0.2 and older we may need to explicitly specify _PAGE_USER | ||
262 | + in kernel PTEs. We check that here. */ | ||
263 | + if (HYPERVISOR_xen_version(XENVER_version, NULL) <= 0x30000) { | ||
264 | + unsigned long *pg; | ||
265 | + pte_t pte; | ||
266 | + | ||
267 | + /* Mess with the initial mapping of page 0. It's not needed. */ | ||
268 | + BUILD_BUG_ON(__START_KERNEL <= __START_KERNEL_map); | ||
269 | + addr = page[pmd_index(__START_KERNEL_map)]; | ||
270 | + addr_to_page(addr, pg); | ||
271 | + pte.pte = pg[pte_index(__START_KERNEL_map)]; | ||
272 | + BUG_ON(!(pte.pte & _PAGE_PRESENT)); | ||
273 | + | ||
274 | + /* If _PAGE_USER isn't set, we obviously do not need it. */ | ||
275 | + if (pte.pte & _PAGE_USER) { | ||
276 | + /* _PAGE_USER is needed, but is it set implicitly? */ | ||
277 | + pte.pte &= ~_PAGE_USER; | ||
278 | + if ((HYPERVISOR_update_va_mapping(__START_KERNEL_map, | ||
279 | + pte, 0) != 0) || | ||
280 | + !(pg[pte_index(__START_KERNEL_map)] & _PAGE_USER)) | ||
281 | + /* We need to explicitly specify _PAGE_USER. */ | ||
282 | + __kernel_page_user = _PAGE_USER; | ||
283 | + } | ||
284 | + } | ||
285 | +#endif | ||
286 | + | ||
287 | + xprintk("l4pgt: %p\n", init_level4_pgt); | ||
288 | + | ||
289 | + /* The page tables are pre-initialized with values that are not | ||
290 | + * usable by Xen. Zero them out. | ||
291 | + */ | ||
292 | + memset(init_level4_pgt, 0, PAGE_SIZE); | ||
293 | + memset(level3_kernel_pgt, 0, PAGE_SIZE); | ||
294 | + memset(level2_kernel_pgt, 0, PAGE_SIZE); | ||
295 | + | ||
296 | + xprintk("%s going change init_level4_pgt\n", __func__); | ||
297 | + | ||
298 | + /* Construct mapping of initial pte page in our own directories. */ | ||
299 | + init_level4_pgt[pgd_index(__START_KERNEL_map)] = | ||
300 | + mk_kernel_pgd(__pa_symbol(level3_kernel_pgt)); | ||
301 | + | ||
302 | + xprintk("pointed l4 to l3kpgt\n"); | ||
303 | + | ||
304 | + xprintk("l3pgt: %p\n", level3_kernel_pgt); | ||
305 | + | ||
306 | + | ||
307 | + { | ||
308 | + unsigned long pi = pud_index(__START_KERNEL_map); | ||
309 | + pud_t newp; | ||
310 | + /*int i; | ||
311 | + for (i = 0; i < PTRS_PER_PUD; i++) | ||
312 | + xprintk("l3[%d] (%p)= %lx\n", i, &level3_kernel_pgt[i], (unsigned long)level3_kernel_pgt[i].pud);*/ | ||
313 | + | ||
314 | + xprintk("pud index: %lx\n", pi); | ||
315 | + xprintk("writing to %p\n", &level3_kernel_pgt[pi]); | ||
316 | + newp = __pud(__pa_symbol(level2_kernel_pgt) | | ||
317 | + _KERNPG_TABLE); | ||
318 | + xprintk("new pud: %lx\n", (unsigned long)newp.pud); | ||
319 | + level3_kernel_pgt[pi] = newp; | ||
320 | + | ||
321 | + } | ||
322 | + xprintk("pointed l3 to l2kpgt\n"); | ||
323 | + | ||
324 | + xprintk("l2pgt: %p\n", level2_kernel_pgt); | ||
325 | + memcpy((void *)level2_kernel_pgt, page, PAGE_SIZE); | ||
326 | + xprintk("copied l2kpgt from page\n"); | ||
327 | + | ||
328 | + | ||
329 | + xprintk("%s: going to pin\n", __func__); | ||
330 | + | ||
331 | + early_make_page_readonly(init_level4_user_pgt, | ||
332 | + XENFEAT_writable_page_tables); | ||
333 | + early_make_page_readonly(level3_user_pgt, | ||
334 | + XENFEAT_writable_page_tables); | ||
335 | + | ||
336 | + xprintk("%s going to make pages readonly\n", __func__); | ||
337 | + early_make_page_readonly(init_level4_pgt, | ||
338 | + XENFEAT_writable_page_tables); | ||
339 | + early_make_page_readonly(level3_kernel_pgt, | ||
340 | + XENFEAT_writable_page_tables); | ||
341 | + early_make_page_readonly(level2_kernel_pgt, | ||
342 | + XENFEAT_writable_page_tables); | ||
343 | + | ||
344 | + xprintk("%s going to pin pgds\n", __func__); | ||
345 | + if (!xen_feature(XENFEAT_writable_page_tables)) { | ||
346 | + xprintk("kernel:\n"); | ||
347 | + xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa_symbol(init_level4_pgt))); | ||
348 | + xprintk("user:\n"); | ||
349 | + xen_do_pin(MMUEXT_PIN_L4_TABLE, PFN_DOWN(__pa_symbol(init_level4_user_pgt))); | ||
350 | + } | ||
351 | + | ||
352 | + | ||
353 | + /*FIXME: check why this isn't set before xen_pgd_pin() on | ||
354 | + * x86_64 XenSource code | ||
355 | + */ | ||
356 | + xprintk("%s: set_pgd:\n", __func__); | ||
357 | + set_pgd((pgd_t *)(init_level4_user_pgt + 511), | ||
358 | + mk_kernel_pgd(__pa_symbol(level3_user_pgt))); | ||
359 | + xprintk("%s: returning.\n", __func__); | ||
360 | + | ||
361 | + xprintk("going to load new pagetable:\n"); | ||
362 | + write_cr3(__pa(init_level4_pgt)); | ||
363 | + xprintk("loaded new pagetable\n"); | ||
364 | +} | ||
365 | + | ||
366 | + | ||
367 | diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c | ||
368 | index d4742df..89aaa58 100644 | ||
369 | --- a/arch/x86/xen/mmu.c | ||
370 | +++ b/arch/x86/xen/mmu.c | ||
371 | @@ -53,6 +53,8 @@ | ||
372 | #include <xen/page.h> | ||
373 | #include <xen/interface/xen.h> | ||
374 | |||
375 | +#include <xen/hvc-console.h> | ||
376 | + | ||
377 | #include "multicalls.h" | ||
378 | #include "mmu.h" | ||
379 | |||
380 | @@ -157,7 +159,21 @@ pteval_t xen_pte_val(pte_t pte) | ||
381 | return ret; | ||
382 | } | ||
383 | |||
384 | -#ifdef CONFIG_X86_PAE | ||
385 | +pte_t xen_make_pte(pteval_t pte) | ||
386 | +{ | ||
387 | + if (pte & _PAGE_PRESENT) { | ||
388 | + pte = phys_to_machine(XPADDR(pte)).maddr; | ||
389 | + pte &= ~(_PAGE_PCD | _PAGE_PWT); | ||
390 | + } | ||
391 | + | ||
392 | + return (pte_t){ .pte = pte }; | ||
393 | +} | ||
394 | + | ||
395 | +#if defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64) | ||
396 | + | ||
397 | +/*FIXME: merge functions where possible */ | ||
398 | + | ||
399 | + | ||
400 | void xen_set_pud(pud_t *ptr, pud_t val) | ||
401 | { | ||
402 | struct multicall_space mcs; | ||
403 | @@ -176,6 +192,46 @@ void xen_set_pud(pud_t *ptr, pud_t val) | ||
404 | preempt_enable(); | ||
405 | } | ||
406 | |||
407 | + | ||
408 | +#ifdef CONFIG_X86_64 | ||
409 | + | ||
410 | +void xen_set_pte(pte_t *ptep, pte_t pte) | ||
411 | +{ | ||
412 | + ptep->pte = pte.pte; | ||
413 | + //smp_wmb(); | ||
414 | +} | ||
415 | + | ||
416 | +void xen_set_pte_atomic(pte_t *ptep, pte_t pte) | ||
417 | +{ | ||
418 | + set_64bit((unsigned long *)ptep, pte_val_ma(pte)); | ||
419 | +} | ||
420 | + | ||
421 | +void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
422 | +{ | ||
423 | + ptep->pte = 0; | ||
424 | +} | ||
425 | + | ||
426 | +void xen_set_pgd(pgd_t *ptr, pgd_t val) | ||
427 | +{ | ||
428 | + struct multicall_space mcs; | ||
429 | + struct mmu_update *u; | ||
430 | + | ||
431 | + preempt_disable(); | ||
432 | + | ||
433 | + mcs = xen_mc_entry(sizeof(*u)); | ||
434 | + u = mcs.args; | ||
435 | + | ||
436 | + u->ptr = virt_to_machine(ptr).maddr; | ||
437 | + u->val = pgd_val_ma(val); | ||
438 | + | ||
439 | + MULTI_mmu_update(mcs.mc, u, 1, NULL, DOMID_SELF); | ||
440 | + | ||
441 | + xen_mc_issue(PARAVIRT_LAZY_MMU); | ||
442 | + | ||
443 | + preempt_enable(); | ||
444 | +} | ||
445 | +#else | ||
446 | + | ||
447 | void xen_set_pte(pte_t *ptep, pte_t pte) | ||
448 | { | ||
449 | ptep->pte_high = pte.pte_high; | ||
450 | @@ -195,6 +251,8 @@ void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | ||
451 | ptep->pte_high = 0; | ||
452 | } | ||
453 | |||
454 | +#endif | ||
455 | + | ||
456 | void xen_pmd_clear(pmd_t *pmdp) | ||
457 | { | ||
458 | xen_set_pmd(pmdp, __pmd(0)); | ||
459 | @@ -203,6 +261,7 @@ void xen_pmd_clear(pmd_t *pmdp) | ||
460 | pmdval_t xen_pmd_val(pmd_t pmd) | ||
461 | { | ||
462 | unsigned long long ret = pmd.pmd; | ||
463 | + | ||
464 | if (ret) | ||
465 | ret = machine_to_phys(XMADDR(ret)).paddr | 1; | ||
466 | return ret; | ||
467 | @@ -216,16 +275,6 @@ pgdval_t xen_pgd_val(pgd_t pgd) | ||
468 | return ret; | ||
469 | } | ||
470 | |||
471 | -pte_t xen_make_pte(pteval_t pte) | ||
472 | -{ | ||
473 | - if (pte & _PAGE_PRESENT) { | ||
474 | - pte = phys_to_machine(XPADDR(pte)).maddr; | ||
475 | - pte &= ~(_PAGE_PCD | _PAGE_PWT); | ||
476 | - } | ||
477 | - | ||
478 | - return (pte_t){ .pte = pte }; | ||
479 | -} | ||
480 | - | ||
481 | pmd_t xen_make_pmd(pmdval_t pmd) | ||
482 | { | ||
483 | if (pmd & 1) | ||
484 | @@ -241,7 +290,9 @@ pgd_t xen_make_pgd(pgdval_t pgd) | ||
485 | |||
486 | return (pgd_t){ pgd }; | ||
487 | } | ||
488 | + | ||
489 | #else /* !PAE */ | ||
490 | + | ||
491 | void xen_set_pte(pte_t *ptep, pte_t pte) | ||
492 | { | ||
493 | *ptep = pte; | ||
494 | @@ -255,16 +306,6 @@ pgdval_t xen_pgd_val(pgd_t pgd) | ||
495 | return ret; | ||
496 | } | ||
497 | |||
498 | -pte_t xen_make_pte(pteval_t pte) | ||
499 | -{ | ||
500 | - if (pte & _PAGE_PRESENT) { | ||
501 | - pte = phys_to_machine(XPADDR(pte)).maddr; | ||
502 | - pte &= ~(_PAGE_PCD | _PAGE_PWT); | ||
503 | - } | ||
504 | - | ||
505 | - return (pte_t){ pte }; | ||
506 | -} | ||
507 | - | ||
508 | pgd_t xen_make_pgd(pgdval_t pgd) | ||
509 | { | ||
510 | if (pgd & _PAGE_PRESENT) | ||
511 | @@ -272,6 +313,7 @@ pgd_t xen_make_pgd(pgdval_t pgd) | ||
512 | |||
513 | return (pgd_t){ pgd }; | ||
514 | } | ||
515 | + | ||
516 | #endif /* CONFIG_X86_PAE */ | ||
517 | |||
518 | /* | ||
519 | @@ -368,7 +410,7 @@ static void do_unlock(void *v) | ||
520 | spin_unlock(ptl); | ||
521 | } | ||
522 | |||
523 | -static void xen_do_pin(unsigned level, unsigned long pfn) | ||
524 | +void xen_do_pin(unsigned level, unsigned long pfn) | ||
525 | { | ||
526 | struct mmuext_op *op; | ||
527 | struct multicall_space mcs; | ||
528 | diff --git a/arch/x86/xen/mmu.h b/arch/x86/xen/mmu.h | ||
529 | index ce425a4..62a325c 100644 | ||
530 | --- a/arch/x86/xen/mmu.h | ||
531 | +++ b/arch/x86/xen/mmu.h | ||
532 | @@ -36,13 +36,17 @@ void xen_exit_mmap(struct mm_struct *mm); | ||
533 | |||
534 | void xen_pgd_pin(pgd_t *pgd); | ||
535 | //void xen_pgd_unpin(pgd_t *pgd); | ||
536 | +// | ||
537 | +void xen_do_pin(unsigned level, unsigned long pfn); | ||
538 | |||
539 | pteval_t xen_pte_val(pte_t); | ||
540 | pmdval_t xen_pmd_val(pmd_t); | ||
541 | +pudval_t xen_pud_val(pud_t); | ||
542 | pgdval_t xen_pgd_val(pgd_t); | ||
543 | |||
544 | pte_t xen_make_pte(pteval_t); | ||
545 | pmd_t xen_make_pmd(pmdval_t); | ||
546 | +pud_t xen_make_pud(pudval_t); | ||
547 | pgd_t xen_make_pgd(pgdval_t); | ||
548 | |||
549 | #ifdef CONFIG_X86_PAE | ||
550 | @@ -55,4 +59,8 @@ void xen_pmd_clear(pmd_t *pmdp); | ||
551 | |||
552 | #endif | ||
553 | |||
554 | +#ifdef CONFIG_X86_64 | ||
555 | +void xen_set_pgd(pgd_t *pgdp, pgd_t pgdval); | ||
556 | +#endif | ||
557 | + | ||
558 | #endif /* _XEN_MMU_H */ | ||
559 | diff --git a/arch/x86/xen/multicalls.c b/arch/x86/xen/multicalls.c | ||
560 | index 5e6f36f..c96a8b0 100644 | ||
561 | --- a/arch/x86/xen/multicalls.c | ||
562 | +++ b/arch/x86/xen/multicalls.c | ||
563 | @@ -24,6 +24,8 @@ | ||
564 | |||
565 | #include <asm/xen/hypercall.h> | ||
566 | |||
567 | +#include <xen/hvc-console.h> | ||
568 | + | ||
569 | #include "multicalls.h" | ||
570 | |||
571 | #define MC_DEBUG 1 | ||
572 | @@ -60,6 +62,8 @@ void xen_mc_flush(void) | ||
573 | something in the middle */ | ||
574 | local_irq_save(flags); | ||
575 | |||
576 | + xprintk("xen_mc_flush called. mcidx: %u\n", b->mcidx); | ||
577 | + | ||
578 | if (b->mcidx) { | ||
579 | #if MC_DEBUG | ||
580 | memcpy(b->debug, b->entries, | ||
581 | @@ -72,19 +76,20 @@ void xen_mc_flush(void) | ||
582 | if (b->entries[i].result < 0) | ||
583 | ret++; | ||
584 | |||
585 | -#if MC_DEBUG | ||
586 | + xprintk("multicall ret: %d\n", ret); | ||
587 | +//#if MC_DEBUG | ||
588 | if (ret) { | ||
589 | - printk(KERN_ERR "%d multicall(s) failed: cpu %d\n", | ||
590 | + xprintk("%d multicall(s) failed: cpu %d\n", | ||
591 | ret, smp_processor_id()); | ||
592 | for(i = 0; i < b->mcidx; i++) { | ||
593 | - printk(" call %2d/%d: op=%lu arg=[%lx] result=%ld\n", | ||
594 | + xprintk(" call %2d/%d: op=%lu arg=[%lx] result=%ld\n", | ||
595 | i+1, b->mcidx, | ||
596 | b->debug[i].op, | ||
597 | b->debug[i].args[0], | ||
598 | b->entries[i].result); | ||
599 | } | ||
600 | } | ||
601 | -#endif | ||
602 | +//#endif | ||
603 | |||
604 | b->mcidx = 0; | ||
605 | b->argidx = 0; | ||
606 | diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h | ||
607 | index b02a909..f062eab 100644 | ||
608 | --- a/arch/x86/xen/xen-ops.h | ||
609 | +++ b/arch/x86/xen/xen-ops.h | ||
610 | @@ -2,6 +2,13 @@ | ||
611 | #define XEN_OPS_H | ||
612 | |||
613 | #include <linux/init.h> | ||
614 | +#include <linux/types.h> | ||
615 | + | ||
616 | +#include <xen/interface/xen.h> | ||
617 | + | ||
618 | +#include <asm/xen/interface.h> | ||
619 | + | ||
620 | +#include <asm/percpu.h> | ||
621 | |||
622 | /* These are code, but not functions. Defined in entry.S */ | ||
623 | extern const char xen_hypervisor_callback[]; | ||
624 | diff --git a/include/xen/page.h b/include/xen/page.h | ||
625 | index 7bf5b56..8008734 100644 | ||
626 | --- a/include/xen/page.h | ||
627 | +++ b/include/xen/page.h | ||
628 | @@ -8,6 +8,10 @@ | ||
629 | |||
630 | #include <xen/features.h> | ||
631 | |||
632 | +#include <asm/xen/interface.h> | ||
633 | + | ||
634 | +#include <xen/hvc-console.h> | ||
635 | + | ||
636 | #ifdef CONFIG_X86_PAE | ||
637 | /* Xen machine address */ | ||
638 | typedef struct xmaddr { | ||
639 | @@ -70,6 +74,8 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn) | ||
640 | #endif | ||
641 | |||
642 | pfn = 0; | ||
643 | + xprintk("mfn_to_pfn(%lx):\n", mfn); | ||
644 | + | ||
645 | /* | ||
646 | * The array access can fail (e.g., device space beyond end of RAM). | ||
647 | * In such cases it doesn't matter what we return (we return garbage), | ||
648 | @@ -77,6 +83,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn) | ||
649 | */ | ||
650 | __get_user(pfn, &machine_to_phys_mapping[mfn]); | ||
651 | |||
652 | + xprintk("mfn_to_pfn(%lx) = %lx\n", mfn, pfn); | ||
653 | return pfn; | ||
654 | } | ||
655 | |||
656 | @@ -154,7 +161,6 @@ static inline pteval_t pte_val_ma(pte_t x) | ||
657 | { | ||
658 | return native_pte_val(x); | ||
659 | } | ||
660 | -#define pud_val_ma(v) ((v).pgd.pgd) | ||
661 | #define __pte_ma(x) (native_make_pte(x)) | ||
662 | #define __pmd_ma(x) ((pmd_t) { (x) } ) | ||
663 | #else /* !X86_PAE */ | ||
664 | @@ -166,6 +172,7 @@ static inline pteval_t pte_val_ma(pte_t x) | ||
665 | |||
666 | #define pgd_val_ma(x) ((x).pgd) | ||
667 | #define pmd_val_ma(x) (native_pmd_val((x))) | ||
668 | +#define pud_val_ma(x) (native_pud_val((x))) | ||
669 | |||
670 | |||
671 | xmaddr_t arbitrary_virt_to_machine(unsigned long address); | ||
672 | -- | ||
673 | 1.5.4.1 | ||
674 |