debuggers.hg

view tools/ioemu/patches/xen-mm @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 Index: ioemu/hw/pc.c
2 ===================================================================
3 --- ioemu.orig/hw/pc.c 2007-05-03 19:08:13.000000000 +0100
4 +++ ioemu/hw/pc.c 2007-05-03 19:08:19.000000000 +0100
5 @@ -481,7 +481,9 @@
6 }
8 /* allocate RAM */
9 +#ifndef CONFIG_DM /* HVM domain owns memory */
10 cpu_register_physical_memory(0, ram_size, 0);
11 +#endif
13 /* BIOS load */
14 bios_offset = ram_size + vga_ram_size;
15 @@ -510,8 +512,10 @@
16 ret = load_image(buf, phys_ram_base + vga_bios_offset);
18 /* setup basic memory access */
19 +#ifndef CONFIG_DM /* HVM domain owns memory */
20 cpu_register_physical_memory(0xc0000, 0x10000,
21 vga_bios_offset | IO_MEM_ROM);
22 +#endif
24 /* map the last 128KB of the BIOS in ISA space */
25 isa_bios_size = bios_size;
26 Index: ioemu/vl.c
27 ===================================================================
28 --- ioemu.orig/vl.c 2007-05-03 19:08:13.000000000 +0100
29 +++ ioemu/vl.c 2007-05-03 19:08:57.000000000 +0100
30 @@ -89,6 +89,7 @@
32 #include "exec-all.h"
34 +#include <xen/hvm/params.h>
35 #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
36 #ifdef __sun__
37 #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
38 @@ -175,6 +176,8 @@
39 int semihosting_enabled = 0;
40 int autostart = 1;
42 +int xc_handle;
43 +
44 char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'};
45 extern int domid;
47 @@ -6565,6 +6568,9 @@
48 char usb_devices[MAX_USB_CMDLINE][128];
49 int usb_devices_index;
50 int fds[2];
51 + unsigned long ioreq_pfn;
52 + extern void *shared_page;
53 + unsigned long nr_pages;
55 char qemu_dm_logfilename[64];
57 @@ -6839,11 +6845,13 @@
58 ram_size = atol(optarg) * 1024 * 1024;
59 if (ram_size <= 0)
60 help();
61 +#ifndef CONFIG_DM
62 if (ram_size > PHYS_RAM_MAX_SIZE) {
63 fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n",
64 PHYS_RAM_MAX_SIZE / (1024 * 1024));
65 exit(1);
66 }
67 +#endif /* !CONFIG_DM */
68 break;
69 case QEMU_OPTION_l:
70 {
71 @@ -7153,12 +7161,53 @@
72 phys_ram_size += ret;
73 }
75 +#ifdef CONFIG_DM
76 +
77 + xc_handle = xc_interface_open();
78 +
79 +#if defined(__i386__) || defined(__x86_64__)
80 +
81 + nr_pages = ram_size/PAGE_SIZE;
82 +
83 + page_array = (xen_pfn_t *)malloc(nr_pages * sizeof(xen_pfn_t));
84 + if (page_array == NULL) {
85 + fprintf(logfile, "malloc returned error %d\n", errno);
86 + exit(-1);
87 + }
88 +
89 + for ( i = 0; i < nr_pages; i++)
90 + page_array[i] = i;
91 +
92 + phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
93 + PROT_READ|PROT_WRITE, page_array,
94 + nr_pages);
95 + if (phys_ram_base == NULL) {
96 + fprintf(logfile, "batch map guest memory returned error %d\n", errno);
97 + exit(-1);
98 + }
99 +
100 + xc_get_hvm_param(xc_handle, domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
101 + fprintf(logfile, "shared page at pfn %lx\n", ioreq_pfn);
102 + shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
103 + PROT_READ|PROT_WRITE,
104 + page_array[ioreq_pfn]);
105 + if (shared_page == NULL) {
106 + fprintf(logfile, "map shared IO page returned error %d\n", errno);
107 + exit(-1);
108 + }
109 +
110 + free(page_array);
111 +
112 +#else /* !CONFIG_DM */
113 +
114 phys_ram_base = qemu_vmalloc(phys_ram_size);
115 if (!phys_ram_base) {
116 fprintf(stderr, "Could not allocate physical memory\n");
117 exit(1);
118 }
120 +#endif /* !CONFIG_DM */
121 +
122 /* we always create the cdrom drive, even if no disk is there */
123 bdrv_init();
124 if (cdrom_index >= 0) {
125 Index: ioemu/vl.h
126 ===================================================================
127 --- ioemu.orig/vl.h 2007-05-03 19:08:13.000000000 +0100
128 +++ ioemu/vl.h 2007-05-03 19:08:19.000000000 +0100
129 @@ -39,6 +39,7 @@
130 #include <sys/stat.h>
131 #include "xenctrl.h"
132 #include "xs.h"
133 +#include <xen/hvm/e820.h>
135 #ifndef O_LARGEFILE
136 #define O_LARGEFILE 0