ia64/xen-unstable

changeset 6184:737433c5bb2e

The patch cleans up (ugly) setup.c that I wanted to fix for a long time
(but did not have time for that).

It should be compiled for the native x86_64 Linux as well (but not
tested yet, so I don't guarantee):
- no #if 0 or comment out
- use CONFIG_XEN for xen specific code
- preparation for merge to the upstream
- tested both dom0 (UP and SMP) and domU

Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Aug 15 07:52:19 2005 +0000 (2005-08-15)
parents 60a8a5ca4291
children a42bf05b188c
files linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Mon Aug 15 07:51:58 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/e820.c	Mon Aug 15 07:52:19 2005 +0000
     1.3 @@ -46,7 +46,7 @@ void __init add_memory_region(unsigned l
     1.4  	e820.nr_map++;
     1.5  }
     1.6  
     1.7 -#if 0
     1.8 +#ifndef CONFIG_XEN
     1.9  extern char _end[];
    1.10  
    1.11  /* 
    1.12 @@ -235,7 +235,6 @@ void __init e820_reserve_resources(void)
    1.13  	}
    1.14  }
    1.15  
    1.16 -
    1.17  void __init e820_print_map(char *who)
    1.18  {
    1.19  	int i;
    1.20 @@ -516,9 +515,31 @@ void __init setup_memory_region(void)
    1.21  	printk(KERN_INFO "BIOS-provided physical RAM map:\n");
    1.22  	e820_print_map(who);
    1.23  }
    1.24 -#endif
    1.25 +
    1.26 +#else  /* CONFIX_XEN */
    1.27 +extern unsigned long xen_override_max_pfn;
    1.28 +extern union xen_start_info_union xen_start_info_union;
    1.29 +/*
    1.30 + * Guest physical starts from 0.
    1.31 + */
    1.32 +unsigned long __init e820_end_of_ram(void)
    1.33 +{
    1.34 +        unsigned long max_end_pfn = xen_start_info.nr_pages;
    1.35  
    1.36 -extern unsigned long xen_override_max_pfn;
    1.37 +	if ( xen_override_max_pfn <  max_end_pfn)
    1.38 +		xen_override_max_pfn = max_end_pfn;
    1.39 +	
    1.40 +        return xen_override_max_pfn;
    1.41 +}
    1.42 +
    1.43 +
    1.44 +
    1.45 +void __init e820_reserve_resources(void) 
    1.46 +{
    1.47 +	return;			/* Xen won't have reserved entries */
    1.48 +}
    1.49 +
    1.50 +#endif
    1.51  
    1.52  void __init parse_memopt(char *p, char **from) 
    1.53  { 
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Mon Aug 15 07:51:58 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Mon Aug 15 07:52:19 2005 +0000
     2.3 @@ -40,7 +40,6 @@
     2.4  #include <linux/acpi.h>
     2.5  #include <linux/kallsyms.h>
     2.6  #include <linux/edd.h>
     2.7 -#include <linux/percpu.h>
     2.8  #include <asm/mtrr.h>
     2.9  #include <asm/uaccess.h>
    2.10  #include <asm/system.h>
    2.11 @@ -58,27 +57,36 @@
    2.12  #include <asm/setup.h>
    2.13  #include <asm/mach_apic.h>
    2.14  #include <asm/numa.h>
    2.15 +#ifdef CONFIG_XEN
    2.16 +#include <linux/percpu.h>
    2.17  #include <asm-xen/xen-public/physdev.h>
    2.18  #include "setup_arch_pre.h"
    2.19  #include <asm-xen/hypervisor.h>
    2.20 -
    2.21  #define PFN_UP(x)       (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
    2.22  #define PFN_PHYS(x)     ((x) << PAGE_SHIFT)
    2.23 -
    2.24 +#define end_pfn_map end_pfn
    2.25  #include <asm/mach-xen/setup_arch_post.h>
    2.26  
    2.27  extern unsigned long start_pfn;
    2.28 +extern struct edid_info edid_info;
    2.29  
    2.30 -#if 0
    2.31 -struct edid_info {
    2.32 -        unsigned char dummy[128];
    2.33 -};
    2.34 -#endif
    2.35 -
    2.36 -extern struct edid_info edid_info;
    2.37 +shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
    2.38 +EXPORT_SYMBOL(HYPERVISOR_shared_info);
    2.39  
    2.40  /* Allows setting of maximum possible memory size  */
    2.41  unsigned long xen_override_max_pfn;
    2.42 +
    2.43 +u32 *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
    2.44 +
    2.45 +EXPORT_SYMBOL(phys_to_machine_mapping);
    2.46 +
    2.47 +DEFINE_PER_CPU(multicall_entry_t, multicall_list[8]);
    2.48 +DEFINE_PER_CPU(int, nr_multicall_ents);
    2.49 +
    2.50 +/* Raw start-of-day parameters from the hypervisor. */
    2.51 +union xen_start_info_union xen_start_info_union;
    2.52 +#endif
    2.53 +
    2.54  /*
    2.55   * Machine setup..
    2.56   */
    2.57 @@ -166,7 +174,7 @@ struct resource code_resource = {
    2.58  
    2.59  #define IORESOURCE_ROM (IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM)
    2.60  
    2.61 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
    2.62 +#if defined(CONFIG_XEN_PRIVILEGED_GUEST) || !defined(CONFIG_XEN)
    2.63  static struct resource system_rom_resource = {
    2.64  	.name = "System ROM",
    2.65  	.start = 0xf0000,
    2.66 @@ -200,7 +208,7 @@ static struct resource adapter_rom_resou
    2.67  #define ADAPTER_ROM_RESOURCES \
    2.68  	(sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
    2.69  
    2.70 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
    2.71 +#if defined(CONFIG_XEN_PRIVILEGED_GUEST) || !defined(CONFIG_XEN)
    2.72  static struct resource video_rom_resource = {
    2.73  	.name = "Video ROM",
    2.74  	.start = 0xc0000,
    2.75 @@ -216,7 +224,7 @@ static struct resource video_ram_resourc
    2.76  	.flags = IORESOURCE_RAM,
    2.77  };
    2.78  
    2.79 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
    2.80 +#if defined(CONFIG_XEN_PRIVILEGED_GUEST) || !defined(CONFIG_XEN)
    2.81  #define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
    2.82  
    2.83  static int __init romchecksum(unsigned char *rom, unsigned long length)
    2.84 @@ -294,33 +302,24 @@ static void __init probe_roms(void)
    2.85  }
    2.86  #endif
    2.87  
    2.88 -/*
    2.89 - * Point at the empty zero page to start with. We map the real shared_info
    2.90 - * page as soon as fixmap is up and running.
    2.91 - */
    2.92 -shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
    2.93 -EXPORT_SYMBOL(HYPERVISOR_shared_info);
    2.94 -
    2.95 -u32 *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
    2.96 -
    2.97 -EXPORT_SYMBOL(phys_to_machine_mapping);
    2.98 -
    2.99 -DEFINE_PER_CPU(multicall_entry_t, multicall_list[8]);
   2.100 -DEFINE_PER_CPU(int, nr_multicall_ents);
   2.101 -
   2.102 -/* Raw start-of-day parameters from the hypervisor. */
   2.103 -union xen_start_info_union xen_start_info_union;
   2.104  
   2.105  static __init void parse_cmdline_early (char ** cmdline_p)
   2.106  {
   2.107  	char c = ' ', *to = command_line, *from = COMMAND_LINE;
   2.108 -	int len = 0, max_cmdline;
   2.109 +	int len = 0;
   2.110  
   2.111 +	/* Save unparsed command line copy for /proc/cmdline */
   2.112 +#ifdef CONFIG_XEN
   2.113 +	int max_cmdline;
   2.114 +	
   2.115  	if ((max_cmdline = MAX_GUEST_CMDLINE) > COMMAND_LINE_SIZE)
   2.116  		max_cmdline = COMMAND_LINE_SIZE;
   2.117  	memcpy(saved_command_line, xen_start_info.cmd_line, max_cmdline);
   2.118 -	/* Save unparsed command line copy for /proc/cmdline */
   2.119  	saved_command_line[max_cmdline-1] = '\0';
   2.120 +#else
   2.121 +	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
   2.122 +	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
   2.123 +#endif
   2.124  
   2.125  	for (;;) {
   2.126  		if (c != ' ') 
   2.127 @@ -378,8 +377,7 @@ static __init void parse_cmdline_early (
   2.128  			acpi_skip_timer_override = 1;
   2.129  #endif
   2.130  #endif
   2.131 -
   2.132 -#if 0
   2.133 +#ifndef CONFIG_XEN
   2.134  		if (!memcmp(from, "nolapic", 7) ||
   2.135  		    !memcmp(from, "disableapic", 11))
   2.136  			disable_apic = 1;
   2.137 @@ -391,8 +389,7 @@ static __init void parse_cmdline_early (
   2.138  			skip_ioapic_setup = 0;
   2.139  			ioapic_force = 1;
   2.140  		}
   2.141 -#endif
   2.142 -			
   2.143 +#endif			
   2.144  		if (!memcmp(from, "mem=", 4))
   2.145  			parse_memopt(from+4, &from); 
   2.146  
   2.147 @@ -426,34 +423,33 @@ static __init void parse_cmdline_early (
   2.148  }
   2.149  
   2.150  #ifndef CONFIG_DISCONTIGMEM
   2.151 +#ifdef CONFIG_XEN
   2.152  static void __init contig_initmem_init(void)
   2.153  {
   2.154          unsigned long bootmap_size, bootmap; 
   2.155  
   2.156 -        /*
   2.157 -	 * partially used pages are not usable - thus
   2.158 -	 * we are rounding upwards:
   2.159 -	 */
   2.160 -
   2.161          bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
   2.162          bootmap = start_pfn;
   2.163          bootmap_size = init_bootmem(bootmap, end_pfn);
   2.164          reserve_bootmem(bootmap, bootmap_size);
   2.165          
   2.166          free_bootmem(start_pfn << PAGE_SHIFT, (end_pfn - start_pfn) << PAGE_SHIFT);   
   2.167 -        printk("Registering memory for bootmem: from  %lx, size = %lx\n",
   2.168 -                     start_pfn << PAGE_SHIFT, (end_pfn - start_pfn) << PAGE_SHIFT);
   2.169 -        /* 
   2.170 -         * This should cover kernel_end
   2.171 -         */
   2.172 -#if 0
   2.173 -        reserve_bootmem(HIGH_MEMORY, (PFN_PHYS(start_pfn) +
   2.174 -                                      bootmap_size + PAGE_SIZE-1) - (HIGH_MEMORY));
   2.175 -#endif
   2.176          reserve_bootmem(0, (PFN_PHYS(start_pfn) +
   2.177                              bootmap_size + PAGE_SIZE-1));
   2.178 -
   2.179 +}
   2.180 +#else
   2.181 +static void __init contig_initmem_init(void)
   2.182 +{
   2.183 +        unsigned long bootmap_size, bootmap; 
   2.184 +        bootmap_size = bootmem_bootmap_pages(end_pfn)<<PAGE_SHIFT;
   2.185 +        bootmap = find_e820_area(0, end_pfn<<PAGE_SHIFT, bootmap_size);
   2.186 +        if (bootmap == -1L) 
   2.187 +                panic("Cannot find bootmem map of size %ld\n",bootmap_size);
   2.188 +        bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
   2.189 +        e820_bootmem_free(&contig_page_data, 0, end_pfn << PAGE_SHIFT); 
   2.190 +        reserve_bootmem(bootmap, bootmap_size);
   2.191  } 
   2.192 +#endif	/* !CONFIG_XEN */
   2.193  #endif
   2.194  
   2.195  /* Use inline assembly to define this because the nops are defined 
   2.196 @@ -545,35 +541,8 @@ static inline void copy_edd(void)
   2.197  }
   2.198  #endif
   2.199  
   2.200 -#if 0
   2.201 -#define EBDA_ADDR_POINTER 0x40E
   2.202 -static void __init reserve_ebda_region(void)
   2.203 -{
   2.204 -	unsigned int addr;
   2.205 -	/** 
   2.206 -	 * there is a real-mode segmented pointer pointing to the 
   2.207 -	 * 4K EBDA area at 0x40E
   2.208 -	 */
   2.209 -	addr = *(unsigned short *)phys_to_virt(EBDA_ADDR_POINTER);
   2.210 -	addr <<= 4;
   2.211 -	if (addr)
   2.212 -		reserve_bootmem_generic(addr, PAGE_SIZE);
   2.213 -}
   2.214 -#endif
   2.215 -
   2.216 -/*
   2.217 - * Guest physical starts from 0.
   2.218 - */
   2.219 -
   2.220 -unsigned long __init xen_end_of_ram(void)
   2.221 -{
   2.222 -        unsigned long max_end_pfn = xen_start_info.nr_pages;
   2.223 -
   2.224 -	if ( xen_override_max_pfn <  max_end_pfn)
   2.225 -		xen_override_max_pfn = max_end_pfn;
   2.226 -	
   2.227 -        return xen_override_max_pfn;
   2.228 -}
   2.229 +#ifdef CONFIG_XEN
   2.230 +#define reserve_ebda_region() void(0)
   2.231  
   2.232  static void __init print_memory_map(char *who)
   2.233  {
   2.234 @@ -601,7 +570,6 @@ static void __init print_memory_map(char
   2.235          }
   2.236  }
   2.237  
   2.238 -#ifdef CONFIG_XEN
   2.239  void __init smp_alloc_memory(void)
   2.240  {
   2.241  	int cpu;
   2.242 @@ -612,22 +580,42 @@ void __init smp_alloc_memory(void)
   2.243  		/* XXX free unused pages later */
   2.244  	}
   2.245  }
   2.246 +
   2.247 +
   2.248 +#else
   2.249 +#define EBDA_ADDR_POINTER 0x40E
   2.250 +static void __init reserve_ebda_region(void)
   2.251 +{
   2.252 +	unsigned int addr;
   2.253 +	/** 
   2.254 +	 * there is a real-mode segmented pointer pointing to the 
   2.255 +	 * 4K EBDA area at 0x40E
   2.256 +	 */
   2.257 +	addr = *(unsigned short *)phys_to_virt(EBDA_ADDR_POINTER);
   2.258 +	addr <<= 4;
   2.259 +	if (addr)
   2.260 +		reserve_bootmem_generic(addr, PAGE_SIZE);
   2.261 +}
   2.262  #endif
   2.263  
   2.264  void __init setup_arch(char **cmdline_p)
   2.265  {
   2.266 -	int i, j;
   2.267 -	physdev_op_t op;
   2.268 +	unsigned long kernel_end;
   2.269  
   2.270 -#if 0
   2.271 - 	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
   2.272 -#else
   2.273 +#ifdef CONFIG_XEN
   2.274   	ROOT_DEV = MKDEV(RAMDISK_MAJOR,0); 
   2.275 -#endif
   2.276   	drive_info = DRIVE_INFO;
   2.277 -
   2.278 +	kernel_end = 0;		/* dummy */
   2.279  #ifdef CONFIG_XEN_PHYSDEV_ACCESS
   2.280   	screen_info = SCREEN_INFO;
   2.281 +
   2.282 +	/* This is drawn from a dump from vgacon:startup in standard Linux. */
   2.283 +	screen_info.orig_video_mode = 3; 
   2.284 +	screen_info.orig_video_isVGA = 1;
   2.285 +	screen_info.orig_video_lines = 25;
   2.286 +	screen_info.orig_video_cols = 80;
   2.287 +	screen_info.orig_video_ega_bx = 3;
   2.288 +	screen_info.orig_video_points = 16;
   2.289  #endif
   2.290  	edid_info = EDID_INFO;
   2.291  	saved_video_mode = SAVED_VIDEO_MODE;
   2.292 @@ -637,40 +625,48 @@ void __init setup_arch(char **cmdline_p)
   2.293  	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
   2.294  	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
   2.295  	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
   2.296 +
   2.297 +
   2.298 +#endif
   2.299 +
   2.300 +	HYPERVISOR_vm_assist(VMASST_CMD_enable,
   2.301 +			     VMASST_TYPE_writable_pagetables);
   2.302 +
   2.303 +        ARCH_SETUP
   2.304 +        print_memory_map(machine_specific_memory_setup());
   2.305 +#else
   2.306 + 	ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
   2.307 + 	drive_info = DRIVE_INFO;
   2.308 + 	screen_info = SCREEN_INFO;
   2.309 +	edid_info = EDID_INFO;
   2.310 +	saved_video_mode = SAVED_VIDEO_MODE;
   2.311 +	bootloader_type = LOADER_TYPE;
   2.312 +
   2.313 +#ifdef CONFIG_BLK_DEV_RAM
   2.314 +	rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
   2.315 +	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
   2.316 +	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
   2.317  #endif
   2.318 -
   2.319 -	HYPERVISOR_vm_assist(VMASST_CMD_enable,
   2.320 -			     VMASST_TYPE_writable_pagetables);
   2.321 -
   2.322 -#ifdef CONFIG_XEN_PHYSDEV_ACCESS
   2.323 -	/* This is drawn from a dump from vgacon:startup in standard Linux. */
   2.324 -	screen_info.orig_video_mode = 3; 
   2.325 -	screen_info.orig_video_isVGA = 1;
   2.326 -	screen_info.orig_video_lines = 25;
   2.327 -	screen_info.orig_video_cols = 80;
   2.328 -	screen_info.orig_video_ega_bx = 3;
   2.329 -	screen_info.orig_video_points = 16;
   2.330 -#endif       
   2.331 -        ARCH_SETUP
   2.332 -        print_memory_map(machine_specific_memory_setup());
   2.333 -
   2.334 -        /*	copy_edd();  */
   2.335 +	setup_memory_region();
   2.336 +	copy_edd();
   2.337 +#endif	/* !CONFIG_XEN */
   2.338  
   2.339  	if (!MOUNT_ROOT_RDONLY)
   2.340  		root_mountflags &= ~MS_RDONLY;
   2.341  	init_mm.start_code = (unsigned long) &_text;
   2.342  	init_mm.end_code = (unsigned long) &_etext;
   2.343  	init_mm.end_data = (unsigned long) &_edata;
   2.344 -/*	init_mm.brk = (unsigned long) &_end; */
   2.345 +#ifdef CONFIG_XEN
   2.346          init_mm.brk = start_pfn << PAGE_SHIFT;
   2.347 +#else
   2.348 +	init_mm.brk = (unsigned long) &_end;	
   2.349  
   2.350 -
   2.351 -#if 0  /* XEN: This is nonsense: kernel may not even be contiguous in RAM. */
   2.352  	code_resource.start = virt_to_phys(&_text);
   2.353  	code_resource.end = virt_to_phys(&_etext)-1;
   2.354  	data_resource.start = virt_to_phys(&_etext);
   2.355  	data_resource.end = virt_to_phys(&_edata)-1;
   2.356  #endif
   2.357 +
   2.358  	parse_cmdline_early(cmdline_p);
   2.359  
   2.360  	early_identify_cpu(&boot_cpu_data);
   2.361 @@ -679,15 +675,11 @@ void __init setup_arch(char **cmdline_p)
   2.362  	 * partially used pages are not usable - thus
   2.363  	 * we are rounding upwards:
   2.364  	 */
   2.365 -#if 0
   2.366  	end_pfn = e820_end_of_ram();
   2.367 -#else
   2.368 -        end_pfn = xen_end_of_ram();
   2.369 -#endif
   2.370  
   2.371  	check_efer();
   2.372  
   2.373 -	init_memory_mapping(0, (end_pfn << PAGE_SHIFT));
   2.374 +	init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
   2.375  
   2.376  #ifdef CONFIG_ACPI_NUMA
   2.377  	/*
   2.378 @@ -702,24 +694,25 @@ void __init setup_arch(char **cmdline_p)
   2.379  	contig_initmem_init(); 
   2.380  #endif
   2.381  
   2.382 -	/* Reserve direct mapping and shared info etc. */
   2.383 -//	reserve_bootmem_generic(table_start << PAGE_SHIFT, (table_end + 1 - table_start) << PAGE_SHIFT);
   2.384 -
   2.385 -//	reserve_bootmem_generic(0, (table_end + 1) << PAGE_SHIFT);
   2.386 +#ifndef CONFIG_XEN
   2.387 +	/* Reserve direct mapping */
   2.388 +	reserve_bootmem_generic(table_start << PAGE_SHIFT, 
   2.389 +				(table_end - table_start) << PAGE_SHIFT);
   2.390  
   2.391  	/* reserve kernel */
   2.392 -//	kernel_end = round_up(__pa_symbol(&_end),PAGE_SIZE);
   2.393 +	kernel_end = round_up(__pa_symbol(&_end),PAGE_SIZE);
   2.394 +	reserve_bootmem_generic(HIGH_MEMORY, kernel_end - HIGH_MEMORY);
   2.395  
   2.396 -#if 0
   2.397  	/*
   2.398  	 * reserve physical page 0 - it's a special BIOS page on many boxes,
   2.399  	 * enabling clean reboots, SMP operation, laptop functions.
   2.400  	 */
   2.401  	reserve_bootmem_generic(0, PAGE_SIZE);
   2.402 +
   2.403 +	/* reserve ebda region */
   2.404 +	reserve_ebda_region();
   2.405  #endif
   2.406  
   2.407 -	/* reserve ebda region */
   2.408 -/*	reserve_ebda_region(); */
   2.409  
   2.410  #ifdef CONFIG_SMP
   2.411  	/*
   2.412 @@ -739,6 +732,7 @@ void __init setup_arch(char **cmdline_p)
   2.413          */
   2.414         acpi_reserve_bootmem();
   2.415  #endif
   2.416 +#ifdef CONFIG_XEN
   2.417  #ifdef CONFIG_BLK_DEV_INITRD
   2.418  	if (xen_start_info.mod_start) {
   2.419  		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
   2.420 @@ -756,10 +750,27 @@ void __init setup_arch(char **cmdline_p)
   2.421  	}
   2.422  #endif
   2.423  #ifdef CONFIG_SMP
   2.424 -#ifdef CONFIG_XEN
   2.425  	smp_alloc_memory();
   2.426  #endif
   2.427 +#else	/* CONFIG_XEN */
   2.428 +#ifdef CONFIG_BLK_DEV_INITRD
   2.429 +	if (LOADER_TYPE && INITRD_START) {
   2.430 +		if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
   2.431 +			reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
   2.432 +			initrd_start =
   2.433 +				INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
   2.434 +			initrd_end = initrd_start+INITRD_SIZE;
   2.435 +		}
   2.436 +		else {
   2.437 +			printk(KERN_ERR "initrd extends beyond end of memory "
   2.438 +			    "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
   2.439 +			    (unsigned long)(INITRD_START + INITRD_SIZE),
   2.440 +			    (unsigned long)(end_pfn << PAGE_SHIFT));
   2.441 +			initrd_start = 0;
   2.442 +		}
   2.443 +	}
   2.444  #endif
   2.445 +#endif	/* !CONFIG_XEN */
   2.446  	paging_init();
   2.447  #ifdef CONFIG_X86_LOCAL_APIC
   2.448  	/*
   2.449 @@ -767,30 +778,36 @@ void __init setup_arch(char **cmdline_p)
   2.450  	 */
   2.451  	find_smp_config();
   2.452  #endif
   2.453 -	/* Make sure we have a large enough P->M table. */
   2.454 -	if (end_pfn > xen_start_info.nr_pages) {
   2.455 -		phys_to_machine_mapping = alloc_bootmem(
   2.456 -			max_pfn * sizeof(unsigned long));
   2.457 -		memset(phys_to_machine_mapping, ~0,
   2.458 -			max_pfn * sizeof(unsigned long));
   2.459 -		memcpy(phys_to_machine_mapping,
   2.460 -			(unsigned long *)xen_start_info.mfn_list,
   2.461 -			xen_start_info.nr_pages * sizeof(unsigned long));
   2.462 -		free_bootmem(
   2.463 -			__pa(xen_start_info.mfn_list), 
   2.464 -			PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
   2.465 -			sizeof(unsigned long))));
   2.466 +#ifdef CONFIG_XEN
   2.467 +	{
   2.468 +		int i, j;
   2.469 +		/* Make sure we have a large enough P->M table. */
   2.470 +		if (end_pfn > xen_start_info.nr_pages) {
   2.471 +			phys_to_machine_mapping = alloc_bootmem(
   2.472 +				max_pfn * sizeof(unsigned long));
   2.473 +			memset(phys_to_machine_mapping, ~0,
   2.474 +			       max_pfn * sizeof(unsigned long));
   2.475 +			memcpy(phys_to_machine_mapping,
   2.476 +			       (unsigned long *)xen_start_info.mfn_list,
   2.477 +			       xen_start_info.nr_pages * sizeof(unsigned long));
   2.478 +			free_bootmem(
   2.479 +				__pa(xen_start_info.mfn_list), 
   2.480 +				PFN_PHYS(PFN_UP(xen_start_info.nr_pages *
   2.481 +						sizeof(unsigned long))));
   2.482 +		}
   2.483 +
   2.484 +		pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE);
   2.485 +
   2.486 +		for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
   2.487 +		{	
   2.488 +			pfn_to_mfn_frame_list[j] = 
   2.489 +				virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   2.490 +		}
   2.491 +
   2.492  	}
   2.493 -
   2.494 -	pfn_to_mfn_frame_list = alloc_bootmem(PAGE_SIZE);
   2.495 +#endif
   2.496  
   2.497 -	for ( i=0, j=0; i < end_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
   2.498 -	{	
   2.499 -	     pfn_to_mfn_frame_list[j] = 
   2.500 -		  virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   2.501 -	}
   2.502 -
   2.503 -#if 0
   2.504 +#ifndef CONFIG_XEN
   2.505  	check_ioapic();
   2.506  #endif
   2.507  
   2.508 @@ -806,6 +823,7 @@ void __init setup_arch(char **cmdline_p)
   2.509  	 */
   2.510  	acpi_boot_init();
   2.511  #endif
   2.512 +
   2.513  #ifdef CONFIG_X86_LOCAL_APIC
   2.514  	/*
   2.515  	 * get boot-time SMP configuration:
   2.516 @@ -817,18 +835,14 @@ void __init setup_arch(char **cmdline_p)
   2.517  #endif
   2.518  #endif
   2.519  
   2.520 -        /* XXX Disable irqdebug until we have a way to avoid interrupt
   2.521 -	 * conflicts. */
   2.522 -/*	noirqdebug_setup(""); */
   2.523 -
   2.524 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
   2.525 +#if defined(CONFIG_XEN_PRIVILEGED_GUEST) || !defined(CONFIG_XEN)
   2.526  	/*
   2.527  	 * Request address space for all standard RAM and ROM resources
   2.528  	 * and also for regions reported as reserved by the e820.
   2.529  	 */
   2.530  	probe_roms();
   2.531 +	e820_reserve_resources();
   2.532  #endif
   2.533 -/*	e820_reserve_resources();  */
   2.534  
   2.535  	request_resource(&iomem_resource, &video_ram_resource);
   2.536  
   2.537 @@ -845,14 +859,40 @@ void __init setup_arch(char **cmdline_p)
   2.538         iommu_hole_init();
   2.539  #endif
   2.540  
   2.541 -	op.cmd             = PHYSDEVOP_SET_IOPL;
   2.542 -	op.u.set_iopl.iopl = 1;
   2.543 -	HYPERVISOR_physdev_op(&op);
   2.544 +#ifdef CONFIG_XEN
   2.545 +       {
   2.546 +	       physdev_op_t op;
   2.547 +
   2.548 +	       op.cmd             = PHYSDEVOP_SET_IOPL;
   2.549 +	       op.u.set_iopl.iopl = 1;
   2.550 +	       HYPERVISOR_physdev_op(&op);
   2.551  
   2.552 -	if (xen_start_info.flags & SIF_INITDOMAIN) {
   2.553 -		if (!(xen_start_info.flags & SIF_PRIVILEGED))
   2.554 -			panic("Xen granted us console access "
   2.555 -			      "but not privileged status");
   2.556 +	       if (xen_start_info.flags & SIF_INITDOMAIN) {
   2.557 +		       if (!(xen_start_info.flags & SIF_PRIVILEGED))
   2.558 +			       panic("Xen granted us console access "
   2.559 +				     "but not privileged status");
   2.560 +		       
   2.561 +#ifdef CONFIG_VT
   2.562 +#if defined(CONFIG_VGA_CONSOLE)
   2.563 +	       conswitchp = &vga_con;
   2.564 +#elif defined(CONFIG_DUMMY_CONSOLE)
   2.565 +	       conswitchp = &dummy_con;
   2.566 +#endif
   2.567 +#endif
   2.568 +	       } else {
   2.569 +#ifdef CONFIG_XEN_PRIVILEGED_GUEST
   2.570 +		       extern const struct consw xennull_con;
   2.571 +		       extern int console_use_vt;
   2.572 +#if defined(CONFIG_VGA_CONSOLE)
   2.573 +		/* disable VGA driver */
   2.574 +		       ORIG_VIDEO_ISVGA = VIDEO_TYPE_VLFB;
   2.575 +#endif
   2.576 +		       conswitchp = &xennull_con;
   2.577 +		       console_use_vt = 0;
   2.578 +#endif
   2.579 +	       }
   2.580 +       }
   2.581 +#else	/* CONFIG_XEN */
   2.582  
   2.583  #ifdef CONFIG_VT
   2.584  #if defined(CONFIG_VGA_CONSOLE)
   2.585 @@ -861,18 +901,8 @@ void __init setup_arch(char **cmdline_p)
   2.586  	conswitchp = &dummy_con;
   2.587  #endif
   2.588  #endif
   2.589 -	} else {
   2.590 -#ifdef CONFIG_XEN_PRIVILEGED_GUEST
   2.591 -		extern const struct consw xennull_con;
   2.592 -		extern int console_use_vt;
   2.593 -#if defined(CONFIG_VGA_CONSOLE)
   2.594 -		/* disable VGA driver */
   2.595 -		ORIG_VIDEO_ISVGA = VIDEO_TYPE_VLFB;
   2.596 -#endif
   2.597 -		conswitchp = &xennull_con;
   2.598 -		console_use_vt = 0;
   2.599 -#endif
   2.600 -	}
   2.601 +
   2.602 +#endif /* !CONFIG_XEN */
   2.603  }
   2.604  
   2.605  static int __init get_model_name(struct cpuinfo_x86 *c)