aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/xen/mmu.c54
-rw-r--r--arch/x86/xen/xen-head.S2
2 files changed, 31 insertions, 25 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index f0078d9a5b78..8132aa8c5d49 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -323,46 +323,54 @@ out:
323 preempt_enable(); 323 preempt_enable();
324} 324}
325 325
326pteval_t xen_pte_val(pte_t pte) 326/* Assume pteval_t is equivalent to all the other *val_t types. */
327static pteval_t pte_mfn_to_pfn(pteval_t val)
327{ 328{
328 pteval_t ret = pte.pte; 329 if (val & _PAGE_PRESENT) {
330 unsigned long mfn = (val & PTE_MASK) >> PAGE_SHIFT;
331 pteval_t flags = val & ~PTE_MASK;
332 val = (mfn_to_pfn(mfn) << PAGE_SHIFT) | flags;
333 }
329 334
330 if (ret & _PAGE_PRESENT) 335 return val;
331 ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; 336}
332 337
333 return ret; 338static pteval_t pte_pfn_to_mfn(pteval_t val)
339{
340 if (val & _PAGE_PRESENT) {
341 unsigned long pfn = (val & PTE_MASK) >> PAGE_SHIFT;
342 pteval_t flags = val & ~PTE_MASK;
343 val = (pfn_to_mfn(pfn) << PAGE_SHIFT) | flags;
344 }
345
346 return val;
347}
348
349pteval_t xen_pte_val(pte_t pte)
350{
351 return pte_mfn_to_pfn(pte.pte);
334} 352}
335 353
336pgdval_t xen_pgd_val(pgd_t pgd) 354pgdval_t xen_pgd_val(pgd_t pgd)
337{ 355{
338 pgdval_t ret = pgd.pgd; 356 return pte_mfn_to_pfn(pgd.pgd);
339 if (ret & _PAGE_PRESENT)
340 ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT;
341 return ret;
342} 357}
343 358
344pte_t xen_make_pte(pteval_t pte) 359pte_t xen_make_pte(pteval_t pte)
345{ 360{
346 if (pte & _PAGE_PRESENT) 361 pte = pte_pfn_to_mfn(pte);
347 pte = phys_to_machine(XPADDR(pte)).maddr; 362 return native_make_pte(pte);
348
349 return (pte_t){ .pte = pte };
350} 363}
351 364
352pgd_t xen_make_pgd(pgdval_t pgd) 365pgd_t xen_make_pgd(pgdval_t pgd)
353{ 366{
354 if (pgd & _PAGE_PRESENT) 367 pgd = pte_pfn_to_mfn(pgd);
355 pgd = phys_to_machine(XPADDR(pgd)).maddr; 368 return native_make_pgd(pgd);
356
357 return (pgd_t){ pgd };
358} 369}
359 370
360pmdval_t xen_pmd_val(pmd_t pmd) 371pmdval_t xen_pmd_val(pmd_t pmd)
361{ 372{
362 pmdval_t ret = native_pmd_val(pmd); 373 return pte_mfn_to_pfn(pmd.pmd);
363 if (ret & _PAGE_PRESENT)
364 ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT;
365 return ret;
366} 374}
367 375
368void xen_set_pud_hyper(pud_t *ptr, pud_t val) 376void xen_set_pud_hyper(pud_t *ptr, pud_t val)
@@ -421,9 +429,7 @@ void xen_pmd_clear(pmd_t *pmdp)
421 429
422pmd_t xen_make_pmd(pmdval_t pmd) 430pmd_t xen_make_pmd(pmdval_t pmd)
423{ 431{
424 if (pmd & _PAGE_PRESENT) 432 pmd = pte_pfn_to_mfn(pmd);
425 pmd = phys_to_machine(XPADDR(pmd)).maddr;
426
427 return native_make_pmd(pmd); 433 return native_make_pmd(pmd);
428} 434}
429 435
diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index ef6c9e005f90..7c0cf6320a0a 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -18,7 +18,7 @@ ENTRY(startup_xen)
18 18
19 __FINIT 19 __FINIT
20 20
21.pushsection .bss.page_aligned 21.pushsection .text
22 .align PAGE_SIZE_asm 22 .align PAGE_SIZE_asm
23ENTRY(hypercall_page) 23ENTRY(hypercall_page)
24 .skip 0x1000 24 .skip 0x1000