]> xenbits.xensource.com Git - xenclient/kernel.git/commitdiff
xen/i386: re-add and use pre_setup_arch_hook()
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Mar 2008 11:22:54 +0000 (11:22 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 18 Mar 2008 11:22:54 +0000 (11:22 +0000)
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.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
arch/i386/kernel/setup-xen.c
arch/i386/mach-xen/setup.c
arch/i386/mm/init-xen.c

index 242f7485e2b61aff2c3034ad61ad9a76c9cd9c10..2d03a4b575a9057288040a895f31f10a8992fd71 100644 (file)
@@ -1402,10 +1402,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;
 }
 
 /*
@@ -1627,6 +1623,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();
@@ -1680,8 +1677,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 360d261b7a929a11ea63f39d48e85cf5282d5bfe..749ea0b2df466b4c1dbd0e84dd6de7f0057d25f3 100644 (file)
@@ -87,17 +87,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 },
@@ -132,16 +154,4 @@ void __init machine_specific_arch_setup(void)
                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 9a04cb6b1e0eab80c27aa71a7305fd7a4ba90391..de01717e74060fb856ab65c22f7a1a948910588c 100644 (file)
@@ -388,9 +388,6 @@ static void __init pagetable_init (void)
        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);