ia64/xen-unstable

changeset 7036:94c6fc048d8e

Clean up xc_vmx_build():
1. Remove linux parameters.
2. Remove init ramdisk.
3. Remove e820 memmap config file parse.
4. Removed provisional GDT.
5. Removed some ugly tailing space.

Signed-off-by: Xin B Li <xin.b.li@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 23 12:52:43 2005 +0100 (2005-09-23)
parents 43edce5b75d6
children 8a757f283fb8
files tools/examples/Makefile tools/examples/xmexample.vmx tools/firmware/vmxassist/Makefile tools/firmware/vmxassist/vmxloader.c tools/libxc/xc_vmx_build.c tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py xen/arch/x86/vmx_vmcs.c xen/include/asm-x86/e820.h xen/include/asm-x86/vmx_platform.h
line diff
     1.1 --- a/tools/examples/Makefile	Thu Sep 22 20:59:31 2005 +0100
     1.2 +++ b/tools/examples/Makefile	Fri Sep 23 12:52:43 2005 +0100
     1.3 @@ -25,19 +25,13 @@ XEN_SCRIPTS += block-phy
     1.4  XEN_SCRIPTS += block-file
     1.5  XEN_SCRIPTS += block-enbd
     1.6  
     1.7 -# no 64-bit specifics in mem-map.sxp
     1.8 -# so place in /usr/lib, not /usr/lib64
     1.9 -XEN_BOOT_DIR = /usr/lib/xen/boot
    1.10 -XEN_BOOT = mem-map.sxp
    1.11 -
    1.12  XEN_HOTPLUG_DIR = /etc/hotplug
    1.13  XEN_HOTPLUG_SCRIPTS = xen-backend.agent
    1.14  
    1.15  all:
    1.16  build:
    1.17  
    1.18 -install: all install-initd install-configs install-scripts install-boot \
    1.19 -	 install-hotplug
    1.20 +install: all install-initd install-configs install-scripts install-hotplug
    1.21  
    1.22  install-initd:
    1.23  	[ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d
    1.24 @@ -62,14 +56,6 @@ install-scripts:
    1.25  	    $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
    1.26  	done
    1.27  
    1.28 -install-boot:
    1.29 -	[ -d $(DESTDIR)$(XEN_BOOT_DIR) ] || \
    1.30 -		$(INSTALL_DIR) $(DESTDIR)$(XEN_BOOT_DIR)
    1.31 -	for i in $(XEN_BOOT); \
    1.32 -	    do [ -a $(DESTDIR)$(XEN_BOOT_DIR)/$$i ] || \
    1.33 -	    $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_BOOT_DIR); \
    1.34 -	done
    1.35 -
    1.36  install-hotplug:
    1.37  	[ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \
    1.38  		$(INSTALL_DIR) $(DESTDIR)$(XEN_HOTPLUG_DIR)
     2.1 --- a/tools/examples/mem-map.sxp	Thu Sep 22 20:59:31 2005 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,10 +0,0 @@
     2.4 -(memmap
     2.5 - (0000000000000000  000000000009f800 "AddressRangeMemory"   WB)
     2.6 - (000000000009f800  00000000000a0000 "AddressRangeReserved" UC)
     2.7 - (00000000000a0000  00000000000bffff "AddressRangeIO"       UC)
     2.8 - (00000000000f0000  0000000000100000 "AddressRangeReserved" UC)
     2.9 - (0000000000100000  0000000008000000 "AddressRangeMemory"   WB)
    2.10 - (0000000007fff000  0000000008000000 "AddressRangeShared"   WB)
    2.11 - (0000000008000000  0000000008003000 "AddressRangeNVS"      UC)
    2.12 - (0000000008003000  000000000800d000 "AddressRangeACPI"     WB)
    2.13 - (00000000fec00000  0000000100000000 "AddressRangeIO"       UC))
     3.1 --- a/tools/examples/xmexample.vmx	Thu Sep 22 20:59:31 2005 +0100
     3.2 +++ b/tools/examples/xmexample.vmx	Fri Sep 23 12:52:43 2005 +0100
     3.3 @@ -60,9 +60,6 @@ disk = [ 'file:/var/images/min-el3-i386.
     3.4  # New stuff
     3.5  device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
     3.6  
     3.7 -# Advanced users only. Don't touch if you don't know what you're doing
     3.8 -memmap = '/usr/lib/xen/boot/mem-map.sxp'
     3.9 -
    3.10  #-----------------------------------------------------------------------------
    3.11  # Disk image for 
    3.12  #cdrom=
     4.1 --- a/tools/firmware/vmxassist/Makefile	Thu Sep 22 20:59:31 2005 +0100
     4.2 +++ b/tools/firmware/vmxassist/Makefile	Fri Sep 23 12:52:43 2005 +0100
     4.3 @@ -44,7 +44,7 @@ all: vmxloader
     4.4  vmxloader: roms.h vmxloader.c acpi.h acpi_madt.c
     4.5  	${CC} ${CFLAGS} ${DEFINES} -c vmxloader.c -c acpi_madt.c
     4.6  	$(CC) -o vmxloader.tmp -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,0x100000 vmxloader.o acpi_madt.o
     4.7 -	objcopy --change-addresses=0xC0000000 vmxloader.tmp vmxloader
     4.8 +	objcopy vmxloader.tmp vmxloader
     4.9  	rm -f vmxloader.tmp
    4.10  
    4.11  vmxassist.bin: vmxassist.ld ${OBJECTS}
     5.1 --- a/tools/firmware/vmxassist/vmxloader.c	Thu Sep 22 20:59:31 2005 +0100
     5.2 +++ b/tools/firmware/vmxassist/vmxloader.c	Fri Sep 23 12:52:43 2005 +0100
     5.3 @@ -34,28 +34,39 @@ int acpi_madt_update(unsigned char* acpi
     5.4  /*
     5.5   * C runtime start off
     5.6   */
     5.7 -asm("					\n\
     5.8 -	.text				\n\
     5.9 -	.globl	_start			\n\
    5.10 -_start:					\n\
    5.11 -	cli				\n\
    5.12 -	movl	$stack_top, %esp	\n\
    5.13 -	movl	%esp, %ebp		\n\
    5.14 -	call    main			\n\
    5.15 -	jmp	halt			\n\
    5.16 -					\n\
    5.17 -	.globl	halt			\n\
    5.18 -halt:					\n\
    5.19 -	sti				\n\
    5.20 -	jmp	.			\n\
    5.21 -					\n\
    5.22 -	.bss				\n\
    5.23 -	.align	8			\n\
    5.24 -	.globl	stack, stack_top	\n\
    5.25 -stack:					\n\
    5.26 -	.skip	0x4000			\n\
    5.27 -stack_top:				\n\
    5.28 -");
    5.29 +asm(
    5.30 +"	.text				\n"
    5.31 +"	.globl	_start			\n"
    5.32 +"_start:				\n"
    5.33 +"	cld				\n"
    5.34 +"	cli				\n"
    5.35 +"	lgdt	gdt_desr		\n"
    5.36 +"	movl	$stack_top, %esp	\n"
    5.37 +"	movl	%esp, %ebp		\n"
    5.38 +"	call	main			\n"
    5.39 +"	jmp	halt			\n"
    5.40 +"					\n"
    5.41 +"gdt_desr:				\n"
    5.42 +"	.word	gdt_end - gdt - 1	\n"
    5.43 +"	.long	gdt			\n"
    5.44 +"					\n"
    5.45 +"	.align	8			\n"
    5.46 +"gdt:					\n"
    5.47 +"	.quad	0x0000000000000000	\n"
    5.48 +"	.quad	0x00CF92000000FFFF	\n"
    5.49 +"	.quad	0x00CF9A000000FFFF	\n"
    5.50 +"gdt_end:				\n"
    5.51 +"					\n"
    5.52 +"halt:					\n"
    5.53 +"	sti				\n"
    5.54 +"	jmp	.			\n"
    5.55 +"					\n"
    5.56 +"	.bss				\n"
    5.57 +"	.align	8			\n"
    5.58 +"stack:					\n"
    5.59 +"	.skip	0x4000			\n"
    5.60 +"stack_top:				\n"
    5.61 +);
    5.62  
    5.63  void *
    5.64  memcpy(void *dest, const void *src, unsigned n)
    5.65 @@ -95,7 +106,7 @@ cirrus_check(void)
    5.66  }
    5.67  
    5.68  int
    5.69 -main()
    5.70 +main(void)
    5.71  {
    5.72  	puts("VMXAssist Loader\n");
    5.73  	puts("Loading ROMBIOS ...\n");
     6.1 --- a/tools/libxc/linux_boot_params.h	Thu Sep 22 20:59:31 2005 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,166 +0,0 @@
     6.4 -#ifndef __LINUX_BOOT_PARAMS_H__
     6.5 -#define __LINUX_BOOT_PARAMS_H__
     6.6 -
     6.7 -#include <asm/types.h>
     6.8 -
     6.9 -#define E820MAX	32
    6.10 -
    6.11 -struct mem_map {
    6.12 -    int nr_map;
    6.13 -    struct entry {
    6.14 -        u64 addr;	/* start of memory segment */
    6.15 -        u64 size;	/* size of memory segment */
    6.16 -        u32 type;		/* type of memory segment */
    6.17 -#define E820_RAM        1
    6.18 -#define E820_RESERVED   2
    6.19 -#define E820_ACPI       3 /* usable as RAM once ACPI tables have been read */
    6.20 -#define E820_NVS        4
    6.21 -#define E820_IO         16
    6.22 -#define E820_SHARED     17
    6.23 -#define E820_XENSTORE   18
    6.24 -
    6.25 -        u32 caching_attr;    /* used by hypervisor */
    6.26 -#define MEMMAP_UC	0
    6.27 -#define MEMMAP_WC	1
    6.28 -#define MEMMAP_WT	4
    6.29 -#define MEMMAP_WP	5
    6.30 -#define MEMMAP_WB	6
    6.31 -
    6.32 -    }map[E820MAX];
    6.33 -};
    6.34 -
    6.35 -struct e820entry {
    6.36 -	u64 addr;	/* start of memory segment */
    6.37 -	u64 size;	/* size of memory segment */
    6.38 -	u32 type;	/* type of memory segment */
    6.39 -}__attribute__((packed));
    6.40 -
    6.41 -struct e820map {
    6.42 -    u32 nr_map;
    6.43 -    struct e820entry map[E820MAX];
    6.44 -}__attribute__((packed));
    6.45 -
    6.46 -struct drive_info_struct { __u8 dummy[32]; }; 
    6.47 -
    6.48 -struct sys_desc_table { 
    6.49 -    __u16 length; 
    6.50 -    __u8 table[318]; 
    6.51 -}; 
    6.52 -
    6.53 -struct screen_info {
    6.54 -    unsigned char  orig_x;		/* 0x00 */
    6.55 -    unsigned char  orig_y;		/* 0x01 */
    6.56 -    unsigned short dontuse1;		/* 0x02 -- EXT_MEM_K sits here */
    6.57 -    unsigned short orig_video_page;	/* 0x04 */
    6.58 -    unsigned char  orig_video_mode;	/* 0x06 */
    6.59 -    unsigned char  orig_video_cols;	/* 0x07 */
    6.60 -    unsigned short unused2;		/* 0x08 */
    6.61 -    unsigned short orig_video_ega_bx;	/* 0x0a */
    6.62 -    unsigned short unused3;		/* 0x0c */
    6.63 -    unsigned char  orig_video_lines;	/* 0x0e */
    6.64 -    unsigned char  orig_video_isVGA;	/* 0x0f */
    6.65 -    unsigned short orig_video_points;	/* 0x10 */
    6.66 -    
    6.67 -    /* VESA graphic mode -- linear frame buffer */
    6.68 -    unsigned short lfb_width;		/* 0x12 */
    6.69 -    unsigned short lfb_height;		/* 0x14 */
    6.70 -    unsigned short lfb_depth;		/* 0x16 */
    6.71 -    unsigned int   lfb_base;		/* 0x18 */
    6.72 -    unsigned int   lfb_size;		/* 0x1c */
    6.73 -    unsigned short dontuse2, dontuse3;	/* 0x20 -- CL_MAGIC and CL_OFFSET here */
    6.74 -    unsigned short lfb_linelength;	/* 0x24 */
    6.75 -    unsigned char  red_size;		/* 0x26 */
    6.76 -    unsigned char  red_pos;		/* 0x27 */
    6.77 -    unsigned char  green_size;		/* 0x28 */
    6.78 -    unsigned char  green_pos;		/* 0x29 */
    6.79 -    unsigned char  blue_size;		/* 0x2a */
    6.80 -    unsigned char  blue_pos;		/* 0x2b */
    6.81 -    unsigned char  rsvd_size;		/* 0x2c */
    6.82 -    unsigned char  rsvd_pos;		/* 0x2d */
    6.83 -    unsigned short vesapm_seg;		/* 0x2e */
    6.84 -    unsigned short vesapm_off;		/* 0x30 */
    6.85 -    unsigned short pages;		/* 0x32 */
    6.86 -					/* 0x34 -- 0x3f reserved for future expansion */
    6.87 -};
    6.88 -
    6.89 -struct screen_info_overlap { 
    6.90 -    __u8 reserved1[2]; /* 0x00 */ 
    6.91 -    __u16 ext_mem_k; /* 0x02 */ 
    6.92 -    __u8 reserved2[0x20 - 0x04]; /* 0x04 */ 
    6.93 -    __u16 cl_magic; /* 0x20 */ 
    6.94 -#define CL_MAGIC_VALUE 0xA33F 
    6.95 -    __u16 cl_offset; /* 0x22 */ 
    6.96 -    __u8 reserved3[0x40 - 0x24]; /* 0x24 */ 
    6.97 -}; 
    6.98 -
    6.99 -
   6.100 -struct apm_bios_info {
   6.101 -    __u16 version;
   6.102 -    __u16  cseg;
   6.103 -    __u32   offset;
   6.104 -    __u16  cseg_16;
   6.105 -    __u16  dseg;
   6.106 -    __u16  flags;
   6.107 -    __u16  cseg_len;
   6.108 -    __u16  cseg_16_len;
   6.109 -    __u16  dseg_len;
   6.110 -};
   6.111 - 
   6.112 -struct linux_boot_params { 
   6.113 -    union { /* 0x00 */ 
   6.114 -       struct screen_info info; 
   6.115 -       struct screen_info_overlap overlap; 
   6.116 -    } screen; 
   6.117 - 
   6.118 -    struct apm_bios_info apm_bios_info; /* 0x40 */ 
   6.119 -    __u8 reserved4[0x80 - 0x54]; /* 0x54 */ 
   6.120 -    struct drive_info_struct drive_info; /* 0x80 */ 
   6.121 -    struct sys_desc_table sys_desc_table; /* 0xa0 */ 
   6.122 -    __u32 alt_mem_k; /* 0x1e0 */ 
   6.123 -    __u8 reserved5[4]; /* 0x1e4 */ 
   6.124 -    __u8 e820_map_nr; /* 0x1e8 */ 
   6.125 -    __u8 reserved6[8]; /* 0x1e9 */ 
   6.126 -    __u8 setup_sects; /* 0x1f1 */ 
   6.127 -    __u16 mount_root_rdonly; /* 0x1f2 */ 
   6.128 -    __u16 syssize; /* 0x1f4 */ 
   6.129 -    __u16 swapdev; /* 0x1f6 */ 
   6.130 -    __u16 ramdisk_flags; /* 0x1f8 */ 
   6.131 -#define RAMDISK_IMAGE_START_MASK 0x07FF 
   6.132 -#define RAMDISK_PROMPT_FLAG 0x8000 
   6.133 -#define RAMDISK_LOAD_FLAG 0x4000 
   6.134 -    __u16 vid_mode; /* 0x1fa */ 
   6.135 -    __u16 root_dev; /* 0x1fc */ 
   6.136 -    __u8 reserved9[1]; /* 0x1fe */ 
   6.137 -    __u8 aux_device_info; /* 0x1ff */ 
   6.138 -    /* 2.00+ */ 
   6.139 -    __u8 reserved10[2]; /* 0x200 */ 
   6.140 -    __u8 header_magic[4]; /* 0x202 */ 
   6.141 -    __u16 protocol_version; /* 0x206 */ 
   6.142 -    __u8 reserved11[8]; /* 0x208 */ 
   6.143 -    __u8 loader_type; /* 0x210 */ 
   6.144 -#define LOADER_TYPE_LOADLIN 1 
   6.145 -#define LOADER_TYPE_BOOTSECT_LOADER 2 
   6.146 -#define LOADER_TYPE_SYSLINUX 3 
   6.147 -#define LOADER_TYPE_ETHERBOOT 4 
   6.148 -#define LOADER_TYPE_UNKNOWN 0xFF 
   6.149 -    __u8 loader_flags; /* 0x211 */ 
   6.150 -    __u8 reserved12[2]; /* 0x212 */ 
   6.151 -    __u32 code32_start; /* 0x214 */ 
   6.152 -    __u32 initrd_start; /* 0x218 */ 
   6.153 -    __u32 initrd_size; /* 0x21c */ 
   6.154 -    __u8 reserved13[4]; /* 0x220 */ 
   6.155 -    /* 2.01+ */ 
   6.156 -    __u16 heap_end_ptr; /* 0x224 */ 
   6.157 -    __u8 reserved14[2]; /* 0x226 */ 
   6.158 -    /* 2.02+ */ 
   6.159 -    __u32 cmd_line_ptr; /* 0x228 */ 
   6.160 -    /* 2.03+ */ 
   6.161 -    __u32 ramdisk_max; /* 0x22c */ 
   6.162 -    __u8 reserved15[0x2d0 - 0x230]; /* 0x230 */ 
   6.163 -    struct e820entry e820_map[E820MAX]; /* 0x2d0 */ 
   6.164 -    __u64 shared_info; /* 0x550 */
   6.165 -    __u8 padding[0x800 - 0x558]; /* 0x558 */ 
   6.166 -    __u8 cmd_line[0x800]; /* 0x800 */
   6.167 -} __attribute__((packed)); 
   6.168 -
   6.169 -#endif /* __LINUX_BOOT_PARAMS_H__ */
     7.1 --- a/tools/libxc/xc_vmx_build.c	Thu Sep 22 20:59:31 2005 +0100
     7.2 +++ b/tools/libxc/xc_vmx_build.c	Fri Sep 23 12:52:43 2005 +0100
     7.3 @@ -10,7 +10,8 @@
     7.4  #include <unistd.h>
     7.5  #include <zlib.h>
     7.6  #include <xen/io/ioreq.h>
     7.7 -#include "linux_boot_params.h"
     7.8 +
     7.9 +#define VMX_LOADER_ENTR_ADDR  0x00100000
    7.10  
    7.11  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
    7.12  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
    7.13 @@ -18,13 +19,29 @@
    7.14  #define L3_PROT (_PAGE_PRESENT)
    7.15  #endif
    7.16  
    7.17 +#define E820MAX	128
    7.18 +
    7.19 +#define E820_RAM          1
    7.20 +#define E820_RESERVED     2
    7.21 +#define E820_ACPI         3
    7.22 +#define E820_NVS          4
    7.23 +#define E820_IO          16
    7.24 +#define E820_SHARED_PAGE 17
    7.25 +#define E820_XENSTORE    18
    7.26 +
    7.27 +#define E820_MAP_PAGE        0x00090000
    7.28 +#define E820_MAP_NR_OFFSET   0x000001E8
    7.29 +#define E820_MAP_OFFSET      0x000002D0
    7.30 +
    7.31 +struct e820entry {
    7.32 +    u64 addr;
    7.33 +    u64 size;
    7.34 +    u32 type;
    7.35 +} __attribute__((packed));
    7.36 +
    7.37  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    7.38  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    7.39  
    7.40 -#define LINUX_BOOT_PARAMS_ADDR   0x00090000
    7.41 -#define LINUX_KERNEL_ENTR_ADDR   0x00100000
    7.42 -#define LINUX_PAGE_OFFSET        0xC0000000
    7.43 -
    7.44  static int
    7.45  parseelfimage(
    7.46      char *elfbase, unsigned long elfsize, struct domain_setup_info *dsi);
    7.47 @@ -33,78 +50,70 @@ loadelfimage(
    7.48      char *elfbase, int xch, u32 dom, unsigned long *parray,
    7.49      struct domain_setup_info *dsi);
    7.50  
    7.51 -static void build_e820map(struct mem_map *mem_mapp, unsigned long mem_size)
    7.52 +static unsigned char build_e820map(void *e820_page, unsigned long mem_size)
    7.53  {
    7.54 -    int nr_map = 0;
    7.55 +    struct e820entry *e820entry =
    7.56 +        (struct e820entry *)(((unsigned char *)e820_page) + E820_MAP_OFFSET);
    7.57 +    unsigned char nr_map = 0;
    7.58  
    7.59      /* XXX: Doesn't work for > 4GB yet */
    7.60 -    mem_mapp->map[nr_map].addr = 0x0;
    7.61 -    mem_mapp->map[nr_map].size = 0x9F800;
    7.62 -    mem_mapp->map[nr_map].type = E820_RAM;
    7.63 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
    7.64 +    e820entry[nr_map].addr = 0x0;
    7.65 +    e820entry[nr_map].size = 0x9F800;
    7.66 +    e820entry[nr_map].type = E820_RAM;
    7.67      nr_map++;
    7.68  
    7.69 -    mem_mapp->map[nr_map].addr = 0x9F800;
    7.70 -    mem_mapp->map[nr_map].size = 0x800;
    7.71 -    mem_mapp->map[nr_map].type = E820_RESERVED;
    7.72 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    7.73 +    e820entry[nr_map].addr = 0x9F800;
    7.74 +    e820entry[nr_map].size = 0x800;
    7.75 +    e820entry[nr_map].type = E820_RESERVED;
    7.76      nr_map++;
    7.77  
    7.78 -    mem_mapp->map[nr_map].addr = 0xA0000;
    7.79 -    mem_mapp->map[nr_map].size = 0x20000;
    7.80 -    mem_mapp->map[nr_map].type = E820_IO;
    7.81 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    7.82 +    e820entry[nr_map].addr = 0xA0000;
    7.83 +    e820entry[nr_map].size = 0x20000;
    7.84 +    e820entry[nr_map].type = E820_IO;
    7.85      nr_map++;
    7.86  
    7.87 -    mem_mapp->map[nr_map].addr = 0xF0000;
    7.88 -    mem_mapp->map[nr_map].size = 0x10000;
    7.89 -    mem_mapp->map[nr_map].type = E820_RESERVED;
    7.90 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
    7.91 +    e820entry[nr_map].addr = 0xF0000;
    7.92 +    e820entry[nr_map].size = 0x10000;
    7.93 +    e820entry[nr_map].type = E820_RESERVED;
    7.94      nr_map++;
    7.95  
    7.96  #define STATIC_PAGES    2       /* for ioreq_t and store_mfn */
    7.97      /* Most of the ram goes here */
    7.98 -    mem_mapp->map[nr_map].addr = 0x100000;
    7.99 -    mem_mapp->map[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE;
   7.100 -    mem_mapp->map[nr_map].type = E820_RAM;
   7.101 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
   7.102 +    e820entry[nr_map].addr = 0x100000;
   7.103 +    e820entry[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE;
   7.104 +    e820entry[nr_map].type = E820_RAM;
   7.105      nr_map++;
   7.106  
   7.107      /* Statically allocated special pages */
   7.108  
   7.109      /* Shared ioreq_t page */
   7.110 -    mem_mapp->map[nr_map].addr = mem_size - PAGE_SIZE;
   7.111 -    mem_mapp->map[nr_map].size = PAGE_SIZE;
   7.112 -    mem_mapp->map[nr_map].type = E820_SHARED;
   7.113 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
   7.114 +    e820entry[nr_map].addr = mem_size - PAGE_SIZE;
   7.115 +    e820entry[nr_map].size = PAGE_SIZE;
   7.116 +    e820entry[nr_map].type = E820_SHARED_PAGE;
   7.117      nr_map++;
   7.118  
   7.119      /* For xenstore */
   7.120 -    mem_mapp->map[nr_map].addr = mem_size - 2*PAGE_SIZE;
   7.121 -    mem_mapp->map[nr_map].size = PAGE_SIZE;
   7.122 -    mem_mapp->map[nr_map].type = E820_XENSTORE;
   7.123 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
   7.124 +    e820entry[nr_map].addr = mem_size - 2*PAGE_SIZE;
   7.125 +    e820entry[nr_map].size = PAGE_SIZE;
   7.126 +    e820entry[nr_map].type = E820_XENSTORE;
   7.127      nr_map++;
   7.128  
   7.129 -    mem_mapp->map[nr_map].addr = mem_size;
   7.130 -    mem_mapp->map[nr_map].size = 0x3 * PAGE_SIZE;
   7.131 -    mem_mapp->map[nr_map].type = E820_NVS;
   7.132 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
   7.133 +    e820entry[nr_map].addr = mem_size;
   7.134 +    e820entry[nr_map].size = 0x3 * PAGE_SIZE;
   7.135 +    e820entry[nr_map].type = E820_NVS;
   7.136      nr_map++;
   7.137  
   7.138 -    mem_mapp->map[nr_map].addr = mem_size + 0x3 * PAGE_SIZE;
   7.139 -    mem_mapp->map[nr_map].size = 0xA * PAGE_SIZE;
   7.140 -    mem_mapp->map[nr_map].type = E820_ACPI;
   7.141 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_WB;
   7.142 +    e820entry[nr_map].addr = mem_size + 0x3 * PAGE_SIZE;
   7.143 +    e820entry[nr_map].size = 0xA * PAGE_SIZE;
   7.144 +    e820entry[nr_map].type = E820_ACPI;
   7.145      nr_map++;
   7.146  
   7.147 -    mem_mapp->map[nr_map].addr = 0xFEC00000;
   7.148 -    mem_mapp->map[nr_map].size = 0x1400000;
   7.149 -    mem_mapp->map[nr_map].type = E820_IO;
   7.150 -    mem_mapp->map[nr_map].caching_attr = MEMMAP_UC;
   7.151 +    e820entry[nr_map].addr = 0xFEC00000;
   7.152 +    e820entry[nr_map].size = 0x1400000;
   7.153 +    e820entry[nr_map].type = E820_IO;
   7.154      nr_map++;
   7.155  
   7.156 -    mem_mapp->nr_map = nr_map;
   7.157 +    return (*(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map);
   7.158  }
   7.159  
   7.160  /*
   7.161 @@ -112,19 +121,19 @@ static void build_e820map(struct mem_map
   7.162   * vmxloader will use it to config ACPI MADT table
   7.163   */
   7.164  #define VCPU_MAGIC 0x76637075 /* "vcpu" */
   7.165 -static int 
   7.166 -set_nr_vcpus(int xc_handle, u32 dom, unsigned long *pfn_list, 
   7.167 +static int
   7.168 +set_nr_vcpus(int xc_handle, u32 dom, unsigned long *pfn_list,
   7.169               struct domain_setup_info *dsi, unsigned long vcpus)
   7.170  {
   7.171      char          *va_map;
   7.172      unsigned long *va_vcpus;
   7.173 -    
   7.174 +
   7.175      va_map = xc_map_foreign_range(
   7.176          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   7.177 -        pfn_list[(0x9F000 - dsi->v_start) >> PAGE_SHIFT]);    
   7.178 +        pfn_list[(0x9F000 - dsi->v_start) >> PAGE_SHIFT]);
   7.179      if ( va_map == NULL )
   7.180          return -1;
   7.181 -    
   7.182 +
   7.183      va_vcpus = (unsigned long *)(va_map + 0x800);
   7.184      *va_vcpus++ = VCPU_MAGIC;
   7.185      *va_vcpus++ = vcpus;
   7.186 @@ -164,24 +173,23 @@ static int zap_mmio_range(int xc_handle,
   7.187      return 0;
   7.188  }
   7.189  
   7.190 -static int zap_mmio_ranges(int xc_handle, u32 dom,
   7.191 -                           unsigned long l2tab,
   7.192 -                           struct mem_map *mem_mapp)
   7.193 +static int zap_mmio_ranges(int xc_handle, u32 dom, unsigned long l2tab,
   7.194 +                           unsigned char e820_map_nr, unsigned char *e820map)
   7.195  {
   7.196 -    int i;
   7.197 +    unsigned int i;
   7.198 +    struct e820entry *e820entry = (struct e820entry *)e820map;
   7.199 +
   7.200      l2_pgentry_32_t *vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   7.201                                                     PROT_READ|PROT_WRITE,
   7.202                                                     l2tab >> PAGE_SHIFT);
   7.203      if ( vl2tab == 0 )
   7.204          return -1;
   7.205  
   7.206 -    for ( i = 0; i < mem_mapp->nr_map; i++ )
   7.207 +    for ( i = 0; i < e820_map_nr; i++ )
   7.208      {
   7.209 -        if ( (mem_mapp->map[i].type == E820_IO) &&
   7.210 -             (mem_mapp->map[i].caching_attr == MEMMAP_UC) &&
   7.211 +        if ( (e820entry[i].type == E820_IO) &&
   7.212               (zap_mmio_range(xc_handle, dom, vl2tab,
   7.213 -                             mem_mapp->map[i].addr,
   7.214 -                             mem_mapp->map[i].size) == -1) )
   7.215 +                             e820entry[i].addr, e820entry[i].size) == -1))
   7.216              return -1;
   7.217      }
   7.218  
   7.219 @@ -200,7 +208,7 @@ static int zap_mmio_range(int xc_handle,
   7.220      unsigned long vl3e;
   7.221      l1_pgentry_t *vl1tab;
   7.222      l2_pgentry_t *vl2tab;
   7.223 - 
   7.224 +
   7.225      mmio_addr = mmio_range_start & PAGE_MASK;
   7.226      for ( ; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE )
   7.227      {
   7.228 @@ -239,22 +247,22 @@ static int zap_mmio_range(int xc_handle,
   7.229      return 0;
   7.230  }
   7.231  
   7.232 -static int zap_mmio_ranges(int xc_handle, u32 dom,
   7.233 -                           unsigned long l3tab,
   7.234 -                           struct mem_map *mem_mapp)
   7.235 +static int zap_mmio_ranges(int xc_handle, u32 dom, unsigned long l3tab,
   7.236 +                           unsigned char e820_map_nr, unsigned char *e820map)
   7.237  {
   7.238 -    int i;
   7.239 +    unsigned int i;
   7.240 +    struct e820entry *e820entry = (struct e820entry *)e820map;
   7.241 +
   7.242      l3_pgentry_t *vl3tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   7.243                                                  PROT_READ|PROT_WRITE,
   7.244                                                  l3tab >> PAGE_SHIFT);
   7.245      if (vl3tab == 0)
   7.246          return -1;
   7.247 -    for (i = 0; i < mem_mapp->nr_map; i++) {
   7.248 -        if ((mem_mapp->map[i].type == E820_IO)
   7.249 -            && (mem_mapp->map[i].caching_attr == MEMMAP_UC))
   7.250 -            if (zap_mmio_range(xc_handle, dom, vl3tab,
   7.251 -                               mem_mapp->map[i].addr, mem_mapp->map[i].size) == -1)
   7.252 -                return -1;
   7.253 +    for ( i = 0; i < e820_map_nr; i++ ) {
   7.254 +        if ( (e820entry[i].type == E820_IO) &&
   7.255 +             (zap_mmio_range(xc_handle, dom, vl3tab,
   7.256 +                             e820entry[i].addr, e820entry[i].size) == -1) )
   7.257 +            return -1;
   7.258      }
   7.259      munmap(vl3tab, PAGE_SIZE);
   7.260      return 0;
   7.261 @@ -265,18 +273,14 @@ static int zap_mmio_ranges(int xc_handle
   7.262  static int setup_guest(int xc_handle,
   7.263                         u32 dom, int memsize,
   7.264                         char *image, unsigned long image_size,
   7.265 -                       gzFile initrd_gfd, unsigned long initrd_len,
   7.266                         unsigned long nr_pages,
   7.267                         vcpu_guest_context_t *ctxt,
   7.268 -                       const char *cmdline,
   7.269                         unsigned long shared_info_frame,
   7.270                         unsigned int control_evtchn,
   7.271                         unsigned long flags,
   7.272                         unsigned int vcpus,
   7.273                         unsigned int store_evtchn,
   7.274 -                       unsigned long *store_mfn,
   7.275 -                       struct mem_map *mem_mapp
   7.276 -    )
   7.277 +                       unsigned long *store_mfn)
   7.278  {
   7.279      l1_pgentry_t *vl1tab=NULL, *vl1e=NULL;
   7.280      l2_pgentry_t *vl2tab=NULL, *vl2e=NULL;
   7.281 @@ -289,8 +293,8 @@ static int setup_guest(int xc_handle,
   7.282      unsigned long l1tab;
   7.283      unsigned long count, i;
   7.284      shared_info_t *shared_info;
   7.285 -    struct linux_boot_params * boot_paramsp;
   7.286 -    __u16 * boot_gdtp;
   7.287 +    void *e820_page;
   7.288 +    unsigned char e820_map_nr;
   7.289      xc_mmu_t *mmu = NULL;
   7.290      int rc;
   7.291  
   7.292 @@ -298,12 +302,6 @@ static int setup_guest(int xc_handle,
   7.293      unsigned long ppt_alloc;
   7.294  
   7.295      struct domain_setup_info dsi;
   7.296 -    unsigned long vinitrd_start;
   7.297 -    unsigned long vinitrd_end;
   7.298 -    unsigned long vboot_params_start;
   7.299 -    unsigned long vboot_params_end;
   7.300 -    unsigned long vboot_gdt_start;
   7.301 -    unsigned long vboot_gdt_end;
   7.302      unsigned long vpt_start;
   7.303      unsigned long vpt_end;
   7.304      unsigned long v_end;
   7.305 @@ -322,27 +320,8 @@ static int setup_guest(int xc_handle,
   7.306          goto error_out;
   7.307      }
   7.308  
   7.309 -    /*
   7.310 -     * Why do we need this? The number of page-table frames depends on the 
   7.311 -     * size of the bootstrap address space. But the size of the address space 
   7.312 -     * depends on the number of page-table frames (since each one is mapped 
   7.313 -     * read-only). We have a pair of simultaneous equations in two unknowns, 
   7.314 -     * which we solve by exhaustive search.
   7.315 -     */
   7.316 -    vboot_params_start = LINUX_BOOT_PARAMS_ADDR;
   7.317 -    vboot_params_end   = vboot_params_start + PAGE_SIZE;
   7.318 -    vboot_gdt_start    = vboot_params_end;
   7.319 -    vboot_gdt_end      = vboot_gdt_start + PAGE_SIZE;
   7.320 -
   7.321      /* memsize is in megabytes */
   7.322      v_end              = memsize << 20;
   7.323 -    /* leaving the top 4k untouched for IO requests page use */
   7.324 -    vinitrd_end        = v_end - PAGE_SIZE;
   7.325 -    vinitrd_start      = vinitrd_end - initrd_len;
   7.326 -    vinitrd_start      = vinitrd_start & (~(PAGE_SIZE - 1));
   7.327 -
   7.328 -    if(initrd_len == 0)
   7.329 -        vinitrd_start = vinitrd_end = 0;
   7.330  
   7.331  #ifdef __i386__
   7.332      nr_pt_pages = 1 + ((memsize + 3) >> 2);
   7.333 @@ -353,24 +332,17 @@ static int setup_guest(int xc_handle,
   7.334      vpt_end     = vpt_start + (nr_pt_pages * PAGE_SIZE);
   7.335  
   7.336      printf("VIRTUAL MEMORY ARRANGEMENT:\n"
   7.337 -           " Boot_params:   %08lx->%08lx\n"
   7.338 -           " boot_gdt:      %08lx->%08lx\n"
   7.339 -           " Loaded kernel: %08lx->%08lx\n"
   7.340 -           " Init. ramdisk: %08lx->%08lx\n"
   7.341 +           " Loaded VMX loader: %08lx->%08lx\n"
   7.342             " Page tables:   %08lx->%08lx\n"
   7.343             " TOTAL:         %08lx->%08lx\n",
   7.344 -           vboot_params_start, vboot_params_end,
   7.345 -           vboot_gdt_start, vboot_gdt_end,
   7.346 -           dsi.v_kernstart, dsi.v_kernend, 
   7.347 -           vinitrd_start, vinitrd_end,
   7.348 +           dsi.v_kernstart, dsi.v_kernend,
   7.349             vpt_start, vpt_end,
   7.350             dsi.v_start, v_end);
   7.351      printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
   7.352 -    printf(" INITRD LENGTH: %08lx\n", initrd_len);
   7.353  
   7.354      if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) )
   7.355      {
   7.356 -        printf("Initial guest OS requires too much space\n"
   7.357 +        ERROR("Initial guest OS requires too much space\n"
   7.358                 "(%luMB is greater than %luMB limit)\n",
   7.359                 (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20);
   7.360          goto error_out;
   7.361 @@ -390,23 +362,6 @@ static int setup_guest(int xc_handle,
   7.362  
   7.363      loadelfimage(image, xc_handle, dom, page_array, &dsi);
   7.364  
   7.365 -    /* Load the initial ramdisk image. */
   7.366 -    if ( initrd_len != 0 )
   7.367 -    {
   7.368 -        for ( i = (vinitrd_start - dsi.v_start); 
   7.369 -              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
   7.370 -        {
   7.371 -            char page[PAGE_SIZE];
   7.372 -            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
   7.373 -            {
   7.374 -                PERROR("Error reading initrd image, could not");
   7.375 -                goto error_out;
   7.376 -            }
   7.377 -            xc_copy_to_domain_page(xc_handle, dom,
   7.378 -                                   page_array[i>>PAGE_SHIFT], page);
   7.379 -        }
   7.380 -    }
   7.381 -
   7.382      if ( (mmu = xc_init_mmu_updates(xc_handle, dom)) == NULL )
   7.383          goto error_out;
   7.384  
   7.385 @@ -429,14 +384,14 @@ static int setup_guest(int xc_handle,
   7.386      ctxt->ctrlreg[3] = l2tab;
   7.387  
   7.388      /* Initialise the page tables. */
   7.389 -    if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
   7.390 -                                        PROT_READ|PROT_WRITE, 
   7.391 +    if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   7.392 +                                        PROT_READ|PROT_WRITE,
   7.393                                          l2tab >> PAGE_SHIFT)) == NULL )
   7.394          goto error_out;
   7.395      memset(vl2tab, 0, PAGE_SIZE);
   7.396      vl2e = &vl2tab[l2_table_offset(dsi.v_start)];
   7.397      for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ )
   7.398 -    {    
   7.399 +    {
   7.400          if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 )
   7.401          {
   7.402              l1tab = page_array[ppt_alloc++] << PAGE_SHIFT;
   7.403 @@ -465,8 +420,8 @@ static int setup_guest(int xc_handle,
   7.404      ctxt->ctrlreg[3] = l3tab;
   7.405  
   7.406      /* Initialise the page tables. */
   7.407 -    if ( (vl3tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 
   7.408 -                                        PROT_READ|PROT_WRITE, 
   7.409 +    if ( (vl3tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   7.410 +                                        PROT_READ|PROT_WRITE,
   7.411                                          l3tab >> PAGE_SHIFT)) == NULL )
   7.412          goto error_out;
   7.413      memset(vl3tab, 0, PAGE_SIZE);
   7.414 @@ -519,103 +474,31 @@ static int setup_guest(int xc_handle,
   7.415      for ( count = 0; count < nr_pages; count++ )
   7.416      {
   7.417          if ( xc_add_mmu_update(xc_handle, mmu,
   7.418 -                               (page_array[count] << PAGE_SHIFT) | 
   7.419 +                               (page_array[count] << PAGE_SHIFT) |
   7.420                                 MMU_MACHPHYS_UPDATE, count) )
   7.421              goto error_out;
   7.422      }
   7.423  
   7.424      set_nr_vcpus(xc_handle, dom, page_array, &dsi, vcpus);
   7.425  
   7.426 -    if ((boot_paramsp = xc_map_foreign_range(
   7.427 -        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   7.428 -        page_array[(vboot_params_start-dsi.v_start)>>PAGE_SHIFT])) == 0)
   7.429 -        goto error_out;
   7.430 -
   7.431 -    memset(boot_paramsp, 0, sizeof(*boot_paramsp));
   7.432 -
   7.433 -    strncpy((char *)boot_paramsp->cmd_line, cmdline, 0x800);
   7.434 -    boot_paramsp->cmd_line[0x800-1] = '\0';
   7.435 -    boot_paramsp->cmd_line_ptr = ((unsigned long) vboot_params_start) + offsetof(struct linux_boot_params, cmd_line);
   7.436 -
   7.437 -    boot_paramsp->setup_sects = 0;
   7.438 -    boot_paramsp->mount_root_rdonly = 1;
   7.439 -    boot_paramsp->swapdev = 0x0; 
   7.440 -    boot_paramsp->ramdisk_flags = 0x0; 
   7.441 -    boot_paramsp->root_dev = 0x0; /* We must tell kernel root dev by kernel command line. */
   7.442 -
   7.443 -    /* we don't have a ps/2 mouse now.
   7.444 -     * 0xAA means a aux mouse is there.
   7.445 -     * See detect_auxiliary_port() in pc_keyb.c.
   7.446 -     */
   7.447 -    boot_paramsp->aux_device_info = 0x0; 
   7.448 -
   7.449 -    boot_paramsp->header_magic[0] = 0x48; /* "H" */
   7.450 -    boot_paramsp->header_magic[1] = 0x64; /* "d" */
   7.451 -    boot_paramsp->header_magic[2] = 0x72; /* "r" */
   7.452 -    boot_paramsp->header_magic[3] = 0x53; /* "S" */
   7.453 -
   7.454 -    boot_paramsp->protocol_version = 0x0203; /* 2.03 */
   7.455 -    boot_paramsp->loader_type = 0x71; /* GRUB */
   7.456 -    boot_paramsp->loader_flags = 0x1; /* loaded high */
   7.457 -    boot_paramsp->code32_start = LINUX_KERNEL_ENTR_ADDR; /* 1MB */
   7.458 -    boot_paramsp->initrd_start = vinitrd_start;
   7.459 -    boot_paramsp->initrd_size = initrd_len;
   7.460 -
   7.461 -    i = ((memsize - 1) << 10) - 4;
   7.462 -    boot_paramsp->alt_mem_k = i; /* alt_mem_k */
   7.463 -    boot_paramsp->screen.overlap.ext_mem_k = i & 0xFFFF; /* ext_mem_k */
   7.464 +    *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT];
   7.465 +    shared_page_frame = (v_end - PAGE_SIZE) >> PAGE_SHIFT;
   7.466  
   7.467 -    /*
   7.468 -     * Stuff SCREAN_INFO
   7.469 -     */
   7.470 -    boot_paramsp->screen.info.orig_x = 0;
   7.471 -    boot_paramsp->screen.info.orig_y = 0;
   7.472 -    boot_paramsp->screen.info.orig_video_page = 8;
   7.473 -    boot_paramsp->screen.info.orig_video_mode = 3;
   7.474 -    boot_paramsp->screen.info.orig_video_cols = 80;
   7.475 -    boot_paramsp->screen.info.orig_video_ega_bx = 0;
   7.476 -    boot_paramsp->screen.info.orig_video_lines = 25;
   7.477 -    boot_paramsp->screen.info.orig_video_isVGA = 1;
   7.478 -    boot_paramsp->screen.info.orig_video_points = 0x0010;
   7.479 -
   7.480 -    /* seems we may NOT stuff boot_paramsp->apm_bios_info */
   7.481 -    /* seems we may NOT stuff boot_paramsp->drive_info */
   7.482 -    /* seems we may NOT stuff boot_paramsp->sys_desc_table */
   7.483 -    *((unsigned short *) &boot_paramsp->drive_info.dummy[0]) = 800;
   7.484 -    boot_paramsp->drive_info.dummy[2] = 4;
   7.485 -    boot_paramsp->drive_info.dummy[14] = 32;
   7.486 -
   7.487 -    /* memsize is in megabytes */
   7.488 -    /* If you need to create a special e820map, comment this line
   7.489 -       and use mem-map.sxp */
   7.490 -    build_e820map(mem_mapp, memsize << 20);
   7.491 -    *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT];
   7.492 +    if ((e820_page = xc_map_foreign_range(
   7.493 +        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   7.494 +        page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0)
   7.495 +        goto error_out;
   7.496 +    memset(e820_page, 0, PAGE_SIZE);
   7.497 +    e820_map_nr = build_e820map(e820_page, v_end);
   7.498  #if defined (__i386__)
   7.499 -    if (zap_mmio_ranges(xc_handle, dom, l2tab, mem_mapp) == -1)
   7.500 +    if (zap_mmio_ranges(xc_handle, dom, l2tab, e820_map_nr,
   7.501 +                        ((unsigned char *)e820_page) + E820_MAP_OFFSET) == -1)
   7.502  #else
   7.503 -        if (zap_mmio_ranges(xc_handle, dom, l3tab, mem_mapp) == -1)
   7.504 +    if (zap_mmio_ranges(xc_handle, dom, l3tab, e820_map_nr,
   7.505 +                        ((unsigned char *)e820_page) + E820_MAP_OFFSET) == -1)
   7.506  #endif
   7.507 -            goto error_out;
   7.508 -    boot_paramsp->e820_map_nr = mem_mapp->nr_map;
   7.509 -    for (i=0; i<mem_mapp->nr_map; i++) {
   7.510 -        boot_paramsp->e820_map[i].addr = mem_mapp->map[i].addr; 
   7.511 -        boot_paramsp->e820_map[i].size = mem_mapp->map[i].size; 
   7.512 -        boot_paramsp->e820_map[i].type = mem_mapp->map[i].type; 
   7.513 -        if (mem_mapp->map[i].type == E820_SHARED)
   7.514 -            shared_page_frame = (mem_mapp->map[i].addr >> PAGE_SHIFT);
   7.515 -    }
   7.516 -    munmap(boot_paramsp, PAGE_SIZE); 
   7.517 -
   7.518 -    if ((boot_gdtp = xc_map_foreign_range(
   7.519 -        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   7.520 -        page_array[(vboot_gdt_start-dsi.v_start)>>PAGE_SHIFT])) == 0)
   7.521          goto error_out;
   7.522 -    memset(boot_gdtp, 0, PAGE_SIZE);
   7.523 -    boot_gdtp[12*4 + 0] = boot_gdtp[13*4 + 0] = 0xffff; /* limit */
   7.524 -    boot_gdtp[12*4 + 1] = boot_gdtp[13*4 + 1] = 0x0000; /* base */
   7.525 -    boot_gdtp[12*4 + 2] = 0x9a00; boot_gdtp[13*4 + 2] = 0x9200; /* perms */
   7.526 -    boot_gdtp[12*4 + 3] = boot_gdtp[13*4 + 3] = 0x00cf; /* granu + top of limit */
   7.527 -    munmap(boot_gdtp, PAGE_SIZE);
   7.528 +    munmap(e820_page, PAGE_SIZE);
   7.529  
   7.530      /* shared_info page starts its life empty. */
   7.531      if ((shared_info = xc_map_foreign_range(
   7.532 @@ -651,20 +534,21 @@ static int setup_guest(int xc_handle,
   7.533      /*
   7.534       * Initial register values:
   7.535       */
   7.536 -    ctxt->user_regs.ds = 0x68;
   7.537 -    ctxt->user_regs.es = 0x0;
   7.538 -    ctxt->user_regs.fs = 0x0;
   7.539 -    ctxt->user_regs.gs = 0x0;
   7.540 -    ctxt->user_regs.ss = 0x68;
   7.541 -    ctxt->user_regs.cs = 0x60;
   7.542 +    ctxt->user_regs.ds = 0;
   7.543 +    ctxt->user_regs.es = 0;
   7.544 +    ctxt->user_regs.fs = 0;
   7.545 +    ctxt->user_regs.gs = 0;
   7.546 +    ctxt->user_regs.ss = 0;
   7.547 +    ctxt->user_regs.cs = 0;
   7.548      ctxt->user_regs.eip = dsi.v_kernentry;
   7.549 -    ctxt->user_regs.edx = vboot_gdt_start;
   7.550 -    ctxt->user_regs.eax = 0x800;
   7.551 -    ctxt->user_regs.esp = vboot_gdt_end;
   7.552 +    ctxt->user_regs.edx = 0;
   7.553 +    ctxt->user_regs.eax = 0;
   7.554 +    ctxt->user_regs.esp = 0;
   7.555      ctxt->user_regs.ebx = 0; /* startup_32 expects this to be 0 to signal boot cpu */
   7.556 -    ctxt->user_regs.ecx = mem_mapp->nr_map;
   7.557 -    ctxt->user_regs.esi = vboot_params_start;
   7.558 -    ctxt->user_regs.edi = vboot_params_start + 0x2d0;
   7.559 +    ctxt->user_regs.ecx = 0;
   7.560 +    ctxt->user_regs.esi = 0;
   7.561 +    ctxt->user_regs.edi = 0;
   7.562 +    ctxt->user_regs.ebp = 0;
   7.563  
   7.564      ctxt->user_regs.eflags = 0;
   7.565  
   7.566 @@ -684,9 +568,9 @@ static int vmx_identify(void)
   7.567      int eax, ecx;
   7.568  
   7.569  #ifdef __i386__
   7.570 -    __asm__ __volatile__ ("pushl %%ebx; cpuid; popl %%ebx" 
   7.571 -                          : "=a" (eax), "=c" (ecx) 
   7.572 -                          : "0" (1) 
   7.573 +    __asm__ __volatile__ ("pushl %%ebx; cpuid; popl %%ebx"
   7.574 +                          : "=a" (eax), "=c" (ecx)
   7.575 +                          : "0" (1)
   7.576                            : "dx");
   7.577  #elif defined __x86_64__
   7.578      __asm__ __volatile__ ("pushq %%rbx; cpuid; popq %%rbx"
   7.579 @@ -705,9 +589,6 @@ int xc_vmx_build(int xc_handle,
   7.580                   u32 domid,
   7.581                   int memsize,
   7.582                   const char *image_name,
   7.583 -                 struct mem_map *mem_mapp,
   7.584 -                 const char *ramdisk_name,
   7.585 -                 const char *cmdline,
   7.586                   unsigned int control_evtchn,
   7.587                   unsigned long flags,
   7.588                   unsigned int vcpus,
   7.589 @@ -715,20 +596,18 @@ int xc_vmx_build(int xc_handle,
   7.590                   unsigned long *store_mfn)
   7.591  {
   7.592      dom0_op_t launch_op, op;
   7.593 -    int initrd_fd = -1;
   7.594 -    gzFile initrd_gfd = NULL;
   7.595      int rc, i;
   7.596      vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
   7.597      unsigned long nr_pages;
   7.598      char         *image = NULL;
   7.599 -    unsigned long image_size, initrd_size=0;
   7.600 +    unsigned long image_size;
   7.601  
   7.602      if ( vmx_identify() < 0 )
   7.603      {
   7.604          PERROR("CPU doesn't support VMX Extensions");
   7.605          goto error_out;
   7.606      }
   7.607 -    
   7.608 +
   7.609      if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 )
   7.610      {
   7.611          PERROR("Could not find total pages for domain");
   7.612 @@ -738,32 +617,15 @@ int xc_vmx_build(int xc_handle,
   7.613      if ( (image = xc_read_kernel_image(image_name, &image_size)) == NULL )
   7.614          goto error_out;
   7.615  
   7.616 -    if ( (ramdisk_name != NULL) && (strlen(ramdisk_name) != 0) )
   7.617 +    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
   7.618      {
   7.619 -        if ( (initrd_fd = open(ramdisk_name, O_RDONLY)) < 0 )
   7.620 -        {
   7.621 -            PERROR("Could not open the initial ramdisk image");
   7.622 -            goto error_out;
   7.623 -        }
   7.624 -
   7.625 -        initrd_size = xc_get_filesz(initrd_fd);
   7.626 -
   7.627 -        if ( (initrd_gfd = gzdopen(initrd_fd, "rb")) == NULL )
   7.628 -        {
   7.629 -            PERROR("Could not allocate decompression state for initrd");
   7.630 -            goto error_out;
   7.631 -        }
   7.632 -    }
   7.633 -
   7.634 -    if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
   7.635 -    {   
   7.636          PERROR("xc_vmx_build: ctxt mlock failed");
   7.637          return 1;
   7.638      }
   7.639  
   7.640      op.cmd = DOM0_GETDOMAININFO;
   7.641      op.u.getdomaininfo.domain = (domid_t)domid;
   7.642 -    if ( (xc_dom0_op(xc_handle, &op) < 0) || 
   7.643 +    if ( (xc_dom0_op(xc_handle, &op) < 0) ||
   7.644           ((u16)op.u.getdomaininfo.domain != domid) )
   7.645      {
   7.646          PERROR("Could not get info on domain");
   7.647 @@ -783,21 +645,14 @@ int xc_vmx_build(int xc_handle,
   7.648          goto error_out;
   7.649      }
   7.650  
   7.651 -    if ( setup_guest(xc_handle, domid, memsize, image, image_size, 
   7.652 -                     initrd_gfd, initrd_size, nr_pages, 
   7.653 -                     ctxt, cmdline,
   7.654 -                     op.u.getdomaininfo.shared_info_frame,
   7.655 -                     control_evtchn, flags, vcpus, store_evtchn, store_mfn,
   7.656 -                     mem_mapp) < 0 )
   7.657 +    if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages,
   7.658 +                     ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn,
   7.659 +                     flags, vcpus, store_evtchn, store_mfn) < 0)
   7.660      {
   7.661          ERROR("Error constructing guest OS");
   7.662          goto error_out;
   7.663      }
   7.664  
   7.665 -    if ( initrd_fd >= 0 )
   7.666 -        close(initrd_fd);
   7.667 -    if ( initrd_gfd )
   7.668 -        gzclose(initrd_gfd);
   7.669      free(image);
   7.670  
   7.671      ctxt->flags = VGCF_VMX_GUEST;
   7.672 @@ -813,15 +668,10 @@ int xc_vmx_build(int xc_handle,
   7.673  
   7.674      /* No LDT. */
   7.675      ctxt->ldt_ents = 0;
   7.676 -    
   7.677 +
   7.678      /* Use the default Xen-provided GDT. */
   7.679      ctxt->gdt_ents = 0;
   7.680  
   7.681 -    /* Ring 1 stack is the initial stack. */
   7.682 -/*
   7.683 -  ctxt->kernel_ss = FLAT_KERNEL_DS;
   7.684 -  ctxt->kernel_sp = vstartinfo_start;
   7.685 -*/
   7.686      /* No debugging. */
   7.687      memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
   7.688  
   7.689 @@ -845,14 +695,10 @@ int xc_vmx_build(int xc_handle,
   7.690  
   7.691      launch_op.cmd = DOM0_SETDOMAININFO;
   7.692      rc = xc_dom0_op(xc_handle, &launch_op);
   7.693 -    
   7.694 +
   7.695      return rc;
   7.696  
   7.697   error_out:
   7.698 -    if ( initrd_gfd != NULL )
   7.699 -        gzclose(initrd_gfd);
   7.700 -    else if ( initrd_fd >= 0 )
   7.701 -        close(initrd_fd);
   7.702      free(image);
   7.703  
   7.704      return -1;
   7.705 @@ -864,7 +710,7 @@ static inline int is_loadable_phdr(Elf32
   7.706              ((phdr->p_flags & (PF_W|PF_X)) != 0));
   7.707  }
   7.708  
   7.709 -static int parseelfimage(char *elfbase, 
   7.710 +static int parseelfimage(char *elfbase,
   7.711                           unsigned long elfsize,
   7.712                           struct domain_setup_info *dsi)
   7.713  {
   7.714 @@ -899,11 +745,11 @@ static int parseelfimage(char *elfbase,
   7.715          ERROR("ELF image has no section-header strings table (shstrtab).");
   7.716          return -EINVAL;
   7.717      }
   7.718 -    shdr = (Elf32_Shdr *)(elfbase + ehdr->e_shoff + 
   7.719 +    shdr = (Elf32_Shdr *)(elfbase + ehdr->e_shoff +
   7.720                            (ehdr->e_shstrndx*ehdr->e_shentsize));
   7.721      shstrtab = elfbase + shdr->sh_offset;
   7.722 -    
   7.723 -    for ( h = 0; h < ehdr->e_phnum; h++ ) 
   7.724 +
   7.725 +    for ( h = 0; h < ehdr->e_phnum; h++ )
   7.726      {
   7.727          phdr = (Elf32_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
   7.728          if ( !is_loadable_phdr(phdr) )
   7.729 @@ -914,8 +760,8 @@ static int parseelfimage(char *elfbase,
   7.730              kernend = phdr->p_paddr + phdr->p_memsz;
   7.731      }
   7.732  
   7.733 -    if ( (kernstart > kernend) || 
   7.734 -         (ehdr->e_entry < kernstart) || 
   7.735 +    if ( (kernstart > kernend) ||
   7.736 +         (ehdr->e_entry < kernstart) ||
   7.737           (ehdr->e_entry > kernend) )
   7.738      {
   7.739          ERROR("Malformed ELF image.");
   7.740 @@ -924,9 +770,9 @@ static int parseelfimage(char *elfbase,
   7.741  
   7.742      dsi->v_start = 0x00000000;
   7.743  
   7.744 -    dsi->v_kernstart = kernstart - LINUX_PAGE_OFFSET;
   7.745 -    dsi->v_kernend   = kernend - LINUX_PAGE_OFFSET;
   7.746 -    dsi->v_kernentry = LINUX_KERNEL_ENTR_ADDR;
   7.747 +    dsi->v_kernstart = kernstart;
   7.748 +    dsi->v_kernend   = kernend;
   7.749 +    dsi->v_kernentry = VMX_LOADER_ENTR_ADDR;
   7.750  
   7.751      dsi->v_end       = dsi->v_kernend;
   7.752  
   7.753 @@ -945,18 +791,18 @@ loadelfimage(
   7.754      char         *va;
   7.755      unsigned long pa, done, chunksz;
   7.756  
   7.757 -    for ( h = 0; h < ehdr->e_phnum; h++ ) 
   7.758 +    for ( h = 0; h < ehdr->e_phnum; h++ )
   7.759      {
   7.760          phdr = (Elf32_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
   7.761          if ( !is_loadable_phdr(phdr) )
   7.762              continue;
   7.763 -        
   7.764 +
   7.765          for ( done = 0; done < phdr->p_filesz; done += chunksz )
   7.766          {
   7.767 -            pa = (phdr->p_paddr + done) - dsi->v_start - LINUX_PAGE_OFFSET;
   7.768 +            pa = (phdr->p_paddr + done) - dsi->v_start;
   7.769              if ((va = xc_map_foreign_range(
   7.770                  xch, dom, PAGE_SIZE, PROT_WRITE,
   7.771 -                parray[pa>>PAGE_SHIFT])) == 0)
   7.772 +                parray[pa >> PAGE_SHIFT])) == 0)
   7.773                  return -1;
   7.774              chunksz = phdr->p_filesz - done;
   7.775              if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
   7.776 @@ -968,10 +814,10 @@ loadelfimage(
   7.777  
   7.778          for ( ; done < phdr->p_memsz; done += chunksz )
   7.779          {
   7.780 -            pa = (phdr->p_paddr + done) - dsi->v_start - LINUX_PAGE_OFFSET;
   7.781 +            pa = (phdr->p_paddr + done) - dsi->v_start;
   7.782              if ((va = xc_map_foreign_range(
   7.783                  xch, dom, PAGE_SIZE, PROT_WRITE,
   7.784 -                parray[pa>>PAGE_SHIFT])) == 0)
   7.785 +                parray[pa >> PAGE_SHIFT])) == 0)
   7.786                  return -1;
   7.787              chunksz = phdr->p_memsz - done;
   7.788              if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) )
     8.1 --- a/tools/libxc/xenguest.h	Thu Sep 22 20:59:31 2005 +0100
     8.2 +++ b/tools/libxc/xenguest.h	Fri Sep 23 12:52:43 2005 +0100
     8.3 @@ -57,9 +57,6 @@ int xc_vmx_build(int xc_handle,
     8.4                   uint32_t domid,
     8.5                   int memsize,
     8.6                   const char *image_name,
     8.7 -                 struct mem_map *memmap,
     8.8 -                 const char *ramdisk_name,
     8.9 -                 const char *cmdline,
    8.10                   unsigned int control_evtchn,
    8.11                   unsigned long flags,
    8.12                   unsigned int vcpus,
     9.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu Sep 22 20:59:31 2005 +0100
     9.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Sep 23 12:52:43 2005 +0100
     9.3 @@ -17,7 +17,6 @@
     9.4  #include <arpa/inet.h>
     9.5  
     9.6  #include "xc_private.h"
     9.7 -#include "linux_boot_params.h"
     9.8  
     9.9  /* Needed for Python versions earlier than 2.3. */
    9.10  #ifndef PyMODINIT_FUNC
    9.11 @@ -310,80 +309,24 @@ static PyObject *pyxc_vmx_build(PyObject
    9.12      XcObject *xc = (XcObject *)self;
    9.13  
    9.14      u32   dom;
    9.15 -    char *image, *ramdisk = NULL, *cmdline = "";
    9.16 -    PyObject *memmap;
    9.17 +    char *image;
    9.18      int   control_evtchn, store_evtchn;
    9.19      int flags = 0, vcpus = 1;
    9.20 -    int numItems, i;
    9.21      int memsize;
    9.22 -    struct mem_map mem_map;
    9.23      unsigned long store_mfn = 0;
    9.24  
    9.25      static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
    9.26 -                                "memsize", "image", "memmap",
    9.27 -				"ramdisk", "cmdline", "flags",
    9.28 -				"vcpus", NULL };
    9.29 +                                "memsize", "image", "flags", "vcpus", NULL };
    9.30  
    9.31 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisO!|ssii", kwd_list, 
    9.32 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisii", kwd_list,
    9.33                                        &dom, &control_evtchn, &store_evtchn,
    9.34 -                                      &memsize,
    9.35 -                                      &image, &PyList_Type, &memmap,
    9.36 -				      &ramdisk, &cmdline, &flags, &vcpus) )
    9.37 +                                      &memsize, &image, &flags, &vcpus) )
    9.38          return NULL;
    9.39  
    9.40 -    memset(&mem_map, 0, sizeof(mem_map));
    9.41 -    /* Parse memmap */
    9.42 -
    9.43 -    /* get the number of lines passed to us */
    9.44 -    numItems = PyList_Size(memmap) - 1;	/* removing the line 
    9.45 -					   containing "memmap" */
    9.46 -    mem_map.nr_map = numItems;
    9.47 -   
    9.48 -    /* should raise an error here. */
    9.49 -    if (numItems < 0) return NULL; /* Not a list */
    9.50 -
    9.51 -    /* iterate over items of the list, grabbing ranges and parsing them */
    9.52 -    for (i = 1; i <= numItems; i++) {	// skip over "memmap"
    9.53 -	    PyObject *item, *f1, *f2, *f3, *f4;
    9.54 -	    int numFields;
    9.55 -	    unsigned long lf1, lf2, lf3, lf4;
    9.56 -	    char *sf1, *sf2;
    9.57 -	    
    9.58 -	    /* grab the string object from the next element of the list */
    9.59 -	    item = PyList_GetItem(memmap, i); /* Can't fail */
    9.60 -
    9.61 -	    /* get the number of lines passed to us */
    9.62 -	    numFields = PyList_Size(item);
    9.63 -
    9.64 -	    if (numFields != 4)
    9.65 -		    return NULL;
    9.66 +    if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, control_evtchn,
    9.67 +                      flags, vcpus, store_evtchn, &store_mfn) != 0 )
    9.68 +        return PyErr_SetFromErrno(xc_error);
    9.69  
    9.70 -	    f1 = PyList_GetItem(item, 0);
    9.71 -	    f2 = PyList_GetItem(item, 1);
    9.72 -	    f3 = PyList_GetItem(item, 2);
    9.73 -	    f4 = PyList_GetItem(item, 3);
    9.74 -
    9.75 -	    /* Convert objects to strings/longs */
    9.76 -	    sf1 = PyString_AsString(f1);
    9.77 -	    sf2 = PyString_AsString(f2);
    9.78 -	    lf3 = PyLong_AsLong(f3);
    9.79 -	    lf4 = PyLong_AsLong(f4);
    9.80 -	    if ( sscanf(sf1, "%lx", &lf1) != 1 )
    9.81 -                return NULL;
    9.82 -	    if ( sscanf(sf2, "%lx", &lf2) != 1 )
    9.83 -                return NULL;
    9.84 -
    9.85 -            mem_map.map[i-1].addr = lf1;
    9.86 -            mem_map.map[i-1].size = lf2 - lf1;
    9.87 -            mem_map.map[i-1].type = lf3;
    9.88 -            mem_map.map[i-1].caching_attr = lf4;
    9.89 -    }
    9.90 -
    9.91 -    if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, &mem_map,
    9.92 -                        ramdisk, cmdline, control_evtchn, flags,
    9.93 -                        vcpus, store_evtchn, &store_mfn) != 0 )
    9.94 -        return PyErr_SetFromErrno(xc_error);
    9.95 -    
    9.96      return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
    9.97  }
    9.98  
    10.1 --- a/tools/python/xen/util/memmap.py	Thu Sep 22 20:59:31 2005 +0100
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,41 +0,0 @@
    10.4 -mem_caching_attr = {
    10.5 -    'UC' : 0,
    10.6 -    'WC' : 1,
    10.7 -    'WT' : 4,
    10.8 -    'WP' : 5,
    10.9 -    'WB' : 6,
   10.10 -    };
   10.11 -
   10.12 -e820_mem_type = {
   10.13 -    'AddressRangeMemory'    : 1,
   10.14 -    'AddressRangeReserved'  : 2,
   10.15 -    'AddressRangeACPI'      : 3,
   10.16 -    'AddressRangeNVS'       : 4,
   10.17 -    'AddressRangeIO'        : 16,
   10.18 -    'AddressRangeShared'    : 17,
   10.19 -};
   10.20 -
   10.21 -MT_COL = 2
   10.22 -MA_COL = 3
   10.23 -
   10.24 -def strmap(row):
   10.25 -   if (type(row) != type([])):
   10.26 -       return row
   10.27 -   row[MT_COL] = e820_mem_type[row[MT_COL]]
   10.28 -   row[MA_COL] = mem_caching_attr[row[MA_COL]]
   10.29 -   return row
   10.30 -
   10.31 -def memmap_parse(memmap):
   10.32 -    return map(strmap, memmap)
   10.33 -
   10.34 -if __name__ == '__main__':
   10.35 -   memmap = [ 'memmap',
   10.36 -              [ '1', '2', 'AddressRangeMemory', 'UC'],
   10.37 -              [ '1', '2', 'AddressRangeReserved', 'UC'],
   10.38 -              [ '1', '2', 'AddressRangeACPI', 'WB'],
   10.39 -              [ '1', '2', 'AddressRangeNVS', 'WB'],
   10.40 -              [ '1', '2', 'AddressRangeIO', 'WB'],
   10.41 -              [ '1', '2', 'AddressRangeShared', 'WB']]
   10.42 -   print memmap_parse(memmap);
   10.43 -
   10.44 -
    11.1 --- a/tools/python/xen/xend/image.py	Thu Sep 22 20:59:31 2005 +0100
    11.2 +++ b/tools/python/xen/xend/image.py	Fri Sep 23 12:52:43 2005 +0100
    11.3 @@ -238,22 +238,19 @@ class VmxImageHandler(ImageHandler):
    11.4  
    11.5      def configure(self, imageConfig, deviceConfig):
    11.6          ImageHandler.configure(self, imageConfig, deviceConfig)
    11.7 -        
    11.8 -        self.memmap = sxp.child_value(imageConfig, 'memmap')
    11.9 +
   11.10          self.dmargs = self.parseDeviceModelArgs(imageConfig, deviceConfig)
   11.11          self.device_model = sxp.child_value(imageConfig, 'device_model')
   11.12          if not self.device_model:
   11.13              raise VmError("vmx: missing device model")
   11.14          self.display = sxp.child_value(imageConfig, 'display')
   11.15  
   11.16 -        self.vm.storeVm(("image/memmap", self.memmap),
   11.17 -                        ("image/dmargs", " ".join(self.dmargs)),
   11.18 +        self.vm.storeVm(("image/dmargs", " ".join(self.dmargs)),
   11.19                          ("image/device-model", self.device_model),
   11.20                          ("image/display", self.display))
   11.21  
   11.22          self.device_channel = None
   11.23          self.pid = 0
   11.24 -        self.memmap_value = []
   11.25  
   11.26          self.dmargs += self.configVNC(imageConfig)
   11.27  
   11.28 @@ -261,7 +258,6 @@ class VmxImageHandler(ImageHandler):
   11.29      def createImage(self):
   11.30          """Create a VM for the VMX environment.
   11.31          """
   11.32 -        self.parseMemmap()
   11.33          self.createDomain()
   11.34  
   11.35      def buildDomain(self):
   11.36 @@ -278,9 +274,6 @@ class VmxImageHandler(ImageHandler):
   11.37          log.debug("control_evtchn = %d", self.device_channel.port2)
   11.38          log.debug("store_evtchn   = %d", store_evtchn)
   11.39          log.debug("memsize        = %d", self.vm.getMemoryTarget() / 1024)
   11.40 -        log.debug("memmap         = %s", self.memmap_value)
   11.41 -        log.debug("cmdline        = %s", self.cmdline)
   11.42 -        log.debug("ramdisk        = %s", self.ramdisk)
   11.43          log.debug("flags          = %d", self.flags)
   11.44          log.debug("vcpus          = %d", self.vm.getVCpuCount())
   11.45  
   11.46 @@ -289,9 +282,6 @@ class VmxImageHandler(ImageHandler):
   11.47                             control_evtchn = self.device_channel.port2,
   11.48                             store_evtchn   = store_evtchn,
   11.49                             memsize        = self.vm.getMemoryTarget() / 1024,
   11.50 -                           memmap         = self.memmap_value,
   11.51 -                           cmdline        = self.cmdline,
   11.52 -                           ramdisk        = self.ramdisk,
   11.53                             flags          = self.flags,
   11.54                             vcpus          = self.vm.getVCpuCount())
   11.55          if isinstance(ret, dict):
   11.56 @@ -299,18 +289,11 @@ class VmxImageHandler(ImageHandler):
   11.57              return 0
   11.58          return ret
   11.59  
   11.60 -    def parseMemmap(self):
   11.61 -        if self.memmap is None:
   11.62 -            return
   11.63 -        memmap = sxp.parse(open(self.memmap))[0]
   11.64 -        from xen.util.memmap import memmap_parse
   11.65 -        self.memmap_value = memmap_parse(memmap)
   11.66 -        
   11.67      # Return a list of cmd line args to the device models based on the
   11.68      # xm config file
   11.69      def parseDeviceModelArgs(self, imageConfig, deviceConfig):
   11.70          dmargs = [ 'cdrom', 'boot', 'fda', 'fdb',
   11.71 -                   'localtime', 'serial', 'stdvga', 'isa', 'vcpus' ] 
   11.72 +                   'localtime', 'serial', 'stdvga', 'isa', 'vcpus' ]
   11.73          ret = []
   11.74          for a in dmargs:
   11.75              v = sxp.child_value(imageConfig, a)
    12.1 --- a/xen/arch/x86/vmx_vmcs.c	Thu Sep 22 20:59:31 2005 +0100
    12.2 +++ b/xen/arch/x86/vmx_vmcs.c	Fri Sep 23 12:52:43 2005 +0100
    12.3 @@ -37,19 +37,19 @@
    12.4  #endif
    12.5  #ifdef CONFIG_VMX
    12.6  
    12.7 -struct vmcs_struct *alloc_vmcs(void) 
    12.8 +struct vmcs_struct *alloc_vmcs(void)
    12.9  {
   12.10      struct vmcs_struct *vmcs;
   12.11      u32 vmx_msr_low, vmx_msr_high;
   12.12  
   12.13      rdmsr(MSR_IA32_VMX_BASIC_MSR, vmx_msr_low, vmx_msr_high);
   12.14      vmcs_size = vmx_msr_high & 0x1fff;
   12.15 -    vmcs = alloc_xenheap_pages(get_order_from_bytes(vmcs_size)); 
   12.16 +    vmcs = alloc_xenheap_pages(get_order_from_bytes(vmcs_size));
   12.17      memset((char *)vmcs, 0, vmcs_size); /* don't remove this */
   12.18  
   12.19      vmcs->vmcs_revision_id = vmx_msr_low;
   12.20      return vmcs;
   12.21 -} 
   12.22 +}
   12.23  
   12.24  void free_vmcs(struct vmcs_struct *vmcs)
   12.25  {
   12.26 @@ -65,7 +65,7 @@ static inline int construct_vmcs_control
   12.27      void *io_bitmap_a;
   12.28      void *io_bitmap_b;
   12.29  
   12.30 -    error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL, 
   12.31 +    error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL,
   12.32                         MONITOR_PIN_BASED_EXEC_CONTROLS);
   12.33  
   12.34      error |= __vmwrite(VM_EXIT_CONTROLS, MONITOR_VM_EXIT_CONTROLS);
   12.35 @@ -73,8 +73,8 @@ static inline int construct_vmcs_control
   12.36      error |= __vmwrite(VM_ENTRY_CONTROLS, MONITOR_VM_ENTRY_CONTROLS);
   12.37  
   12.38      /* need to use 0x1000 instead of PAGE_SIZE */
   12.39 -    io_bitmap_a = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000)); 
   12.40 -    io_bitmap_b = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000)); 
   12.41 +    io_bitmap_a = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000));
   12.42 +    io_bitmap_b = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000));
   12.43      memset(io_bitmap_a, 0xff, 0x1000);
   12.44      /* don't bother debug port access */
   12.45      clear_bit(PC_DEBUG_PORT, io_bitmap_a);
   12.46 @@ -89,8 +89,10 @@ static inline int construct_vmcs_control
   12.47      return error;
   12.48  }
   12.49  
   12.50 -#define GUEST_SEGMENT_LIMIT     0xffffffff      
   12.51 -#define HOST_SEGMENT_LIMIT      0xffffffff      
   12.52 +#define GUEST_LAUNCH_DS         0x08
   12.53 +#define GUEST_LAUNCH_CS         0x10
   12.54 +#define GUEST_SEGMENT_LIMIT     0xffffffff
   12.55 +#define HOST_SEGMENT_LIMIT      0xffffffff
   12.56  
   12.57  struct host_execution_env {
   12.58      /* selectors */
   12.59 @@ -110,72 +112,80 @@ struct host_execution_env {
   12.60      unsigned long tr_base;
   12.61      unsigned long ds_base;
   12.62      unsigned long cs_base;
   12.63 -#ifdef __x86_64__ 
   12.64 -    unsigned long fs_base; 
   12.65 -    unsigned long gs_base; 
   12.66 -#endif 
   12.67 +#ifdef __x86_64__
   12.68 +    unsigned long fs_base;
   12.69 +    unsigned long gs_base;
   12.70 +#endif
   12.71  };
   12.72  
   12.73 -#define round_pgdown(_p) ((_p)&PAGE_MASK) /* coped from domain.c */
   12.74 -
   12.75 -int vmx_setup_platform(struct vcpu *d, struct cpu_user_regs *regs)
   12.76 +static void vmx_setup_platform(struct vcpu *v, struct cpu_user_regs *regs)
   12.77  {
   12.78      int i;
   12.79 -    unsigned int n;
   12.80 -    unsigned long *p, mpfn, offset, addr;
   12.81 -    struct e820entry *e820p;
   12.82 +    unsigned char e820_map_nr;
   12.83 +    struct e820entry *e820entry;
   12.84 +    unsigned char *p;
   12.85 +    unsigned long mpfn;
   12.86      unsigned long gpfn = 0;
   12.87  
   12.88      local_flush_tlb_pge();
   12.89 -    regs->ebx = 0;   /* Linux expects ebx to be 0 for boot proc */
   12.90  
   12.91 -    n = regs->ecx;
   12.92 -    if (n > 32) {
   12.93 -        VMX_DBG_LOG(DBG_LEVEL_1, "Too many e820 entries: %d", n);
   12.94 -        return -1;
   12.95 +    mpfn = get_mfn_from_pfn(E820_MAP_PAGE >> PAGE_SHIFT);
   12.96 +    if (mpfn == INVALID_MFN) {
   12.97 +        printk("Can not find E820 memory map page for VMX domain.\n");
   12.98 +        domain_crash();
   12.99 +    }
  12.100 +
  12.101 +    p = map_domain_page(mpfn);
  12.102 +    if (p == NULL) {
  12.103 +        printk("Can not map E820 memory map page for VMX domain.\n");
  12.104 +        domain_crash();
  12.105      }
  12.106  
  12.107 -    addr = regs->edi;
  12.108 -    offset = (addr & ~PAGE_MASK);
  12.109 -    addr = round_pgdown(addr);
  12.110 -
  12.111 -    mpfn = get_mfn_from_pfn(addr >> PAGE_SHIFT);
  12.112 -    p = map_domain_page(mpfn);
  12.113 -
  12.114 -    e820p = (struct e820entry *) ((unsigned long) p + offset); 
  12.115 +    e820_map_nr = *(p + E820_MAP_NR_OFFSET);
  12.116 +    e820entry = (struct e820entry *)(p + E820_MAP_OFFSET);
  12.117  
  12.118  #ifndef NDEBUG
  12.119 -    print_e820_memory_map(e820p, n);
  12.120 +    print_e820_memory_map(e820entry, n);
  12.121  #endif
  12.122  
  12.123 -    for ( i = 0; i < n; i++ )
  12.124 +    for ( i = 0; i < e820_map_nr; i++ )
  12.125      {
  12.126 -        if ( e820p[i].type == E820_SHARED_PAGE )
  12.127 +        if (e820entry[i].type == E820_SHARED_PAGE)
  12.128          {
  12.129 -            gpfn = (e820p[i].addr >> PAGE_SHIFT);
  12.130 +            gpfn = (e820entry[i].addr >> PAGE_SHIFT);
  12.131              break;
  12.132          }
  12.133      }
  12.134  
  12.135 -    if ( gpfn == 0 )
  12.136 -    {
  12.137 -        unmap_domain_page(p);        
  12.138 -        return -1;
  12.139 -    }   
  12.140 +    if ( gpfn == 0 ) {
  12.141 +        printk("Can not get io request shared page"
  12.142 +               " from E820 memory map for VMX domain.\n");
  12.143 +        unmap_domain_page(p);
  12.144 +        domain_crash();
  12.145 +    }
  12.146 +    unmap_domain_page(p);
  12.147  
  12.148 -    unmap_domain_page(p);        
  12.149 +    if (v->vcpu_id)
  12.150 +        return;
  12.151  
  12.152      /* Initialise shared page */
  12.153      mpfn = get_mfn_from_pfn(gpfn);
  12.154 -    p = map_domain_page(mpfn);
  12.155 -    d->domain->arch.vmx_platform.shared_page_va = (unsigned long)p;
  12.156 -
  12.157 -    VMX_DBG_LOG(DBG_LEVEL_1, "eport: %x\n", iopacket_port(d->domain));
  12.158 +    if (mpfn == INVALID_MFN) {
  12.159 +        printk("Can not find io request shared page for VMX domain.\n");
  12.160 +        domain_crash();
  12.161 +    }
  12.162  
  12.163 -    clear_bit(iopacket_port(d->domain), 
  12.164 -              &d->domain->shared_info->evtchn_mask[0]);
  12.165 +    p = map_domain_page(mpfn);
  12.166 +    if (p == NULL) {
  12.167 +        printk("Can not map io request shared page for VMX domain.\n");
  12.168 +        domain_crash();
  12.169 +    }
  12.170 +    v->domain->arch.vmx_platform.shared_page_va = (unsigned long)p;
  12.171  
  12.172 -    return 0;
  12.173 +    VMX_DBG_LOG(DBG_LEVEL_1, "eport: %x\n", iopacket_port(v->domain));
  12.174 +
  12.175 +    clear_bit(iopacket_port(v->domain),
  12.176 +              &v->domain->shared_info->evtchn_mask[0]);
  12.177  }
  12.178  
  12.179  void vmx_set_host_env(struct vcpu *v)
  12.180 @@ -203,7 +213,7 @@ void vmx_set_host_env(struct vcpu *v)
  12.181      error |= __vmwrite(HOST_TR_BASE, host_env.tr_base);
  12.182  }
  12.183  
  12.184 -void vmx_do_launch(struct vcpu *v) 
  12.185 +void vmx_do_launch(struct vcpu *v)
  12.186  {
  12.187  /* Update CR3, GDT, LDT, TR */
  12.188      unsigned int  error = 0;
  12.189 @@ -217,7 +227,7 @@ void vmx_do_launch(struct vcpu *v)
  12.190      error |= __vmwrite(GUEST_CR0, cr0);
  12.191      cr0 &= ~X86_CR0_PG;
  12.192      error |= __vmwrite(CR0_READ_SHADOW, cr0);
  12.193 -    error |= __vmwrite(CPU_BASED_VM_EXEC_CONTROL, 
  12.194 +    error |= __vmwrite(CPU_BASED_VM_EXEC_CONTROL,
  12.195                         MONITOR_CPU_BASED_EXEC_CONTROLS);
  12.196  
  12.197      __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (cr4) : );
  12.198 @@ -247,7 +257,7 @@ void vmx_do_launch(struct vcpu *v)
  12.199      error |= __vmwrite(GUEST_LDTR_SELECTOR, 0);
  12.200      error |= __vmwrite(GUEST_LDTR_BASE, 0);
  12.201      error |= __vmwrite(GUEST_LDTR_LIMIT, 0);
  12.202 -        
  12.203 +
  12.204      error |= __vmwrite(GUEST_TR_BASE, 0);
  12.205      error |= __vmwrite(GUEST_TR_LIMIT, 0xff);
  12.206  
  12.207 @@ -261,10 +271,8 @@ void vmx_do_launch(struct vcpu *v)
  12.208  /*
  12.209   * Initially set the same environement as host.
  12.210   */
  12.211 -static inline int 
  12.212 -construct_init_vmcs_guest(struct cpu_user_regs *regs, 
  12.213 -                          struct vcpu_guest_context *ctxt,
  12.214 -                          struct host_execution_env *host_env)
  12.215 +static inline int
  12.216 +construct_init_vmcs_guest(struct cpu_user_regs *regs)
  12.217  {
  12.218      int error = 0;
  12.219      union vmcs_arbytes arbytes;
  12.220 @@ -292,31 +300,37 @@ construct_init_vmcs_guest(struct cpu_use
  12.221      error |= __vmwrite(CR3_TARGET_COUNT, 0);
  12.222  
  12.223      /* Guest Selectors */
  12.224 -    error |= __vmwrite(GUEST_CS_SELECTOR, regs->cs);
  12.225 -    error |= __vmwrite(GUEST_ES_SELECTOR, regs->es);
  12.226 -    error |= __vmwrite(GUEST_SS_SELECTOR, regs->ss);
  12.227 -    error |= __vmwrite(GUEST_DS_SELECTOR, regs->ds);
  12.228 -    error |= __vmwrite(GUEST_FS_SELECTOR, regs->fs);
  12.229 -    error |= __vmwrite(GUEST_GS_SELECTOR, regs->gs);
  12.230 +    error |= __vmwrite(GUEST_ES_SELECTOR, GUEST_LAUNCH_DS);
  12.231 +    error |= __vmwrite(GUEST_SS_SELECTOR, GUEST_LAUNCH_DS);
  12.232 +    error |= __vmwrite(GUEST_DS_SELECTOR, GUEST_LAUNCH_DS);
  12.233 +    error |= __vmwrite(GUEST_FS_SELECTOR, GUEST_LAUNCH_DS);
  12.234 +    error |= __vmwrite(GUEST_GS_SELECTOR, GUEST_LAUNCH_DS);
  12.235 +    error |= __vmwrite(GUEST_CS_SELECTOR, GUEST_LAUNCH_CS);
  12.236 +
  12.237 +    /* Guest segment bases */
  12.238 +    error |= __vmwrite(GUEST_ES_BASE, 0);
  12.239 +    error |= __vmwrite(GUEST_SS_BASE, 0);
  12.240 +    error |= __vmwrite(GUEST_DS_BASE, 0);
  12.241 +    error |= __vmwrite(GUEST_FS_BASE, 0);
  12.242 +    error |= __vmwrite(GUEST_GS_BASE, 0);
  12.243 +    error |= __vmwrite(GUEST_CS_BASE, 0);
  12.244  
  12.245      /* Guest segment Limits */
  12.246 -    error |= __vmwrite(GUEST_CS_LIMIT, GUEST_SEGMENT_LIMIT);
  12.247      error |= __vmwrite(GUEST_ES_LIMIT, GUEST_SEGMENT_LIMIT);
  12.248      error |= __vmwrite(GUEST_SS_LIMIT, GUEST_SEGMENT_LIMIT);
  12.249      error |= __vmwrite(GUEST_DS_LIMIT, GUEST_SEGMENT_LIMIT);
  12.250      error |= __vmwrite(GUEST_FS_LIMIT, GUEST_SEGMENT_LIMIT);
  12.251      error |= __vmwrite(GUEST_GS_LIMIT, GUEST_SEGMENT_LIMIT);
  12.252 +    error |= __vmwrite(GUEST_CS_LIMIT, GUEST_SEGMENT_LIMIT);
  12.253  
  12.254 -    error |= __vmwrite(GUEST_IDTR_LIMIT, host_env->idtr_limit);
  12.255 -
  12.256 -    /* AR bytes */
  12.257 +    /* Guest segment AR bytes */
  12.258      arbytes.bytes = 0;
  12.259      arbytes.fields.seg_type = 0x3;          /* type = 3 */
  12.260      arbytes.fields.s = 1;                   /* code or data, i.e. not system */
  12.261      arbytes.fields.dpl = 0;                 /* DPL = 3 */
  12.262      arbytes.fields.p = 1;                   /* segment present */
  12.263      arbytes.fields.default_ops_size = 1;    /* 32-bit */
  12.264 -    arbytes.fields.g = 1;   
  12.265 +    arbytes.fields.g = 1;
  12.266      arbytes.fields.null_bit = 0;            /* not null */
  12.267  
  12.268      error |= __vmwrite(GUEST_ES_AR_BYTES, arbytes.bytes);
  12.269 @@ -328,35 +342,31 @@ construct_init_vmcs_guest(struct cpu_use
  12.270      arbytes.fields.seg_type = 0xb;          /* type = 0xb */
  12.271      error |= __vmwrite(GUEST_CS_AR_BYTES, arbytes.bytes);
  12.272  
  12.273 -    error |= __vmwrite(GUEST_GDTR_BASE, regs->edx);
  12.274 -    regs->edx = 0;
  12.275 -    error |= __vmwrite(GUEST_GDTR_LIMIT, regs->eax);
  12.276 -    regs->eax = 0;
  12.277 +    /* Guest GDT */
  12.278 +    error |= __vmwrite(GUEST_GDTR_BASE, 0);
  12.279 +    error |= __vmwrite(GUEST_GDTR_LIMIT, 0);
  12.280  
  12.281 +    /* Guest IDT */
  12.282 +    error |= __vmwrite(GUEST_IDTR_BASE, 0);
  12.283 +    error |= __vmwrite(GUEST_IDTR_LIMIT, 0);
  12.284 +
  12.285 +    /* Guest LDT & TSS */
  12.286      arbytes.fields.s = 0;                   /* not code or data segement */
  12.287      arbytes.fields.seg_type = 0x2;          /* LTD */
  12.288      arbytes.fields.default_ops_size = 0;    /* 16-bit */
  12.289 -    arbytes.fields.g = 0;   
  12.290 +    arbytes.fields.g = 0;
  12.291      error |= __vmwrite(GUEST_LDTR_AR_BYTES, arbytes.bytes);
  12.292  
  12.293      arbytes.fields.seg_type = 0xb;          /* 32-bit TSS (busy) */
  12.294      error |= __vmwrite(GUEST_TR_AR_BYTES, arbytes.bytes);
  12.295      /* CR3 is set in vmx_final_setup_guest */
  12.296  
  12.297 -    error |= __vmwrite(GUEST_ES_BASE, host_env->ds_base);
  12.298 -    error |= __vmwrite(GUEST_CS_BASE, host_env->cs_base);
  12.299 -    error |= __vmwrite(GUEST_SS_BASE, host_env->ds_base);
  12.300 -    error |= __vmwrite(GUEST_DS_BASE, host_env->ds_base);
  12.301 -    error |= __vmwrite(GUEST_FS_BASE, host_env->ds_base);
  12.302 -    error |= __vmwrite(GUEST_GS_BASE, host_env->ds_base);
  12.303 -    error |= __vmwrite(GUEST_IDTR_BASE, host_env->idtr_base);
  12.304 -
  12.305 -    error |= __vmwrite(GUEST_RSP, regs->esp);
  12.306 +    error |= __vmwrite(GUEST_RSP, 0);
  12.307      error |= __vmwrite(GUEST_RIP, regs->eip);
  12.308  
  12.309 +    /* Guest EFLAGS */
  12.310      eflags = regs->eflags & ~VMCS_EFLAGS_RESERVED_0; /* clear 0s */
  12.311      eflags |= VMCS_EFLAGS_RESERVED_1; /* set 1s */
  12.312 -
  12.313      error |= __vmwrite(GUEST_RFLAGS, eflags);
  12.314  
  12.315      error |= __vmwrite(GUEST_INTERRUPTIBILITY_INFO, 0);
  12.316 @@ -381,14 +391,14 @@ static inline int construct_vmcs_host(st
  12.317  #if defined (__i386__)
  12.318      error |= __vmwrite(HOST_FS_SELECTOR, host_env->ds_selector);
  12.319      error |= __vmwrite(HOST_GS_SELECTOR, host_env->ds_selector);
  12.320 -    error |= __vmwrite(HOST_FS_BASE, host_env->ds_base); 
  12.321 -    error |= __vmwrite(HOST_GS_BASE, host_env->ds_base); 
  12.322 +    error |= __vmwrite(HOST_FS_BASE, host_env->ds_base);
  12.323 +    error |= __vmwrite(HOST_GS_BASE, host_env->ds_base);
  12.324  
  12.325  #else
  12.326 -    rdmsrl(MSR_FS_BASE, host_env->fs_base); 
  12.327 -    rdmsrl(MSR_GS_BASE, host_env->gs_base); 
  12.328 -    error |= __vmwrite(HOST_FS_BASE, host_env->fs_base); 
  12.329 -    error |= __vmwrite(HOST_GS_BASE, host_env->gs_base); 
  12.330 +    rdmsrl(MSR_FS_BASE, host_env->fs_base);
  12.331 +    rdmsrl(MSR_GS_BASE, host_env->gs_base);
  12.332 +    error |= __vmwrite(HOST_FS_BASE, host_env->fs_base);
  12.333 +    error |= __vmwrite(HOST_GS_BASE, host_env->gs_base);
  12.334  
  12.335  #endif
  12.336      host_env->cs_selector = __HYPERVISOR_CS;
  12.337 @@ -401,16 +411,16 @@ static inline int construct_vmcs_host(st
  12.338      error |= __vmwrite(HOST_CR0, crn); /* same CR0 */
  12.339  
  12.340      /* CR3 is set in vmx_final_setup_hostos */
  12.341 -    __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (crn) : ); 
  12.342 +    __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (crn) : );
  12.343      error |= __vmwrite(HOST_CR4, crn);
  12.344  
  12.345      error |= __vmwrite(HOST_RIP, (unsigned long) vmx_asm_vmexit_handler);
  12.346 -#ifdef __x86_64__ 
  12.347 -    /* TBD: support cr8 for 64-bit guest */ 
  12.348 -    __vmwrite(VIRTUAL_APIC_PAGE_ADDR, 0); 
  12.349 -    __vmwrite(TPR_THRESHOLD, 0); 
  12.350 -    __vmwrite(SECONDARY_VM_EXEC_CONTROL, 0); 
  12.351 -#endif 
  12.352 +#ifdef __x86_64__
  12.353 +    /* TBD: support cr8 for 64-bit guest */
  12.354 +    __vmwrite(VIRTUAL_APIC_PAGE_ADDR, 0);
  12.355 +    __vmwrite(TPR_THRESHOLD, 0);
  12.356 +    __vmwrite(SECONDARY_VM_EXEC_CONTROL, 0);
  12.357 +#endif
  12.358  
  12.359      return error;
  12.360  }
  12.361 @@ -440,37 +450,37 @@ int construct_vmcs(struct arch_vmx_struc
  12.362  
  12.363      if ((error = __vmpclear (vmcs_phys_ptr))) {
  12.364          printk("construct_vmcs: VMCLEAR failed\n");
  12.365 -        return -EINVAL;         
  12.366 +        return -EINVAL;
  12.367      }
  12.368      if ((error = load_vmcs(arch_vmx, vmcs_phys_ptr))) {
  12.369          printk("construct_vmcs: load_vmcs failed: VMCS = %lx\n",
  12.370                 (unsigned long) vmcs_phys_ptr);
  12.371 -        return -EINVAL; 
  12.372 +        return -EINVAL;
  12.373      }
  12.374      if ((error = construct_vmcs_controls(arch_vmx))) {
  12.375          printk("construct_vmcs: construct_vmcs_controls failed\n");
  12.376 -        return -EINVAL;         
  12.377 +        return -EINVAL;
  12.378      }
  12.379      /* host selectors */
  12.380      if ((error = construct_vmcs_host(&host_env))) {
  12.381          printk("construct_vmcs: construct_vmcs_host failed\n");
  12.382 -        return -EINVAL;         
  12.383 +        return -EINVAL;
  12.384      }
  12.385      /* guest selectors */
  12.386 -    if ((error = construct_init_vmcs_guest(regs, ctxt, &host_env))) {
  12.387 +    if ((error = construct_init_vmcs_guest(regs))) {
  12.388          printk("construct_vmcs: construct_vmcs_guest failed\n");
  12.389 -        return -EINVAL;         
  12.390 -    }       
  12.391 +        return -EINVAL;
  12.392 +    }
  12.393  
  12.394 -    if ((error |= __vmwrite(EXCEPTION_BITMAP, 
  12.395 +    if ((error |= __vmwrite(EXCEPTION_BITMAP,
  12.396                              MONITOR_DEFAULT_EXCEPTION_BITMAP))) {
  12.397          printk("construct_vmcs: setting Exception bitmap failed\n");
  12.398 -        return -EINVAL;         
  12.399 +        return -EINVAL;
  12.400      }
  12.401  
  12.402      if (regs->eflags & EF_TF)
  12.403          __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
  12.404 -    else 
  12.405 +    else
  12.406          __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
  12.407  
  12.408      return 0;
  12.409 @@ -491,7 +501,7 @@ int modify_vmcs(struct arch_vmx_struct *
  12.410      if ((error = load_vmcs(arch_vmx, vmcs_phys_ptr))) {
  12.411          printk("modify_vmcs: load_vmcs failed: VMCS = %lx\n",
  12.412                 (unsigned long) vmcs_phys_ptr);
  12.413 -        return -EINVAL; 
  12.414 +        return -EINVAL;
  12.415      }
  12.416      load_cpu_user_regs(regs);
  12.417  
  12.418 @@ -500,23 +510,23 @@ int modify_vmcs(struct arch_vmx_struct *
  12.419      return 0;
  12.420  }
  12.421  
  12.422 -int load_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr) 
  12.423 +int load_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr)
  12.424  {
  12.425      int error;
  12.426  
  12.427      if ((error = __vmptrld(phys_ptr))) {
  12.428 -        clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); 
  12.429 +        clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags);
  12.430          return error;
  12.431      }
  12.432 -    set_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); 
  12.433 +    set_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags);
  12.434      return 0;
  12.435  }
  12.436  
  12.437 -int store_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr) 
  12.438 +int store_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr)
  12.439  {
  12.440      /* take the current VMCS */
  12.441      __vmptrst(phys_ptr);
  12.442 -    clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); 
  12.443 +    clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags);
  12.444      return 0;
  12.445  }
  12.446  
  12.447 @@ -536,7 +546,7 @@ void vm_resume_fail(unsigned long eflags
  12.448      __vmx_bug(guest_cpu_user_regs());
  12.449  }
  12.450  
  12.451 -void arch_vmx_do_resume(struct vcpu *v) 
  12.452 +void arch_vmx_do_resume(struct vcpu *v)
  12.453  {
  12.454      u64 vmcs_phys_ptr = (u64) virt_to_phys(v->arch.arch_vmx.vmcs);
  12.455  
  12.456 @@ -545,7 +555,7 @@ void arch_vmx_do_resume(struct vcpu *v)
  12.457      reset_stack_and_jump(vmx_asm_do_resume);
  12.458  }
  12.459  
  12.460 -void arch_vmx_do_launch(struct vcpu *v) 
  12.461 +void arch_vmx_do_launch(struct vcpu *v)
  12.462  {
  12.463      u64 vmcs_phys_ptr = (u64) virt_to_phys(v->arch.arch_vmx.vmcs);
  12.464  
    13.1 --- a/xen/include/asm-x86/e820.h	Thu Sep 22 20:59:31 2005 +0100
    13.2 +++ b/xen/include/asm-x86/e820.h	Fri Sep 23 12:52:43 2005 +0100
    13.3 @@ -11,6 +11,11 @@
    13.4  #define E820_NVS          4
    13.5  #define E820_IO          16
    13.6  #define E820_SHARED_PAGE 17
    13.7 +#define E820_XENSTORE    18
    13.8 +
    13.9 +#define E820_MAP_PAGE        0x00090000
   13.10 +#define E820_MAP_NR_OFFSET   0x000001E8
   13.11 +#define E820_MAP_OFFSET      0x000002D0
   13.12  
   13.13  #ifndef __ASSEMBLY__
   13.14  struct e820entry {
    14.1 --- a/xen/include/asm-x86/vmx_platform.h	Thu Sep 22 20:59:31 2005 +0100
    14.2 +++ b/xen/include/asm-x86/vmx_platform.h	Fri Sep 23 12:52:43 2005 +0100
    14.3 @@ -93,7 +93,6 @@ struct virtual_platform_def {
    14.4  
    14.5  extern void handle_mmio(unsigned long, unsigned long);
    14.6  extern void vmx_wait_io(void);
    14.7 -extern int vmx_setup_platform(struct vcpu *, struct cpu_user_regs *);
    14.8  extern void vmx_io_assist(struct vcpu *v);
    14.9  
   14.10  // XXX - think about this -- maybe use bit 30 of the mfn to signify an MMIO frame.