From ea5a2b76fa368394de92f851124e347a649e6980 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 23 Jan 2008 13:20:18 -0200 Subject: [PATCH] Pull xen_finish_init_mappin() from XS upstream Signed-off-by: Eduardo Habkost --- arch/x86/mm/init_64.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 85 insertions(+), 1 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index fddf208..58ae6ad 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -468,6 +468,85 @@ int make_readonly(unsigned long paddr) return readonly; } +static void xen_finish_init_mapping(void) +{ + /*FIXME: move this to pvops */ + unsigned long i, start, end; + + xprintk("messing with start_info:\n"); + + /* Re-vector virtual addresses pointing into the initial + mapping to the just-established permanent ones. */ + xen_start_info = __va(__pa(xen_start_info)); + xen_start_info->pt_base = (unsigned long) + __va(__pa(xen_start_info->pt_base)); + if (!xen_feature(XENFEAT_auto_translated_physmap)) { + phys_to_machine_mapping = + __va(__pa(xen_start_info->mfn_list)); + xen_start_info->mfn_list = (unsigned long) + phys_to_machine_mapping; + } + if (xen_start_info->mod_start) + xen_start_info->mod_start = (unsigned long) + __va(__pa(xen_start_info->mod_start)); + + xprintk("messed with start_info.\n"); + xprintk("unmapping:\n"); + + /* Destroy the Xen-created mappings beyond the kernel image as + * well as the temporary mappings created above. Prevents + * overlap with modules area (if init mapping is very big). + */ + start = PAGE_ALIGN((unsigned long)_end); + end = __START_KERNEL_map + (table_end << PAGE_SHIFT); + + xprintk("from %lx to %lx\n", start, end); + for (; start < end; start += PAGE_SIZE) + WARN_ON(HYPERVISOR_update_va_mapping( + start, __pte_ma(0), 0)); + + /* Allocate pte's for initial fixmaps from 'start_pfn' allocator. */ + table_end = ~0UL; + + + xprintk("set_fixmaps:\n"); + + /* + * Prefetch pte's for the bt_ioremap() area. It gets used before the + * boot-time allocator is online, so allocate-on-demand would fail. + */ + for (i = FIX_BTMAP_END; i <= FIX_BTMAP_BEGIN; i++) + clear_fixmap(i); + + xprintk("btmap end.\n"); + + /* Switch to the real shared_info page, and clear the dummy page. */ +#if 0 + set_fixmap_mfn(FIX_SHARED_INFO, xen_start_info->shared_info); + HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO); +#endif + + memset(empty_zero_page, 0, sizeof(empty_zero_page)); + xprintk("isamaps:\n"); + + /* Set up mapping of lowest 1MB of physical memory. */ + for (i = 0; i < NR_FIX_ISAMAPS; i++) + if (is_initial_xendomain()) + __native_set_fixmap(FIX_ISAMAP_BEGIN - i, + mfn_pte(i * PAGE_SIZE, PAGE_KERNEL)); + else + __native_set_fixmap(FIX_ISAMAP_BEGIN - i, + pfn_pte(__pa(empty_zero_page) + >> PAGE_SHIFT, + PAGE_KERNEL_RO)); + + /* Disable the 'start_pfn' allocator. */ + table_end = start_pfn; + + xprintk("finished!\n"); +} + + #else /* !XEN */ static __meminit void *alloc_low_page(unsigned long *phys) @@ -771,8 +850,13 @@ void __init_refok init_memory_mapping(unsigned long start, unsigned long end) unmap_low_page(pud); } - if (!after_bootmem) + if (!after_bootmem) { +#ifdef CONFIG_XEN + BUG_ON(start_pfn != table_end); + xen_finish_init_mapping(); +#endif mmu_cr4_features = read_cr4(); + } __flush_tlb_all(); if (!after_bootmem) -- 1.5.4.1