[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] Clean up xc_vmx_build():
# HG changeset patch # User kaf24@xxxxxxxxxxxxxxxxxxxx # Node ID 94c6fc048d8ed548b552be415f23c68162f30ab0 # Parent 43edce5b75d62213991842e441f8f11a29081a02 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@xxxxxxxxx> diff -r 43edce5b75d6 -r 94c6fc048d8e tools/examples/Makefile --- a/tools/examples/Makefile Thu Sep 22 19:59:31 2005 +++ b/tools/examples/Makefile Fri Sep 23 11:52:43 2005 @@ -25,19 +25,13 @@ XEN_SCRIPTS += block-file XEN_SCRIPTS += block-enbd -# no 64-bit specifics in mem-map.sxp -# so place in /usr/lib, not /usr/lib64 -XEN_BOOT_DIR = /usr/lib/xen/boot -XEN_BOOT = mem-map.sxp - XEN_HOTPLUG_DIR = /etc/hotplug XEN_HOTPLUG_SCRIPTS = xen-backend.agent all: build: -install: all install-initd install-configs install-scripts install-boot \ - install-hotplug +install: all install-initd install-configs install-scripts install-hotplug install-initd: [ -d $(DESTDIR)/etc/init.d ] || $(INSTALL_DIR) $(DESTDIR)/etc/init.d @@ -62,14 +56,6 @@ $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \ done -install-boot: - [ -d $(DESTDIR)$(XEN_BOOT_DIR) ] || \ - $(INSTALL_DIR) $(DESTDIR)$(XEN_BOOT_DIR) - for i in $(XEN_BOOT); \ - do [ -a $(DESTDIR)$(XEN_BOOT_DIR)/$$i ] || \ - $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_BOOT_DIR); \ - done - install-hotplug: [ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \ $(INSTALL_DIR) $(DESTDIR)$(XEN_HOTPLUG_DIR) diff -r 43edce5b75d6 -r 94c6fc048d8e tools/examples/xmexample.vmx --- a/tools/examples/xmexample.vmx Thu Sep 22 19:59:31 2005 +++ b/tools/examples/xmexample.vmx Fri Sep 23 11:52:43 2005 @@ -60,9 +60,6 @@ # New stuff device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm' -# Advanced users only. Don't touch if you don't know what you're doing -memmap = '/usr/lib/xen/boot/mem-map.sxp' - #----------------------------------------------------------------------------- # Disk image for #cdrom= diff -r 43edce5b75d6 -r 94c6fc048d8e tools/firmware/vmxassist/Makefile --- a/tools/firmware/vmxassist/Makefile Thu Sep 22 19:59:31 2005 +++ b/tools/firmware/vmxassist/Makefile Fri Sep 23 11:52:43 2005 @@ -44,7 +44,7 @@ vmxloader: roms.h vmxloader.c acpi.h acpi_madt.c ${CC} ${CFLAGS} ${DEFINES} -c vmxloader.c -c acpi_madt.c $(CC) -o vmxloader.tmp -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,0x100000 vmxloader.o acpi_madt.o - objcopy --change-addresses=0xC0000000 vmxloader.tmp vmxloader + objcopy vmxloader.tmp vmxloader rm -f vmxloader.tmp vmxassist.bin: vmxassist.ld ${OBJECTS} diff -r 43edce5b75d6 -r 94c6fc048d8e tools/firmware/vmxassist/vmxloader.c --- a/tools/firmware/vmxassist/vmxloader.c Thu Sep 22 19:59:31 2005 +++ b/tools/firmware/vmxassist/vmxloader.c Fri Sep 23 11:52:43 2005 @@ -34,28 +34,39 @@ /* * C runtime start off */ -asm(" \n\ - .text \n\ - .globl _start \n\ -_start: \n\ - cli \n\ - movl $stack_top, %esp \n\ - movl %esp, %ebp \n\ - call main \n\ - jmp halt \n\ - \n\ - .globl halt \n\ -halt: \n\ - sti \n\ - jmp . \n\ - \n\ - .bss \n\ - .align 8 \n\ - .globl stack, stack_top \n\ -stack: \n\ - .skip 0x4000 \n\ -stack_top: \n\ -"); +asm( +" .text \n" +" .globl _start \n" +"_start: \n" +" cld \n" +" cli \n" +" lgdt gdt_desr \n" +" movl $stack_top, %esp \n" +" movl %esp, %ebp \n" +" call main \n" +" jmp halt \n" +" \n" +"gdt_desr: \n" +" .word gdt_end - gdt - 1 \n" +" .long gdt \n" +" \n" +" .align 8 \n" +"gdt: \n" +" .quad 0x0000000000000000 \n" +" .quad 0x00CF92000000FFFF \n" +" .quad 0x00CF9A000000FFFF \n" +"gdt_end: \n" +" \n" +"halt: \n" +" sti \n" +" jmp . \n" +" \n" +" .bss \n" +" .align 8 \n" +"stack: \n" +" .skip 0x4000 \n" +"stack_top: \n" +); void * memcpy(void *dest, const void *src, unsigned n) @@ -95,7 +106,7 @@ } int -main() +main(void) { puts("VMXAssist Loader\n"); puts("Loading ROMBIOS ...\n"); diff -r 43edce5b75d6 -r 94c6fc048d8e tools/libxc/xc_vmx_build.c --- a/tools/libxc/xc_vmx_build.c Thu Sep 22 19:59:31 2005 +++ b/tools/libxc/xc_vmx_build.c Fri Sep 23 11:52:43 2005 @@ -10,7 +10,8 @@ #include <unistd.h> #include <zlib.h> #include <xen/io/ioreq.h> -#include "linux_boot_params.h" + +#define VMX_LOADER_ENTR_ADDR 0x00100000 #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER) #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) @@ -18,12 +19,28 @@ #define L3_PROT (_PAGE_PRESENT) #endif +#define E820MAX 128 + +#define E820_RAM 1 +#define E820_RESERVED 2 +#define E820_ACPI 3 +#define E820_NVS 4 +#define E820_IO 16 +#define E820_SHARED_PAGE 17 +#define E820_XENSTORE 18 + +#define E820_MAP_PAGE 0x00090000 +#define E820_MAP_NR_OFFSET 0x000001E8 +#define E820_MAP_OFFSET 0x000002D0 + +struct e820entry { + u64 addr; + u64 size; + u32 type; +} __attribute__((packed)); + #define round_pgup(_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK) #define round_pgdown(_p) ((_p)&PAGE_MASK) - -#define LINUX_BOOT_PARAMS_ADDR 0x00090000 -#define LINUX_KERNEL_ENTR_ADDR 0x00100000 -#define LINUX_PAGE_OFFSET 0xC0000000 static int parseelfimage( @@ -33,78 +50,70 @@ char *elfbase, int xch, u32 dom, unsigned long *parray, struct domain_setup_info *dsi); -static void build_e820map(struct mem_map *mem_mapp, unsigned long mem_size) -{ - int nr_map = 0; +static unsigned char build_e820map(void *e820_page, unsigned long mem_size) +{ + struct e820entry *e820entry = + (struct e820entry *)(((unsigned char *)e820_page) + E820_MAP_OFFSET); + unsigned char nr_map = 0; /* XXX: Doesn't work for > 4GB yet */ - mem_mapp->map[nr_map].addr = 0x0; - mem_mapp->map[nr_map].size = 0x9F800; - mem_mapp->map[nr_map].type = E820_RAM; - mem_mapp->map[nr_map].caching_attr = MEMMAP_WB; - nr_map++; - - mem_mapp->map[nr_map].addr = 0x9F800; - mem_mapp->map[nr_map].size = 0x800; - mem_mapp->map[nr_map].type = E820_RESERVED; - mem_mapp->map[nr_map].caching_attr = MEMMAP_UC; - nr_map++; - - mem_mapp->map[nr_map].addr = 0xA0000; - mem_mapp->map[nr_map].size = 0x20000; - mem_mapp->map[nr_map].type = E820_IO; - mem_mapp->map[nr_map].caching_attr = MEMMAP_UC; - nr_map++; - - mem_mapp->map[nr_map].addr = 0xF0000; - mem_mapp->map[nr_map].size = 0x10000; - mem_mapp->map[nr_map].type = E820_RESERVED; - mem_mapp->map[nr_map].caching_attr = MEMMAP_UC; + e820entry[nr_map].addr = 0x0; + e820entry[nr_map].size = 0x9F800; + e820entry[nr_map].type = E820_RAM; + nr_map++; + + e820entry[nr_map].addr = 0x9F800; + e820entry[nr_map].size = 0x800; + e820entry[nr_map].type = E820_RESERVED; + nr_map++; + + e820entry[nr_map].addr = 0xA0000; + e820entry[nr_map].size = 0x20000; + e820entry[nr_map].type = E820_IO; + nr_map++; + + e820entry[nr_map].addr = 0xF0000; + e820entry[nr_map].size = 0x10000; + e820entry[nr_map].type = E820_RESERVED; nr_map++; #define STATIC_PAGES 2 /* for ioreq_t and store_mfn */ /* Most of the ram goes here */ - mem_mapp->map[nr_map].addr = 0x100000; - mem_mapp->map[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE; - mem_mapp->map[nr_map].type = E820_RAM; - mem_mapp->map[nr_map].caching_attr = MEMMAP_WB; + e820entry[nr_map].addr = 0x100000; + e820entry[nr_map].size = mem_size - 0x100000 - STATIC_PAGES*PAGE_SIZE; + e820entry[nr_map].type = E820_RAM; nr_map++; /* Statically allocated special pages */ /* Shared ioreq_t page */ - mem_mapp->map[nr_map].addr = mem_size - PAGE_SIZE; - mem_mapp->map[nr_map].size = PAGE_SIZE; - mem_mapp->map[nr_map].type = E820_SHARED; - mem_mapp->map[nr_map].caching_attr = MEMMAP_WB; + e820entry[nr_map].addr = mem_size - PAGE_SIZE; + e820entry[nr_map].size = PAGE_SIZE; + e820entry[nr_map].type = E820_SHARED_PAGE; nr_map++; /* For xenstore */ - mem_mapp->map[nr_map].addr = mem_size - 2*PAGE_SIZE; - mem_mapp->map[nr_map].size = PAGE_SIZE; - mem_mapp->map[nr_map].type = E820_XENSTORE; - mem_mapp->map[nr_map].caching_attr = MEMMAP_WB; - nr_map++; - - mem_mapp->map[nr_map].addr = mem_size; - mem_mapp->map[nr_map].size = 0x3 * PAGE_SIZE; - mem_mapp->map[nr_map].type = E820_NVS; - mem_mapp->map[nr_map].caching_attr = MEMMAP_UC; - nr_map++; - - mem_mapp->map[nr_map].addr = mem_size + 0x3 * PAGE_SIZE; - mem_mapp->map[nr_map].size = 0xA * PAGE_SIZE; - mem_mapp->map[nr_map].type = E820_ACPI; - mem_mapp->map[nr_map].caching_attr = MEMMAP_WB; - nr_map++; - - mem_mapp->map[nr_map].addr = 0xFEC00000; - mem_mapp->map[nr_map].size = 0x1400000; - mem_mapp->map[nr_map].type = E820_IO; - mem_mapp->map[nr_map].caching_attr = MEMMAP_UC; - nr_map++; - - mem_mapp->nr_map = nr_map; + e820entry[nr_map].addr = mem_size - 2*PAGE_SIZE; + e820entry[nr_map].size = PAGE_SIZE; + e820entry[nr_map].type = E820_XENSTORE; + nr_map++; + + e820entry[nr_map].addr = mem_size; + e820entry[nr_map].size = 0x3 * PAGE_SIZE; + e820entry[nr_map].type = E820_NVS; + nr_map++; + + e820entry[nr_map].addr = mem_size + 0x3 * PAGE_SIZE; + e820entry[nr_map].size = 0xA * PAGE_SIZE; + e820entry[nr_map].type = E820_ACPI; + nr_map++; + + e820entry[nr_map].addr = 0xFEC00000; + e820entry[nr_map].size = 0x1400000; + e820entry[nr_map].type = E820_IO; + nr_map++; + + return (*(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map); } /* @@ -112,19 +121,19 @@ * vmxloader will use it to config ACPI MADT table */ #define VCPU_MAGIC 0x76637075 /* "vcpu" */ -static int -set_nr_vcpus(int xc_handle, u32 dom, unsigned long *pfn_list, +static int +set_nr_vcpus(int xc_handle, u32 dom, unsigned long *pfn_list, struct domain_setup_info *dsi, unsigned long vcpus) { char *va_map; unsigned long *va_vcpus; - + va_map = xc_map_foreign_range( xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, - pfn_list[(0x9F000 - dsi->v_start) >> PAGE_SHIFT]); + pfn_list[(0x9F000 - dsi->v_start) >> PAGE_SHIFT]); if ( va_map == NULL ) return -1; - + va_vcpus = (unsigned long *)(va_map + 0x800); *va_vcpus++ = VCPU_MAGIC; *va_vcpus++ = vcpus; @@ -164,24 +173,23 @@ return 0; } -static int zap_mmio_ranges(int xc_handle, u32 dom, - unsigned long l2tab, - struct mem_map *mem_mapp) -{ - int i; +static int zap_mmio_ranges(int xc_handle, u32 dom, unsigned long l2tab, + unsigned char e820_map_nr, unsigned char *e820map) +{ + unsigned int i; + struct e820entry *e820entry = (struct e820entry *)e820map; + l2_pgentry_32_t *vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, l2tab >> PAGE_SHIFT); if ( vl2tab == 0 ) return -1; - for ( i = 0; i < mem_mapp->nr_map; i++ ) - { - if ( (mem_mapp->map[i].type == E820_IO) && - (mem_mapp->map[i].caching_attr == MEMMAP_UC) && + for ( i = 0; i < e820_map_nr; i++ ) + { + if ( (e820entry[i].type == E820_IO) && (zap_mmio_range(xc_handle, dom, vl2tab, - mem_mapp->map[i].addr, - mem_mapp->map[i].size) == -1) ) + e820entry[i].addr, e820entry[i].size) == -1)) return -1; } @@ -200,7 +208,7 @@ unsigned long vl3e; l1_pgentry_t *vl1tab; l2_pgentry_t *vl2tab; - + mmio_addr = mmio_range_start & PAGE_MASK; for ( ; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE ) { @@ -239,22 +247,22 @@ return 0; } -static int zap_mmio_ranges(int xc_handle, u32 dom, - unsigned long l3tab, - struct mem_map *mem_mapp) -{ - int i; +static int zap_mmio_ranges(int xc_handle, u32 dom, unsigned long l3tab, + unsigned char e820_map_nr, unsigned char *e820map) +{ + unsigned int i; + struct e820entry *e820entry = (struct e820entry *)e820map; + l3_pgentry_t *vl3tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, l3tab >> PAGE_SHIFT); if (vl3tab == 0) return -1; - for (i = 0; i < mem_mapp->nr_map; i++) { - if ((mem_mapp->map[i].type == E820_IO) - && (mem_mapp->map[i].caching_attr == MEMMAP_UC)) - if (zap_mmio_range(xc_handle, dom, vl3tab, - mem_mapp->map[i].addr, mem_mapp->map[i].size) == -1) - return -1; + for ( i = 0; i < e820_map_nr; i++ ) { + if ( (e820entry[i].type == E820_IO) && + (zap_mmio_range(xc_handle, dom, vl3tab, + e820entry[i].addr, e820entry[i].size) == -1) ) + return -1; } munmap(vl3tab, PAGE_SIZE); return 0; @@ -265,18 +273,14 @@ static int setup_guest(int xc_handle, u32 dom, int memsize, char *image, unsigned long image_size, - gzFile initrd_gfd, unsigned long initrd_len, unsigned long nr_pages, vcpu_guest_context_t *ctxt, - const char *cmdline, unsigned long shared_info_frame, unsigned int control_evtchn, unsigned long flags, unsigned int vcpus, unsigned int store_evtchn, - unsigned long *store_mfn, - struct mem_map *mem_mapp - ) + unsigned long *store_mfn) { l1_pgentry_t *vl1tab=NULL, *vl1e=NULL; l2_pgentry_t *vl2tab=NULL, *vl2e=NULL; @@ -289,8 +293,8 @@ unsigned long l1tab; unsigned long count, i; shared_info_t *shared_info; - struct linux_boot_params * boot_paramsp; - __u16 * boot_gdtp; + void *e820_page; + unsigned char e820_map_nr; xc_mmu_t *mmu = NULL; int rc; @@ -298,12 +302,6 @@ unsigned long ppt_alloc; struct domain_setup_info dsi; - unsigned long vinitrd_start; - unsigned long vinitrd_end; - unsigned long vboot_params_start; - unsigned long vboot_params_end; - unsigned long vboot_gdt_start; - unsigned long vboot_gdt_end; unsigned long vpt_start; unsigned long vpt_end; unsigned long v_end; @@ -322,27 +320,8 @@ goto error_out; } - /* - * Why do we need this? The number of page-table frames depends on the - * size of the bootstrap address space. But the size of the address space - * depends on the number of page-table frames (since each one is mapped - * read-only). We have a pair of simultaneous equations in two unknowns, - * which we solve by exhaustive search. - */ - vboot_params_start = LINUX_BOOT_PARAMS_ADDR; - vboot_params_end = vboot_params_start + PAGE_SIZE; - vboot_gdt_start = vboot_params_end; - vboot_gdt_end = vboot_gdt_start + PAGE_SIZE; - /* memsize is in megabytes */ v_end = memsize << 20; - /* leaving the top 4k untouched for IO requests page use */ - vinitrd_end = v_end - PAGE_SIZE; - vinitrd_start = vinitrd_end - initrd_len; - vinitrd_start = vinitrd_start & (~(PAGE_SIZE - 1)); - - if(initrd_len == 0) - vinitrd_start = vinitrd_end = 0; #ifdef __i386__ nr_pt_pages = 1 + ((memsize + 3) >> 2); @@ -353,24 +332,17 @@ vpt_end = vpt_start + (nr_pt_pages * PAGE_SIZE); printf("VIRTUAL MEMORY ARRANGEMENT:\n" - " Boot_params: %08lx->%08lx\n" - " boot_gdt: %08lx->%08lx\n" - " Loaded kernel: %08lx->%08lx\n" - " Init. ramdisk: %08lx->%08lx\n" + " Loaded VMX loader: %08lx->%08lx\n" " Page tables: %08lx->%08lx\n" " TOTAL: %08lx->%08lx\n", - vboot_params_start, vboot_params_end, - vboot_gdt_start, vboot_gdt_end, - dsi.v_kernstart, dsi.v_kernend, - vinitrd_start, vinitrd_end, + dsi.v_kernstart, dsi.v_kernend, vpt_start, vpt_end, dsi.v_start, v_end); printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry); - printf(" INITRD LENGTH: %08lx\n", initrd_len); if ( (v_end - dsi.v_start) > (nr_pages * PAGE_SIZE) ) { - printf("Initial guest OS requires too much space\n" + ERROR("Initial guest OS requires too much space\n" "(%luMB is greater than %luMB limit)\n", (v_end-dsi.v_start)>>20, (nr_pages<<PAGE_SHIFT)>>20); goto error_out; @@ -389,23 +361,6 @@ } loadelfimage(image, xc_handle, dom, page_array, &dsi); - - /* Load the initial ramdisk image. */ - if ( initrd_len != 0 ) - { - for ( i = (vinitrd_start - dsi.v_start); - i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE ) - { - char page[PAGE_SIZE]; - if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 ) - { - PERROR("Error reading initrd image, could not"); - goto error_out; - } - xc_copy_to_domain_page(xc_handle, dom, - page_array[i>>PAGE_SHIFT], page); - } - } if ( (mmu = xc_init_mmu_updates(xc_handle, dom)) == NULL ) goto error_out; @@ -429,14 +384,14 @@ ctxt->ctrlreg[3] = l2tab; /* Initialise the page tables. */ - if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, + if ( (vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, + PROT_READ|PROT_WRITE, l2tab >> PAGE_SHIFT)) == NULL ) goto error_out; memset(vl2tab, 0, PAGE_SIZE); vl2e = &vl2tab[l2_table_offset(dsi.v_start)]; for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ ) - { + { if ( ((unsigned long)vl1e & (PAGE_SIZE-1)) == 0 ) { l1tab = page_array[ppt_alloc++] << PAGE_SHIFT; @@ -465,8 +420,8 @@ ctxt->ctrlreg[3] = l3tab; /* Initialise the page tables. */ - if ( (vl3tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, + if ( (vl3tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, + PROT_READ|PROT_WRITE, l3tab >> PAGE_SHIFT)) == NULL ) goto error_out; memset(vl3tab, 0, PAGE_SIZE); @@ -519,103 +474,31 @@ for ( count = 0; count < nr_pages; count++ ) { if ( xc_add_mmu_update(xc_handle, mmu, - (page_array[count] << PAGE_SHIFT) | + (page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, count) ) goto error_out; } set_nr_vcpus(xc_handle, dom, page_array, &dsi, vcpus); - if ((boot_paramsp = xc_map_foreign_range( + *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT]; + shared_page_frame = (v_end - PAGE_SIZE) >> PAGE_SHIFT; + + if ((e820_page = xc_map_foreign_range( xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, - page_array[(vboot_params_start-dsi.v_start)>>PAGE_SHIFT])) == 0) - goto error_out; - - memset(boot_paramsp, 0, sizeof(*boot_paramsp)); - - strncpy((char *)boot_paramsp->cmd_line, cmdline, 0x800); - boot_paramsp->cmd_line[0x800-1] = '\0'; - boot_paramsp->cmd_line_ptr = ((unsigned long) vboot_params_start) + offsetof(struct linux_boot_params, cmd_line); - - boot_paramsp->setup_sects = 0; - boot_paramsp->mount_root_rdonly = 1; - boot_paramsp->swapdev = 0x0; - boot_paramsp->ramdisk_flags = 0x0; - boot_paramsp->root_dev = 0x0; /* We must tell kernel root dev by kernel command line. */ - - /* we don't have a ps/2 mouse now. - * 0xAA means a aux mouse is there. - * See detect_auxiliary_port() in pc_keyb.c. - */ - boot_paramsp->aux_device_info = 0x0; - - boot_paramsp->header_magic[0] = 0x48; /* "H" */ - boot_paramsp->header_magic[1] = 0x64; /* "d" */ - boot_paramsp->header_magic[2] = 0x72; /* "r" */ - boot_paramsp->header_magic[3] = 0x53; /* "S" */ - - boot_paramsp->protocol_version = 0x0203; /* 2.03 */ - boot_paramsp->loader_type = 0x71; /* GRUB */ - boot_paramsp->loader_flags = 0x1; /* loaded high */ - boot_paramsp->code32_start = LINUX_KERNEL_ENTR_ADDR; /* 1MB */ - boot_paramsp->initrd_start = vinitrd_start; - boot_paramsp->initrd_size = initrd_len; - - i = ((memsize - 1) << 10) - 4; - boot_paramsp->alt_mem_k = i; /* alt_mem_k */ - boot_paramsp->screen.overlap.ext_mem_k = i & 0xFFFF; /* ext_mem_k */ - - /* - * Stuff SCREAN_INFO - */ - boot_paramsp->screen.info.orig_x = 0; - boot_paramsp->screen.info.orig_y = 0; - boot_paramsp->screen.info.orig_video_page = 8; - boot_paramsp->screen.info.orig_video_mode = 3; - boot_paramsp->screen.info.orig_video_cols = 80; - boot_paramsp->screen.info.orig_video_ega_bx = 0; - boot_paramsp->screen.info.orig_video_lines = 25; - boot_paramsp->screen.info.orig_video_isVGA = 1; - boot_paramsp->screen.info.orig_video_points = 0x0010; - - /* seems we may NOT stuff boot_paramsp->apm_bios_info */ - /* seems we may NOT stuff boot_paramsp->drive_info */ - /* seems we may NOT stuff boot_paramsp->sys_desc_table */ - *((unsigned short *) &boot_paramsp->drive_info.dummy[0]) = 800; - boot_paramsp->drive_info.dummy[2] = 4; - boot_paramsp->drive_info.dummy[14] = 32; - - /* memsize is in megabytes */ - /* If you need to create a special e820map, comment this line - and use mem-map.sxp */ - build_e820map(mem_mapp, memsize << 20); - *store_mfn = page_array[(v_end-2) >> PAGE_SHIFT]; + page_array[E820_MAP_PAGE >> PAGE_SHIFT])) == 0) + goto error_out; + memset(e820_page, 0, PAGE_SIZE); + e820_map_nr = build_e820map(e820_page, v_end); #if defined (__i386__) - if (zap_mmio_ranges(xc_handle, dom, l2tab, mem_mapp) == -1) + if (zap_mmio_ranges(xc_handle, dom, l2tab, e820_map_nr, + ((unsigned char *)e820_page) + E820_MAP_OFFSET) == -1) #else - if (zap_mmio_ranges(xc_handle, dom, l3tab, mem_mapp) == -1) + if (zap_mmio_ranges(xc_handle, dom, l3tab, e820_map_nr, + ((unsigned char *)e820_page) + E820_MAP_OFFSET) == -1) #endif - goto error_out; - boot_paramsp->e820_map_nr = mem_mapp->nr_map; - for (i=0; i<mem_mapp->nr_map; i++) { - boot_paramsp->e820_map[i].addr = mem_mapp->map[i].addr; - boot_paramsp->e820_map[i].size = mem_mapp->map[i].size; - boot_paramsp->e820_map[i].type = mem_mapp->map[i].type; - if (mem_mapp->map[i].type == E820_SHARED) - shared_page_frame = (mem_mapp->map[i].addr >> PAGE_SHIFT); - } - munmap(boot_paramsp, PAGE_SIZE); - - if ((boot_gdtp = xc_map_foreign_range( - xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, - page_array[(vboot_gdt_start-dsi.v_start)>>PAGE_SHIFT])) == 0) - goto error_out; - memset(boot_gdtp, 0, PAGE_SIZE); - boot_gdtp[12*4 + 0] = boot_gdtp[13*4 + 0] = 0xffff; /* limit */ - boot_gdtp[12*4 + 1] = boot_gdtp[13*4 + 1] = 0x0000; /* base */ - boot_gdtp[12*4 + 2] = 0x9a00; boot_gdtp[13*4 + 2] = 0x9200; /* perms */ - boot_gdtp[12*4 + 3] = boot_gdtp[13*4 + 3] = 0x00cf; /* granu + top of limit */ - munmap(boot_gdtp, PAGE_SIZE); + goto error_out; + munmap(e820_page, PAGE_SIZE); /* shared_info page starts its life empty. */ if ((shared_info = xc_map_foreign_range( @@ -651,20 +534,21 @@ /* * Initial register values: */ - ctxt->user_regs.ds = 0x68; - ctxt->user_regs.es = 0x0; - ctxt->user_regs.fs = 0x0; - ctxt->user_regs.gs = 0x0; - ctxt->user_regs.ss = 0x68; - ctxt->user_regs.cs = 0x60; + ctxt->user_regs.ds = 0; + ctxt->user_regs.es = 0; + ctxt->user_regs.fs = 0; + ctxt->user_regs.gs = 0; + ctxt->user_regs.ss = 0; + ctxt->user_regs.cs = 0; ctxt->user_regs.eip = dsi.v_kernentry; - ctxt->user_regs.edx = vboot_gdt_start; - ctxt->user_regs.eax = 0x800; - ctxt->user_regs.esp = vboot_gdt_end; + ctxt->user_regs.edx = 0; + ctxt->user_regs.eax = 0; + ctxt->user_regs.esp = 0; ctxt->user_regs.ebx = 0; /* startup_32 expects this to be 0 to signal boot cpu */ - ctxt->user_regs.ecx = mem_mapp->nr_map; - ctxt->user_regs.esi = vboot_params_start; - ctxt->user_regs.edi = vboot_params_start + 0x2d0; + ctxt->user_regs.ecx = 0; + ctxt->user_regs.esi = 0; + ctxt->user_regs.edi = 0; + ctxt->user_regs.ebp = 0; ctxt->user_regs.eflags = 0; @@ -684,9 +568,9 @@ int eax, ecx; #ifdef __i386__ - __asm__ __volatile__ ("pushl %%ebx; cpuid; popl %%ebx" - : "=a" (eax), "=c" (ecx) - : "0" (1) + __asm__ __volatile__ ("pushl %%ebx; cpuid; popl %%ebx" + : "=a" (eax), "=c" (ecx) + : "0" (1) : "dx"); #elif defined __x86_64__ __asm__ __volatile__ ("pushq %%rbx; cpuid; popq %%rbx" @@ -705,9 +589,6 @@ u32 domid, int memsize, const char *image_name, - struct mem_map *mem_mapp, - const char *ramdisk_name, - const char *cmdline, unsigned int control_evtchn, unsigned long flags, unsigned int vcpus, @@ -715,20 +596,18 @@ unsigned long *store_mfn) { dom0_op_t launch_op, op; - int initrd_fd = -1; - gzFile initrd_gfd = NULL; int rc, i; vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt; unsigned long nr_pages; char *image = NULL; - unsigned long image_size, initrd_size=0; + unsigned long image_size; if ( vmx_identify() < 0 ) { PERROR("CPU doesn't support VMX Extensions"); goto error_out; } - + if ( (nr_pages = xc_get_tot_pages(xc_handle, domid)) < 0 ) { PERROR("Could not find total pages for domain"); @@ -738,32 +617,15 @@ if ( (image = xc_read_kernel_image(image_name, &image_size)) == NULL ) goto error_out; - if ( (ramdisk_name != NULL) && (strlen(ramdisk_name) != 0) ) - { - if ( (initrd_fd = open(ramdisk_name, O_RDONLY)) < 0 ) - { - PERROR("Could not open the initial ramdisk image"); - goto error_out; - } - - initrd_size = xc_get_filesz(initrd_fd); - - if ( (initrd_gfd = gzdopen(initrd_fd, "rb")) == NULL ) - { - PERROR("Could not allocate decompression state for initrd"); - goto error_out; - } - } - if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ) - { + { PERROR("xc_vmx_build: ctxt mlock failed"); return 1; } op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)domid; - if ( (xc_dom0_op(xc_handle, &op) < 0) || + if ( (xc_dom0_op(xc_handle, &op) < 0) || ((u16)op.u.getdomaininfo.domain != domid) ) { PERROR("Could not get info on domain"); @@ -783,21 +645,14 @@ goto error_out; } - if ( setup_guest(xc_handle, domid, memsize, image, image_size, - initrd_gfd, initrd_size, nr_pages, - ctxt, cmdline, - op.u.getdomaininfo.shared_info_frame, - control_evtchn, flags, vcpus, store_evtchn, store_mfn, - mem_mapp) < 0 ) + if ( setup_guest(xc_handle, domid, memsize, image, image_size, nr_pages, + ctxt, op.u.getdomaininfo.shared_info_frame, control_evtchn, + flags, vcpus, store_evtchn, store_mfn) < 0) { ERROR("Error constructing guest OS"); goto error_out; } - if ( initrd_fd >= 0 ) - close(initrd_fd); - if ( initrd_gfd ) - gzclose(initrd_gfd); free(image); ctxt->flags = VGCF_VMX_GUEST; @@ -813,15 +668,10 @@ /* No LDT. */ ctxt->ldt_ents = 0; - + /* Use the default Xen-provided GDT. */ ctxt->gdt_ents = 0; - /* Ring 1 stack is the initial stack. */ -/* - ctxt->kernel_ss = FLAT_KERNEL_DS; - ctxt->kernel_sp = vstartinfo_start; -*/ /* No debugging. */ memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg)); @@ -845,14 +695,10 @@ launch_op.cmd = DOM0_SETDOMAININFO; rc = xc_dom0_op(xc_handle, &launch_op); - + return rc; error_out: - if ( initrd_gfd != NULL ) - gzclose(initrd_gfd); - else if ( initrd_fd >= 0 ) - close(initrd_fd); free(image); return -1; @@ -864,7 +710,7 @@ ((phdr->p_flags & (PF_W|PF_X)) != 0)); } -static int parseelfimage(char *elfbase, +static int parseelfimage(char *elfbase, unsigned long elfsize, struct domain_setup_info *dsi) { @@ -899,11 +745,11 @@ ERROR("ELF image has no section-header strings table (shstrtab)."); return -EINVAL; } - shdr = (Elf32_Shdr *)(elfbase + ehdr->e_shoff + + shdr = (Elf32_Shdr *)(elfbase + ehdr->e_shoff + (ehdr->e_shstrndx*ehdr->e_shentsize)); shstrtab = elfbase + shdr->sh_offset; - - for ( h = 0; h < ehdr->e_phnum; h++ ) + + for ( h = 0; h < ehdr->e_phnum; h++ ) { phdr = (Elf32_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize)); if ( !is_loadable_phdr(phdr) ) @@ -914,8 +760,8 @@ kernend = phdr->p_paddr + phdr->p_memsz; } - if ( (kernstart > kernend) || - (ehdr->e_entry < kernstart) || + if ( (kernstart > kernend) || + (ehdr->e_entry < kernstart) || (ehdr->e_entry > kernend) ) { ERROR("Malformed ELF image."); @@ -924,9 +770,9 @@ dsi->v_start = 0x00000000; - dsi->v_kernstart = kernstart - LINUX_PAGE_OFFSET; - dsi->v_kernend = kernend - LINUX_PAGE_OFFSET; - dsi->v_kernentry = LINUX_KERNEL_ENTR_ADDR; + dsi->v_kernstart = kernstart; + dsi->v_kernend = kernend; + dsi->v_kernentry = VMX_LOADER_ENTR_ADDR; dsi->v_end = dsi->v_kernend; @@ -945,18 +791,18 @@ char *va; unsigned long pa, done, chunksz; - for ( h = 0; h < ehdr->e_phnum; h++ ) + for ( h = 0; h < ehdr->e_phnum; h++ ) { phdr = (Elf32_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize)); if ( !is_loadable_phdr(phdr) ) continue; - + for ( done = 0; done < phdr->p_filesz; done += chunksz ) { - pa = (phdr->p_paddr + done) - dsi->v_start - LINUX_PAGE_OFFSET; + pa = (phdr->p_paddr + done) - dsi->v_start; if ((va = xc_map_foreign_range( xch, dom, PAGE_SIZE, PROT_WRITE, - parray[pa>>PAGE_SHIFT])) == 0) + parray[pa >> PAGE_SHIFT])) == 0) return -1; chunksz = phdr->p_filesz - done; if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) ) @@ -968,10 +814,10 @@ for ( ; done < phdr->p_memsz; done += chunksz ) { - pa = (phdr->p_paddr + done) - dsi->v_start - LINUX_PAGE_OFFSET; + pa = (phdr->p_paddr + done) - dsi->v_start; if ((va = xc_map_foreign_range( xch, dom, PAGE_SIZE, PROT_WRITE, - parray[pa>>PAGE_SHIFT])) == 0) + parray[pa >> PAGE_SHIFT])) == 0) return -1; chunksz = phdr->p_memsz - done; if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) ) diff -r 43edce5b75d6 -r 94c6fc048d8e tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h Thu Sep 22 19:59:31 2005 +++ b/tools/libxc/xenguest.h Fri Sep 23 11:52:43 2005 @@ -57,9 +57,6 @@ uint32_t domid, int memsize, const char *image_name, - struct mem_map *memmap, - const char *ramdisk_name, - const char *cmdline, unsigned int control_evtchn, unsigned long flags, unsigned int vcpus, diff -r 43edce5b75d6 -r 94c6fc048d8e tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Thu Sep 22 19:59:31 2005 +++ b/tools/python/xen/lowlevel/xc/xc.c Fri Sep 23 11:52:43 2005 @@ -17,7 +17,6 @@ #include <arpa/inet.h> #include "xc_private.h" -#include "linux_boot_params.h" /* Needed for Python versions earlier than 2.3. */ #ifndef PyMODINIT_FUNC @@ -310,80 +309,24 @@ XcObject *xc = (XcObject *)self; u32 dom; - char *image, *ramdisk = NULL, *cmdline = ""; - PyObject *memmap; + char *image; int control_evtchn, store_evtchn; int flags = 0, vcpus = 1; - int numItems, i; int memsize; - struct mem_map mem_map; unsigned long store_mfn = 0; static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn", - "memsize", "image", "memmap", - "ramdisk", "cmdline", "flags", - "vcpus", NULL }; - - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisO!|ssii", kwd_list, + "memsize", "image", "flags", "vcpus", NULL }; + + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisii", kwd_list, &dom, &control_evtchn, &store_evtchn, - &memsize, - &image, &PyList_Type, &memmap, - &ramdisk, &cmdline, &flags, &vcpus) ) - return NULL; - - memset(&mem_map, 0, sizeof(mem_map)); - /* Parse memmap */ - - /* get the number of lines passed to us */ - numItems = PyList_Size(memmap) - 1; /* removing the line - containing "memmap" */ - mem_map.nr_map = numItems; - - /* should raise an error here. */ - if (numItems < 0) return NULL; /* Not a list */ - - /* iterate over items of the list, grabbing ranges and parsing them */ - for (i = 1; i <= numItems; i++) { // skip over "memmap" - PyObject *item, *f1, *f2, *f3, *f4; - int numFields; - unsigned long lf1, lf2, lf3, lf4; - char *sf1, *sf2; - - /* grab the string object from the next element of the list */ - item = PyList_GetItem(memmap, i); /* Can't fail */ - - /* get the number of lines passed to us */ - numFields = PyList_Size(item); - - if (numFields != 4) - return NULL; - - f1 = PyList_GetItem(item, 0); - f2 = PyList_GetItem(item, 1); - f3 = PyList_GetItem(item, 2); - f4 = PyList_GetItem(item, 3); - - /* Convert objects to strings/longs */ - sf1 = PyString_AsString(f1); - sf2 = PyString_AsString(f2); - lf3 = PyLong_AsLong(f3); - lf4 = PyLong_AsLong(f4); - if ( sscanf(sf1, "%lx", &lf1) != 1 ) - return NULL; - if ( sscanf(sf2, "%lx", &lf2) != 1 ) - return NULL; - - mem_map.map[i-1].addr = lf1; - mem_map.map[i-1].size = lf2 - lf1; - mem_map.map[i-1].type = lf3; - mem_map.map[i-1].caching_attr = lf4; - } - - if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, &mem_map, - ramdisk, cmdline, control_evtchn, flags, - vcpus, store_evtchn, &store_mfn) != 0 ) - return PyErr_SetFromErrno(xc_error); - + &memsize, &image, &flags, &vcpus) ) + return NULL; + + if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, control_evtchn, + flags, vcpus, store_evtchn, &store_mfn) != 0 ) + return PyErr_SetFromErrno(xc_error); + return Py_BuildValue("{s:i}", "store_mfn", store_mfn); } diff -r 43edce5b75d6 -r 94c6fc048d8e tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.py Thu Sep 22 19:59:31 2005 +++ b/tools/python/xen/xend/image.py Fri Sep 23 11:52:43 2005 @@ -238,22 +238,19 @@ def configure(self, imageConfig, deviceConfig): ImageHandler.configure(self, imageConfig, deviceConfig) - - self.memmap = sxp.child_value(imageConfig, 'memmap') + self.dmargs = self.parseDeviceModelArgs(imageConfig, deviceConfig) self.device_model = sxp.child_value(imageConfig, 'device_model') if not self.device_model: raise VmError("vmx: missing device model") self.display = sxp.child_value(imageConfig, 'display') - self.vm.storeVm(("image/memmap", self.memmap), - ("image/dmargs", " ".join(self.dmargs)), + self.vm.storeVm(("image/dmargs", " ".join(self.dmargs)), ("image/device-model", self.device_model), ("image/display", self.display)) self.device_channel = None self.pid = 0 - self.memmap_value = [] self.dmargs += self.configVNC(imageConfig) @@ -261,7 +258,6 @@ def createImage(self): """Create a VM for the VMX environment. """ - self.parseMemmap() self.createDomain() def buildDomain(self): @@ -278,9 +274,6 @@ log.debug("control_evtchn = %d", self.device_channel.port2) log.debug("store_evtchn = %d", store_evtchn) log.debug("memsize = %d", self.vm.getMemoryTarget() / 1024) - log.debug("memmap = %s", self.memmap_value) - log.debug("cmdline = %s", self.cmdline) - log.debug("ramdisk = %s", self.ramdisk) log.debug("flags = %d", self.flags) log.debug("vcpus = %d", self.vm.getVCpuCount()) @@ -289,9 +282,6 @@ control_evtchn = self.device_channel.port2, store_evtchn = store_evtchn, memsize = self.vm.getMemoryTarget() / 1024, - memmap = self.memmap_value, - cmdline = self.cmdline, - ramdisk = self.ramdisk, flags = self.flags, vcpus = self.vm.getVCpuCount()) if isinstance(ret, dict): @@ -299,18 +289,11 @@ return 0 return ret - def parseMemmap(self): - if self.memmap is None: - return - memmap = sxp.parse(open(self.memmap))[0] - from xen.util.memmap import memmap_parse - self.memmap_value = memmap_parse(memmap) - # Return a list of cmd line args to the device models based on the # xm config file def parseDeviceModelArgs(self, imageConfig, deviceConfig): dmargs = [ 'cdrom', 'boot', 'fda', 'fdb', - 'localtime', 'serial', 'stdvga', 'isa', 'vcpus' ] + 'localtime', 'serial', 'stdvga', 'isa', 'vcpus' ] ret = [] for a in dmargs: v = sxp.child_value(imageConfig, a) diff -r 43edce5b75d6 -r 94c6fc048d8e xen/arch/x86/vmx_vmcs.c --- a/xen/arch/x86/vmx_vmcs.c Thu Sep 22 19:59:31 2005 +++ b/xen/arch/x86/vmx_vmcs.c Fri Sep 23 11:52:43 2005 @@ -37,19 +37,19 @@ #endif #ifdef CONFIG_VMX -struct vmcs_struct *alloc_vmcs(void) +struct vmcs_struct *alloc_vmcs(void) { struct vmcs_struct *vmcs; u32 vmx_msr_low, vmx_msr_high; rdmsr(MSR_IA32_VMX_BASIC_MSR, vmx_msr_low, vmx_msr_high); vmcs_size = vmx_msr_high & 0x1fff; - vmcs = alloc_xenheap_pages(get_order_from_bytes(vmcs_size)); + vmcs = alloc_xenheap_pages(get_order_from_bytes(vmcs_size)); memset((char *)vmcs, 0, vmcs_size); /* don't remove this */ vmcs->vmcs_revision_id = vmx_msr_low; return vmcs; -} +} void free_vmcs(struct vmcs_struct *vmcs) { @@ -65,7 +65,7 @@ void *io_bitmap_a; void *io_bitmap_b; - error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL, + error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL, MONITOR_PIN_BASED_EXEC_CONTROLS); error |= __vmwrite(VM_EXIT_CONTROLS, MONITOR_VM_EXIT_CONTROLS); @@ -73,8 +73,8 @@ error |= __vmwrite(VM_ENTRY_CONTROLS, MONITOR_VM_ENTRY_CONTROLS); /* need to use 0x1000 instead of PAGE_SIZE */ - io_bitmap_a = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000)); - io_bitmap_b = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000)); + io_bitmap_a = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000)); + io_bitmap_b = (void*) alloc_xenheap_pages(get_order_from_bytes(0x1000)); memset(io_bitmap_a, 0xff, 0x1000); /* don't bother debug port access */ clear_bit(PC_DEBUG_PORT, io_bitmap_a); @@ -89,8 +89,10 @@ return error; } -#define GUEST_SEGMENT_LIMIT 0xffffffff -#define HOST_SEGMENT_LIMIT 0xffffffff +#define GUEST_LAUNCH_DS 0x08 +#define GUEST_LAUNCH_CS 0x10 +#define GUEST_SEGMENT_LIMIT 0xffffffff +#define HOST_SEGMENT_LIMIT 0xffffffff struct host_execution_env { /* selectors */ @@ -110,72 +112,80 @@ unsigned long tr_base; unsigned long ds_base; unsigned long cs_base; -#ifdef __x86_64__ - unsigned long fs_base; - unsigned long gs_base; -#endif +#ifdef __x86_64__ + unsigned long fs_base; + unsigned long gs_base; +#endif }; -#define round_pgdown(_p) ((_p)&PAGE_MASK) /* coped from domain.c */ - -int vmx_setup_platform(struct vcpu *d, struct cpu_user_regs *regs) +static void vmx_setup_platform(struct vcpu *v, struct cpu_user_regs *regs) { int i; - unsigned int n; - unsigned long *p, mpfn, offset, addr; - struct e820entry *e820p; + unsigned char e820_map_nr; + struct e820entry *e820entry; + unsigned char *p; + unsigned long mpfn; unsigned long gpfn = 0; local_flush_tlb_pge(); - regs->ebx = 0; /* Linux expects ebx to be 0 for boot proc */ - - n = regs->ecx; - if (n > 32) { - VMX_DBG_LOG(DBG_LEVEL_1, "Too many e820 entries: %d", n); - return -1; - } - - addr = regs->edi; - offset = (addr & ~PAGE_MASK); - addr = round_pgdown(addr); - - mpfn = get_mfn_from_pfn(addr >> PAGE_SHIFT); + + mpfn = get_mfn_from_pfn(E820_MAP_PAGE >> PAGE_SHIFT); + if (mpfn == INVALID_MFN) { + printk("Can not find E820 memory map page for VMX domain.\n"); + domain_crash(); + } + p = map_domain_page(mpfn); - - e820p = (struct e820entry *) ((unsigned long) p + offset); + if (p == NULL) { + printk("Can not map E820 memory map page for VMX domain.\n"); + domain_crash(); + } + + e820_map_nr = *(p + E820_MAP_NR_OFFSET); + e820entry = (struct e820entry *)(p + E820_MAP_OFFSET); #ifndef NDEBUG - print_e820_memory_map(e820p, n); -#endif - - for ( i = 0; i < n; i++ ) + print_e820_memory_map(e820entry, n); +#endif + + for ( i = 0; i < e820_map_nr; i++ ) { - if ( e820p[i].type == E820_SHARED_PAGE ) + if (e820entry[i].type == E820_SHARED_PAGE) { - gpfn = (e820p[i].addr >> PAGE_SHIFT); + gpfn = (e820entry[i].addr >> PAGE_SHIFT); break; } } - if ( gpfn == 0 ) - { - unmap_domain_page(p); - return -1; - } - - unmap_domain_page(p); + if ( gpfn == 0 ) { + printk("Can not get io request shared page" + " from E820 memory map for VMX domain.\n"); + unmap_domain_page(p); + domain_crash(); + } + unmap_domain_page(p); + + if (v->vcpu_id) + return; /* Initialise shared page */ mpfn = get_mfn_from_pfn(gpfn); + if (mpfn == INVALID_MFN) { + printk("Can not find io request shared page for VMX domain.\n"); + domain_crash(); + } + p = map_domain_page(mpfn); - d->domain->arch.vmx_platform.shared_page_va = (unsigned long)p; - - VMX_DBG_LOG(DBG_LEVEL_1, "eport: %x\n", iopacket_port(d->domain)); - - clear_bit(iopacket_port(d->domain), - &d->domain->shared_info->evtchn_mask[0]); - - return 0; + if (p == NULL) { + printk("Can not map io request shared page for VMX domain.\n"); + domain_crash(); + } + v->domain->arch.vmx_platform.shared_page_va = (unsigned long)p; + + VMX_DBG_LOG(DBG_LEVEL_1, "eport: %x\n", iopacket_port(v->domain)); + + clear_bit(iopacket_port(v->domain), + &v->domain->shared_info->evtchn_mask[0]); } void vmx_set_host_env(struct vcpu *v) @@ -203,7 +213,7 @@ error |= __vmwrite(HOST_TR_BASE, host_env.tr_base); } -void vmx_do_launch(struct vcpu *v) +void vmx_do_launch(struct vcpu *v) { /* Update CR3, GDT, LDT, TR */ unsigned int error = 0; @@ -217,7 +227,7 @@ error |= __vmwrite(GUEST_CR0, cr0); cr0 &= ~X86_CR0_PG; error |= __vmwrite(CR0_READ_SHADOW, cr0); - error |= __vmwrite(CPU_BASED_VM_EXEC_CONTROL, + error |= __vmwrite(CPU_BASED_VM_EXEC_CONTROL, MONITOR_CPU_BASED_EXEC_CONTROLS); __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (cr4) : ); @@ -247,7 +257,7 @@ error |= __vmwrite(GUEST_LDTR_SELECTOR, 0); error |= __vmwrite(GUEST_LDTR_BASE, 0); error |= __vmwrite(GUEST_LDTR_LIMIT, 0); - + error |= __vmwrite(GUEST_TR_BASE, 0); error |= __vmwrite(GUEST_TR_LIMIT, 0xff); @@ -261,10 +271,8 @@ /* * Initially set the same environement as host. */ -static inline int -construct_init_vmcs_guest(struct cpu_user_regs *regs, - struct vcpu_guest_context *ctxt, - struct host_execution_env *host_env) +static inline int +construct_init_vmcs_guest(struct cpu_user_regs *regs) { int error = 0; union vmcs_arbytes arbytes; @@ -292,31 +300,37 @@ error |= __vmwrite(CR3_TARGET_COUNT, 0); /* Guest Selectors */ - error |= __vmwrite(GUEST_CS_SELECTOR, regs->cs); - error |= __vmwrite(GUEST_ES_SELECTOR, regs->es); - error |= __vmwrite(GUEST_SS_SELECTOR, regs->ss); - error |= __vmwrite(GUEST_DS_SELECTOR, regs->ds); - error |= __vmwrite(GUEST_FS_SELECTOR, regs->fs); - error |= __vmwrite(GUEST_GS_SELECTOR, regs->gs); + error |= __vmwrite(GUEST_ES_SELECTOR, GUEST_LAUNCH_DS); + error |= __vmwrite(GUEST_SS_SELECTOR, GUEST_LAUNCH_DS); + error |= __vmwrite(GUEST_DS_SELECTOR, GUEST_LAUNCH_DS); + error |= __vmwrite(GUEST_FS_SELECTOR, GUEST_LAUNCH_DS); + error |= __vmwrite(GUEST_GS_SELECTOR, GUEST_LAUNCH_DS); + error |= __vmwrite(GUEST_CS_SELECTOR, GUEST_LAUNCH_CS); + + /* Guest segment bases */ + error |= __vmwrite(GUEST_ES_BASE, 0); + error |= __vmwrite(GUEST_SS_BASE, 0); + error |= __vmwrite(GUEST_DS_BASE, 0); + error |= __vmwrite(GUEST_FS_BASE, 0); + error |= __vmwrite(GUEST_GS_BASE, 0); + error |= __vmwrite(GUEST_CS_BASE, 0); /* Guest segment Limits */ - error |= __vmwrite(GUEST_CS_LIMIT, GUEST_SEGMENT_LIMIT); error |= __vmwrite(GUEST_ES_LIMIT, GUEST_SEGMENT_LIMIT); error |= __vmwrite(GUEST_SS_LIMIT, GUEST_SEGMENT_LIMIT); error |= __vmwrite(GUEST_DS_LIMIT, GUEST_SEGMENT_LIMIT); error |= __vmwrite(GUEST_FS_LIMIT, GUEST_SEGMENT_LIMIT); error |= __vmwrite(GUEST_GS_LIMIT, GUEST_SEGMENT_LIMIT); - - error |= __vmwrite(GUEST_IDTR_LIMIT, host_env->idtr_limit); - - /* AR bytes */ + error |= __vmwrite(GUEST_CS_LIMIT, GUEST_SEGMENT_LIMIT); + + /* Guest segment AR bytes */ arbytes.bytes = 0; arbytes.fields.seg_type = 0x3; /* type = 3 */ arbytes.fields.s = 1; /* code or data, i.e. not system */ arbytes.fields.dpl = 0; /* DPL = 3 */ arbytes.fields.p = 1; /* segment present */ arbytes.fields.default_ops_size = 1; /* 32-bit */ - arbytes.fields.g = 1; + arbytes.fields.g = 1; arbytes.fields.null_bit = 0; /* not null */ error |= __vmwrite(GUEST_ES_AR_BYTES, arbytes.bytes); @@ -328,35 +342,31 @@ arbytes.fields.seg_type = 0xb; /* type = 0xb */ error |= __vmwrite(GUEST_CS_AR_BYTES, arbytes.bytes); - error |= __vmwrite(GUEST_GDTR_BASE, regs->edx); - regs->edx = 0; - error |= __vmwrite(GUEST_GDTR_LIMIT, regs->eax); - regs->eax = 0; - + /* Guest GDT */ + error |= __vmwrite(GUEST_GDTR_BASE, 0); + error |= __vmwrite(GUEST_GDTR_LIMIT, 0); + + /* Guest IDT */ + error |= __vmwrite(GUEST_IDTR_BASE, 0); + error |= __vmwrite(GUEST_IDTR_LIMIT, 0); + + /* Guest LDT & TSS */ arbytes.fields.s = 0; /* not code or data segement */ arbytes.fields.seg_type = 0x2; /* LTD */ arbytes.fields.default_ops_size = 0; /* 16-bit */ - arbytes.fields.g = 0; + arbytes.fields.g = 0; error |= __vmwrite(GUEST_LDTR_AR_BYTES, arbytes.bytes); arbytes.fields.seg_type = 0xb; /* 32-bit TSS (busy) */ error |= __vmwrite(GUEST_TR_AR_BYTES, arbytes.bytes); /* CR3 is set in vmx_final_setup_guest */ - error |= __vmwrite(GUEST_ES_BASE, host_env->ds_base); - error |= __vmwrite(GUEST_CS_BASE, host_env->cs_base); - error |= __vmwrite(GUEST_SS_BASE, host_env->ds_base); - error |= __vmwrite(GUEST_DS_BASE, host_env->ds_base); - error |= __vmwrite(GUEST_FS_BASE, host_env->ds_base); - error |= __vmwrite(GUEST_GS_BASE, host_env->ds_base); - error |= __vmwrite(GUEST_IDTR_BASE, host_env->idtr_base); - - error |= __vmwrite(GUEST_RSP, regs->esp); + error |= __vmwrite(GUEST_RSP, 0); error |= __vmwrite(GUEST_RIP, regs->eip); + /* Guest EFLAGS */ eflags = regs->eflags & ~VMCS_EFLAGS_RESERVED_0; /* clear 0s */ eflags |= VMCS_EFLAGS_RESERVED_1; /* set 1s */ - error |= __vmwrite(GUEST_RFLAGS, eflags); error |= __vmwrite(GUEST_INTERRUPTIBILITY_INFO, 0); @@ -381,14 +391,14 @@ #if defined (__i386__) error |= __vmwrite(HOST_FS_SELECTOR, host_env->ds_selector); error |= __vmwrite(HOST_GS_SELECTOR, host_env->ds_selector); - error |= __vmwrite(HOST_FS_BASE, host_env->ds_base); - error |= __vmwrite(HOST_GS_BASE, host_env->ds_base); + error |= __vmwrite(HOST_FS_BASE, host_env->ds_base); + error |= __vmwrite(HOST_GS_BASE, host_env->ds_base); #else - rdmsrl(MSR_FS_BASE, host_env->fs_base); - rdmsrl(MSR_GS_BASE, host_env->gs_base); - error |= __vmwrite(HOST_FS_BASE, host_env->fs_base); - error |= __vmwrite(HOST_GS_BASE, host_env->gs_base); + rdmsrl(MSR_FS_BASE, host_env->fs_base); + rdmsrl(MSR_GS_BASE, host_env->gs_base); + error |= __vmwrite(HOST_FS_BASE, host_env->fs_base); + error |= __vmwrite(HOST_GS_BASE, host_env->gs_base); #endif host_env->cs_selector = __HYPERVISOR_CS; @@ -401,16 +411,16 @@ error |= __vmwrite(HOST_CR0, crn); /* same CR0 */ /* CR3 is set in vmx_final_setup_hostos */ - __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (crn) : ); + __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (crn) : ); error |= __vmwrite(HOST_CR4, crn); error |= __vmwrite(HOST_RIP, (unsigned long) vmx_asm_vmexit_handler); -#ifdef __x86_64__ - /* TBD: support cr8 for 64-bit guest */ - __vmwrite(VIRTUAL_APIC_PAGE_ADDR, 0); - __vmwrite(TPR_THRESHOLD, 0); - __vmwrite(SECONDARY_VM_EXEC_CONTROL, 0); -#endif +#ifdef __x86_64__ + /* TBD: support cr8 for 64-bit guest */ + __vmwrite(VIRTUAL_APIC_PAGE_ADDR, 0); + __vmwrite(TPR_THRESHOLD, 0); + __vmwrite(SECONDARY_VM_EXEC_CONTROL, 0); +#endif return error; } @@ -440,37 +450,37 @@ if ((error = __vmpclear (vmcs_phys_ptr))) { printk("construct_vmcs: VMCLEAR failed\n"); - return -EINVAL; + return -EINVAL; } if ((error = load_vmcs(arch_vmx, vmcs_phys_ptr))) { printk("construct_vmcs: load_vmcs failed: VMCS = %lx\n", (unsigned long) vmcs_phys_ptr); - return -EINVAL; + return -EINVAL; } if ((error = construct_vmcs_controls(arch_vmx))) { printk("construct_vmcs: construct_vmcs_controls failed\n"); - return -EINVAL; + return -EINVAL; } /* host selectors */ if ((error = construct_vmcs_host(&host_env))) { printk("construct_vmcs: construct_vmcs_host failed\n"); - return -EINVAL; + return -EINVAL; } /* guest selectors */ - if ((error = construct_init_vmcs_guest(regs, ctxt, &host_env))) { + if ((error = construct_init_vmcs_guest(regs))) { printk("construct_vmcs: construct_vmcs_guest failed\n"); - return -EINVAL; - } - - if ((error |= __vmwrite(EXCEPTION_BITMAP, + return -EINVAL; + } + + if ((error |= __vmwrite(EXCEPTION_BITMAP, MONITOR_DEFAULT_EXCEPTION_BITMAP))) { printk("construct_vmcs: setting Exception bitmap failed\n"); - return -EINVAL; + return -EINVAL; } if (regs->eflags & EF_TF) __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB); - else + else __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB); return 0; @@ -491,7 +501,7 @@ if ((error = load_vmcs(arch_vmx, vmcs_phys_ptr))) { printk("modify_vmcs: load_vmcs failed: VMCS = %lx\n", (unsigned long) vmcs_phys_ptr); - return -EINVAL; + return -EINVAL; } load_cpu_user_regs(regs); @@ -500,23 +510,23 @@ return 0; } -int load_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr) +int load_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr) { int error; if ((error = __vmptrld(phys_ptr))) { - clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); + clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); return error; } - set_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); + set_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); return 0; } -int store_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr) +int store_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr) { /* take the current VMCS */ __vmptrst(phys_ptr); - clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); + clear_bit(ARCH_VMX_VMCS_LOADED, &arch_vmx->flags); return 0; } @@ -536,7 +546,7 @@ __vmx_bug(guest_cpu_user_regs()); } -void arch_vmx_do_resume(struct vcpu *v) +void arch_vmx_do_resume(struct vcpu *v) { u64 vmcs_phys_ptr = (u64) virt_to_phys(v->arch.arch_vmx.vmcs); @@ -545,7 +555,7 @@ reset_stack_and_jump(vmx_asm_do_resume); } -void arch_vmx_do_launch(struct vcpu *v) +void arch_vmx_do_launch(struct vcpu *v) { u64 vmcs_phys_ptr = (u64) virt_to_phys(v->arch.arch_vmx.vmcs); diff -r 43edce5b75d6 -r 94c6fc048d8e xen/include/asm-x86/e820.h --- a/xen/include/asm-x86/e820.h Thu Sep 22 19:59:31 2005 +++ b/xen/include/asm-x86/e820.h Fri Sep 23 11:52:43 2005 @@ -11,6 +11,11 @@ #define E820_NVS 4 #define E820_IO 16 #define E820_SHARED_PAGE 17 +#define E820_XENSTORE 18 + +#define E820_MAP_PAGE 0x00090000 +#define E820_MAP_NR_OFFSET 0x000001E8 +#define E820_MAP_OFFSET 0x000002D0 #ifndef __ASSEMBLY__ struct e820entry { diff -r 43edce5b75d6 -r 94c6fc048d8e xen/include/asm-x86/vmx_platform.h --- a/xen/include/asm-x86/vmx_platform.h Thu Sep 22 19:59:31 2005 +++ b/xen/include/asm-x86/vmx_platform.h Fri Sep 23 11:52:43 2005 @@ -93,7 +93,6 @@ extern void handle_mmio(unsigned long, unsigned long); extern void vmx_wait_io(void); -extern int vmx_setup_platform(struct vcpu *, struct cpu_user_regs *); extern void vmx_io_assist(struct vcpu *v); // XXX - think about this -- maybe use bit 30 of the mfn to signify an MMIO frame. diff -r 43edce5b75d6 -r 94c6fc048d8e tools/examples/mem-map.sxp --- a/tools/examples/mem-map.sxp Thu Sep 22 19:59:31 2005 +++ /dev/null Fri Sep 23 11:52:43 2005 @@ -1,10 +0,0 @@ -(memmap - (0000000000000000 000000000009f800 "AddressRangeMemory" WB) - (000000000009f800 00000000000a0000 "AddressRangeReserved" UC) - (00000000000a0000 00000000000bffff "AddressRangeIO" UC) - (00000000000f0000 0000000000100000 "AddressRangeReserved" UC) - (0000000000100000 0000000008000000 "AddressRangeMemory" WB) - (0000000007fff000 0000000008000000 "AddressRangeShared" WB) - (0000000008000000 0000000008003000 "AddressRangeNVS" UC) - (0000000008003000 000000000800d000 "AddressRangeACPI" WB) - (00000000fec00000 0000000100000000 "AddressRangeIO" UC)) diff -r 43edce5b75d6 -r 94c6fc048d8e tools/libxc/linux_boot_params.h --- a/tools/libxc/linux_boot_params.h Thu Sep 22 19:59:31 2005 +++ /dev/null Fri Sep 23 11:52:43 2005 @@ -1,166 +0,0 @@ -#ifndef __LINUX_BOOT_PARAMS_H__ -#define __LINUX_BOOT_PARAMS_H__ - -#include <asm/types.h> - -#define E820MAX 32 - -struct mem_map { - int nr_map; - struct entry { - u64 addr; /* start of memory segment */ - u64 size; /* size of memory segment */ - u32 type; /* type of memory segment */ -#define E820_RAM 1 -#define E820_RESERVED 2 -#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */ -#define E820_NVS 4 -#define E820_IO 16 -#define E820_SHARED 17 -#define E820_XENSTORE 18 - - u32 caching_attr; /* used by hypervisor */ -#define MEMMAP_UC 0 -#define MEMMAP_WC 1 -#define MEMMAP_WT 4 -#define MEMMAP_WP 5 -#define MEMMAP_WB 6 - - }map[E820MAX]; -}; - -struct e820entry { - u64 addr; /* start of memory segment */ - u64 size; /* size of memory segment */ - u32 type; /* type of memory segment */ -}__attribute__((packed)); - -struct e820map { - u32 nr_map; - struct e820entry map[E820MAX]; -}__attribute__((packed)); - -struct drive_info_struct { __u8 dummy[32]; }; - -struct sys_desc_table { - __u16 length; - __u8 table[318]; -}; - -struct screen_info { - unsigned char orig_x; /* 0x00 */ - unsigned char orig_y; /* 0x01 */ - unsigned short dontuse1; /* 0x02 -- EXT_MEM_K sits here */ - unsigned short orig_video_page; /* 0x04 */ - unsigned char orig_video_mode; /* 0x06 */ - unsigned char orig_video_cols; /* 0x07 */ - unsigned short unused2; /* 0x08 */ - unsigned short orig_video_ega_bx; /* 0x0a */ - unsigned short unused3; /* 0x0c */ - unsigned char orig_video_lines; /* 0x0e */ - unsigned char orig_video_isVGA; /* 0x0f */ - unsigned short orig_video_points; /* 0x10 */ - - /* VESA graphic mode -- linear frame buffer */ - unsigned short lfb_width; /* 0x12 */ - unsigned short lfb_height; /* 0x14 */ - unsigned short lfb_depth; /* 0x16 */ - unsigned int lfb_base; /* 0x18 */ - unsigned int lfb_size; /* 0x1c */ - unsigned short dontuse2, dontuse3; /* 0x20 -- CL_MAGIC and CL_OFFSET here */ - unsigned short lfb_linelength; /* 0x24 */ - unsigned char red_size; /* 0x26 */ - unsigned char red_pos; /* 0x27 */ - unsigned char green_size; /* 0x28 */ - unsigned char green_pos; /* 0x29 */ - unsigned char blue_size; /* 0x2a */ - unsigned char blue_pos; /* 0x2b */ - unsigned char rsvd_size; /* 0x2c */ - unsigned char rsvd_pos; /* 0x2d */ - unsigned short vesapm_seg; /* 0x2e */ - unsigned short vesapm_off; /* 0x30 */ - unsigned short pages; /* 0x32 */ - /* 0x34 -- 0x3f reserved for future expansion */ -}; - -struct screen_info_overlap { - __u8 reserved1[2]; /* 0x00 */ - __u16 ext_mem_k; /* 0x02 */ - __u8 reserved2[0x20 - 0x04]; /* 0x04 */ - __u16 cl_magic; /* 0x20 */ -#define CL_MAGIC_VALUE 0xA33F - __u16 cl_offset; /* 0x22 */ - __u8 reserved3[0x40 - 0x24]; /* 0x24 */ -}; - - -struct apm_bios_info { - __u16 version; - __u16 cseg; - __u32 offset; - __u16 cseg_16; - __u16 dseg; - __u16 flags; - __u16 cseg_len; - __u16 cseg_16_len; - __u16 dseg_len; -}; - -struct linux_boot_params { - union { /* 0x00 */ - struct screen_info info; - struct screen_info_overlap overlap; - } screen; - - struct apm_bios_info apm_bios_info; /* 0x40 */ - __u8 reserved4[0x80 - 0x54]; /* 0x54 */ - struct drive_info_struct drive_info; /* 0x80 */ - struct sys_desc_table sys_desc_table; /* 0xa0 */ - __u32 alt_mem_k; /* 0x1e0 */ - __u8 reserved5[4]; /* 0x1e4 */ - __u8 e820_map_nr; /* 0x1e8 */ - __u8 reserved6[8]; /* 0x1e9 */ - __u8 setup_sects; /* 0x1f1 */ - __u16 mount_root_rdonly; /* 0x1f2 */ - __u16 syssize; /* 0x1f4 */ - __u16 swapdev; /* 0x1f6 */ - __u16 ramdisk_flags; /* 0x1f8 */ -#define RAMDISK_IMAGE_START_MASK 0x07FF -#define RAMDISK_PROMPT_FLAG 0x8000 -#define RAMDISK_LOAD_FLAG 0x4000 - __u16 vid_mode; /* 0x1fa */ - __u16 root_dev; /* 0x1fc */ - __u8 reserved9[1]; /* 0x1fe */ - __u8 aux_device_info; /* 0x1ff */ - /* 2.00+ */ - __u8 reserved10[2]; /* 0x200 */ - __u8 header_magic[4]; /* 0x202 */ - __u16 protocol_version; /* 0x206 */ - __u8 reserved11[8]; /* 0x208 */ - __u8 loader_type; /* 0x210 */ -#define LOADER_TYPE_LOADLIN 1 -#define LOADER_TYPE_BOOTSECT_LOADER 2 -#define LOADER_TYPE_SYSLINUX 3 -#define LOADER_TYPE_ETHERBOOT 4 -#define LOADER_TYPE_UNKNOWN 0xFF - __u8 loader_flags; /* 0x211 */ - __u8 reserved12[2]; /* 0x212 */ - __u32 code32_start; /* 0x214 */ - __u32 initrd_start; /* 0x218 */ - __u32 initrd_size; /* 0x21c */ - __u8 reserved13[4]; /* 0x220 */ - /* 2.01+ */ - __u16 heap_end_ptr; /* 0x224 */ - __u8 reserved14[2]; /* 0x226 */ - /* 2.02+ */ - __u32 cmd_line_ptr; /* 0x228 */ - /* 2.03+ */ - __u32 ramdisk_max; /* 0x22c */ - __u8 reserved15[0x2d0 - 0x230]; /* 0x230 */ - struct e820entry e820_map[E820MAX]; /* 0x2d0 */ - __u64 shared_info; /* 0x550 */ - __u8 padding[0x800 - 0x558]; /* 0x558 */ - __u8 cmd_line[0x800]; /* 0x800 */ -} __attribute__((packed)); - -#endif /* __LINUX_BOOT_PARAMS_H__ */ diff -r 43edce5b75d6 -r 94c6fc048d8e tools/python/xen/util/memmap.py --- a/tools/python/xen/util/memmap.py Thu Sep 22 19:59:31 2005 +++ /dev/null Fri Sep 23 11:52:43 2005 @@ -1,41 +0,0 @@ -mem_caching_attr = { - 'UC' : 0, - 'WC' : 1, - 'WT' : 4, - 'WP' : 5, - 'WB' : 6, - }; - -e820_mem_type = { - 'AddressRangeMemory' : 1, - 'AddressRangeReserved' : 2, - 'AddressRangeACPI' : 3, - 'AddressRangeNVS' : 4, - 'AddressRangeIO' : 16, - 'AddressRangeShared' : 17, -}; - -MT_COL = 2 -MA_COL = 3 - -def strmap(row): - if (type(row) != type([])): - return row - row[MT_COL] = e820_mem_type[row[MT_COL]] - row[MA_COL] = mem_caching_attr[row[MA_COL]] - return row - -def memmap_parse(memmap): - return map(strmap, memmap) - -if __name__ == '__main__': - memmap = [ 'memmap', - [ '1', '2', 'AddressRangeMemory', 'UC'], - [ '1', '2', 'AddressRangeReserved', 'UC'], - [ '1', '2', 'AddressRangeACPI', 'WB'], - [ '1', '2', 'AddressRangeNVS', 'WB'], - [ '1', '2', 'AddressRangeIO', 'WB'], - [ '1', '2', 'AddressRangeShared', 'WB']] - print memmap_parse(memmap); - - _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |