Jan Beulich
2008-Mar-13 16:47 UTC
[Xen-devel] [PATCH] linux/i386: re-add and use pre_setup_arch_hook()
It was only during the 2.6.25 merge that I realized that there was a difference to native code that was not only unnecessary, but even preventing the Xen version from being better readable and closer to native both in terms of source code and behavior: pre_setup_arch_hook() can do everything that (or equivalent to what) x86-64 does in head64-xen.c. Apart from that it simplifies forward porting, since certain pieces set up here are required to be available much earlier in newer Linux. As usual, written and tested on 2.6.25-rc5 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: head-2008-03-11/arch/i386/kernel/setup-xen.c ==================================================================--- head-2008-03-11.orig/arch/i386/kernel/setup-xen.c 2008-03-12 17:16:04.000000000 +0100 +++ head-2008-03-11/arch/i386/kernel/setup-xen.c 2008-03-12 11:43:42.000000000 +0100 @@ -1400,10 +1400,6 @@ void __init setup_bootmem_allocator(void crashk_res.end - crashk_res.start + 1); #endif #endif - - if (!xen_feature(XENFEAT_auto_translated_physmap)) - phys_to_machine_mapping - (unsigned long *)xen_start_info->mfn_list; } /* @@ -1601,6 +1601,7 @@ void __init setup_arch(char **cmdline_p) VMASST_TYPE_writable_pagetables)); memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); + pre_setup_arch_hook(); early_cpu_init(); #ifdef CONFIG_SMP prefill_possible_map(); @@ -1654,8 +1655,6 @@ void __init setup_arch(char **cmdline_p) rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0); #endif - setup_xen_features(); - ARCH_SETUP if (efi_enabled) efi_init(); Index: head-2008-03-11/arch/i386/mach-xen/setup.c ==================================================================--- head-2008-03-11.orig/arch/i386/mach-xen/setup.c 2008-03-12 17:16:04.000000000 +0100 +++ head-2008-03-11/arch/i386/mach-xen/setup.c 2008-03-12 11:43:56.000000000 +0100 @@ -88,17 +88,39 @@ extern void hypervisor_callback(void); extern void failsafe_callback(void); extern void nmi(void); -unsigned long *machine_to_phys_mapping; +unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START; EXPORT_SYMBOL(machine_to_phys_mapping); unsigned int machine_to_phys_order; EXPORT_SYMBOL(machine_to_phys_order); -void __init machine_specific_arch_setup(void) +void __init pre_setup_arch_hook(void) { - int ret; struct xen_machphys_mapping mapping; unsigned long machine_to_phys_nr_ents; struct xen_platform_parameters pp; + + init_mm.pgd = swapper_pg_dir = (pgd_t *)xen_start_info->pt_base; + + setup_xen_features(); + + if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) + set_fixaddr_top(pp.virt_start); + + if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) { + machine_to_phys_mapping = (unsigned long *)mapping.v_start; + machine_to_phys_nr_ents = mapping.max_mfn + 1; + } else + machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES; + machine_to_phys_order = fls(machine_to_phys_nr_ents - 1); + + if (!xen_feature(XENFEAT_auto_translated_physmap)) + phys_to_machine_mapping + (unsigned long *)xen_start_info->mfn_list; +} + +void __init machine_specific_arch_setup(void) +{ + int ret; static struct callback_register __initdata event = { .type = CALLBACKTYPE_event, .address = { __KERNEL_CS, (unsigned long)hypervisor_callback }, @@ -134,16 +158,4 @@ void __init machine_specific_arch_setup( HYPERVISOR_nmi_op(XENNMI_register_callback, &cb); } #endif - - if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0) - set_fixaddr_top(pp.virt_start); - - machine_to_phys_mapping = (unsigned long *)MACH2PHYS_VIRT_START; - machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES; - if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) { - machine_to_phys_mapping = (unsigned long *)mapping.v_start; - machine_to_phys_nr_ents = mapping.max_mfn + 1; - } - while ((1UL << machine_to_phys_order) < machine_to_phys_nr_ents ) - machine_to_phys_order++; } Index: head-2008-03-11/arch/i386/mm/init-xen.c ==================================================================--- head-2008-03-11.orig/arch/i386/mm/init-xen.c +++ head-2008-03-11/arch/i386/mm/init-xen.c @@ -388,9 +388,6 @@ unsigned long vaddr; pgd_t *pgd_base = (pgd_t *)xen_start_info->pt_base; - swapper_pg_dir = pgd_base; - init_mm.pgd = pgd_base; - /* Enable PSE if available */ if (cpu_has_pse) { set_in_cr4(X86_CR4_PSE); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel