ia64/linux-2.6.18-xen.hg

changeset 482:f619448beab5

xen/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.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 18 11:22:54 2008 +0000 (2008-03-18)
parents 87a56ff291d3
children 2ffc78135e7f
files arch/i386/kernel/setup-xen.c arch/i386/mach-xen/setup.c arch/i386/mm/init-xen.c
line diff
     1.1 --- a/arch/i386/kernel/setup-xen.c	Tue Mar 18 11:21:44 2008 +0000
     1.2 +++ b/arch/i386/kernel/setup-xen.c	Tue Mar 18 11:22:54 2008 +0000
     1.3 @@ -1402,10 +1402,6 @@ void __init setup_bootmem_allocator(void
     1.4  			crashk_res.end - crashk_res.start + 1);
     1.5  #endif
     1.6  #endif
     1.7 -
     1.8 -	if (!xen_feature(XENFEAT_auto_translated_physmap))
     1.9 -		phys_to_machine_mapping =
    1.10 -			(unsigned long *)xen_start_info->mfn_list;
    1.11  }
    1.12  
    1.13  /*
    1.14 @@ -1627,6 +1623,7 @@ void __init setup_arch(char **cmdline_p)
    1.15  				     VMASST_TYPE_writable_pagetables));
    1.16  
    1.17  	memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
    1.18 +	pre_setup_arch_hook();
    1.19  	early_cpu_init();
    1.20  #ifdef CONFIG_SMP
    1.21  	prefill_possible_map();
    1.22 @@ -1680,8 +1677,6 @@ void __init setup_arch(char **cmdline_p)
    1.23  	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
    1.24  #endif
    1.25  
    1.26 -	setup_xen_features();
    1.27 -
    1.28  	ARCH_SETUP
    1.29  	if (efi_enabled)
    1.30  		efi_init();
     2.1 --- a/arch/i386/mach-xen/setup.c	Tue Mar 18 11:21:44 2008 +0000
     2.2 +++ b/arch/i386/mach-xen/setup.c	Tue Mar 18 11:22:54 2008 +0000
     2.3 @@ -87,17 +87,39 @@ extern void hypervisor_callback(void);
     2.4  extern void failsafe_callback(void);
     2.5  extern void nmi(void);
     2.6  
     2.7 -unsigned long *machine_to_phys_mapping;
     2.8 +unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
     2.9  EXPORT_SYMBOL(machine_to_phys_mapping);
    2.10  unsigned int machine_to_phys_order;
    2.11  EXPORT_SYMBOL(machine_to_phys_order);
    2.12  
    2.13 +void __init pre_setup_arch_hook(void)
    2.14 +{
    2.15 +	struct xen_machphys_mapping mapping;
    2.16 +	unsigned long machine_to_phys_nr_ents;
    2.17 +	struct xen_platform_parameters pp;
    2.18 +
    2.19 +	init_mm.pgd = swapper_pg_dir = (pgd_t *)xen_start_info->pt_base;
    2.20 +
    2.21 +	setup_xen_features();
    2.22 +
    2.23 +	if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0)
    2.24 +		set_fixaddr_top(pp.virt_start);
    2.25 +
    2.26 +	if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
    2.27 +		machine_to_phys_mapping = (unsigned long *)mapping.v_start;
    2.28 +		machine_to_phys_nr_ents = mapping.max_mfn + 1;
    2.29 +	} else
    2.30 +		machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
    2.31 +	machine_to_phys_order = fls(machine_to_phys_nr_ents - 1);
    2.32 +
    2.33 +	if (!xen_feature(XENFEAT_auto_translated_physmap))
    2.34 +		phys_to_machine_mapping =
    2.35 +			(unsigned long *)xen_start_info->mfn_list;
    2.36 +}
    2.37 +
    2.38  void __init machine_specific_arch_setup(void)
    2.39  {
    2.40  	int ret;
    2.41 -	struct xen_machphys_mapping mapping;
    2.42 -	unsigned long machine_to_phys_nr_ents;
    2.43 -	struct xen_platform_parameters pp;
    2.44  	static struct callback_register __initdata event = {
    2.45  		.type = CALLBACKTYPE_event,
    2.46  		.address = { __KERNEL_CS, (unsigned long)hypervisor_callback },
    2.47 @@ -132,16 +154,4 @@ void __init machine_specific_arch_setup(
    2.48  		HYPERVISOR_nmi_op(XENNMI_register_callback, &cb);
    2.49  	}
    2.50  #endif
    2.51 -
    2.52 -	if (HYPERVISOR_xen_version(XENVER_platform_parameters, &pp) == 0)
    2.53 -		set_fixaddr_top(pp.virt_start);
    2.54 -
    2.55 -	machine_to_phys_mapping = (unsigned long *)MACH2PHYS_VIRT_START;
    2.56 -	machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES;
    2.57 -	if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) {
    2.58 -		machine_to_phys_mapping = (unsigned long *)mapping.v_start;
    2.59 -		machine_to_phys_nr_ents = mapping.max_mfn + 1;
    2.60 -	}
    2.61 -	while ((1UL << machine_to_phys_order) < machine_to_phys_nr_ents )
    2.62 -		machine_to_phys_order++;
    2.63  }
     3.1 --- a/arch/i386/mm/init-xen.c	Tue Mar 18 11:21:44 2008 +0000
     3.2 +++ b/arch/i386/mm/init-xen.c	Tue Mar 18 11:22:54 2008 +0000
     3.3 @@ -388,9 +388,6 @@ static void __init pagetable_init (void)
     3.4  	unsigned long vaddr;
     3.5  	pgd_t *pgd_base = (pgd_t *)xen_start_info->pt_base;
     3.6  
     3.7 -	swapper_pg_dir = pgd_base;
     3.8 -	init_mm.pgd    = pgd_base;
     3.9 -
    3.10  	/* Enable PSE if available */
    3.11  	if (cpu_has_pse) {
    3.12  		set_in_cr4(X86_CR4_PSE);