mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
[qemu patches] Update patches upto changeset 12814:c3ad3fcfe3.
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
This commit is contained in:
1 parent
2802359071
commit
a456fc7666
5 files changed
+495
-19
No files matched your search
@@ -1,7 +1,7 @@
|
||||
Index: ioemu/hw/mc146818rtc.c
|
||||
===================================================================
|
||||
--- ioemu.orig/hw/mc146818rtc.c 2006-12-08 18:23:40.000000000 +0000
|
||||
+++ ioemu/hw/mc146818rtc.c 2006-12-08 18:23:46.000000000 +0000
|
||||
--- ioemu.orig/hw/mc146818rtc.c 2006-12-08 18:36:31.000000000 +0000
|
||||
+++ ioemu/hw/mc146818rtc.c 2006-12-08 18:36:36.000000000 +0000
|
||||
@@ -178,10 +178,27 @@
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,8 @@ Index: ioemu/hw/mc146818rtc.c
|
||||
static void rtc_copy_date(RTCState *s)
|
||||
Index: ioemu/hw/pc.c
|
||||
===================================================================
|
||||
--- ioemu.orig/hw/pc.c 2006-12-08 18:23:46.000000000 +0000
|
||||
+++ ioemu/hw/pc.c 2006-12-08 18:23:46.000000000 +0000
|
||||
--- ioemu.orig/hw/pc.c 2006-12-08 18:36:35.000000000 +0000
|
||||
+++ ioemu/hw/pc.c 2006-12-08 18:36:36.000000000 +0000
|
||||
@@ -159,7 +159,7 @@
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ Index: ioemu/hw/pc.c
|
||||
QEMUMachine pc_machine = {
|
||||
Index: ioemu/vl.c
|
||||
===================================================================
|
||||
--- ioemu.orig/vl.c 2006-12-08 18:23:46.000000000 +0000
|
||||
+++ ioemu/vl.c 2006-12-08 18:23:46.000000000 +0000
|
||||
--- ioemu.orig/vl.c 2006-12-08 18:36:35.000000000 +0000
|
||||
+++ ioemu/vl.c 2006-12-08 18:36:36.000000000 +0000
|
||||
@@ -163,6 +163,8 @@
|
||||
|
||||
int xc_handle;
|
||||
@@ -174,8 +174,8 @@ Index: ioemu/vl.c
|
||||
if (usb_enabled) {
|
||||
Index: ioemu/vl.h
|
||||
===================================================================
|
||||
--- ioemu.orig/vl.h 2006-12-08 18:23:46.000000000 +0000
|
||||
+++ ioemu/vl.h 2006-12-08 18:23:46.000000000 +0000
|
||||
--- ioemu.orig/vl.h 2006-12-08 18:36:35.000000000 +0000
|
||||
+++ ioemu/vl.h 2006-12-08 18:36:36.000000000 +0000
|
||||
@@ -576,7 +576,7 @@
|
||||
int boot_device,
|
||||
DisplayState *ds, const char **fd_filename, int snapshot,
|
||||
|
||||
@@ -67,3 +67,5 @@ usb-uhci-buffer-size
|
||||
vnc-monitor-shift-key-processing
|
||||
ide-error-reporting
|
||||
vnc-numpad-handling
|
||||
xen-mapcache -p3
|
||||
usb-mouse-tablet-status-check -p3
|
||||
@@ -22,8 +22,8 @@ Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
|
||||
|
||||
Index: ioemu/Makefile.target
|
||||
===================================================================
|
||||
--- ioemu.orig/Makefile.target 2006-12-08 18:20:53.000000000 +0000
|
||||
+++ ioemu/Makefile.target 2006-12-08 18:21:18.000000000 +0000
|
||||
--- ioemu.orig/Makefile.target 2006-12-08 18:33:48.000000000 +0000
|
||||
+++ ioemu/Makefile.target 2006-12-08 18:35:14.000000000 +0000
|
||||
@@ -369,6 +369,7 @@
|
||||
VL_OBJS+= piix4acpi.o
|
||||
VL_OBJS+= xenstore.o
|
||||
@@ -34,8 +34,8 @@ Index: ioemu/Makefile.target
|
||||
ifeq ($(TARGET_BASE_ARCH), ppc)
|
||||
Index: ioemu/hw/pc.c
|
||||
===================================================================
|
||||
--- ioemu.orig/hw/pc.c 2006-12-08 18:20:52.000000000 +0000
|
||||
+++ ioemu/hw/pc.c 2006-12-08 18:21:18.000000000 +0000
|
||||
--- ioemu.orig/hw/pc.c 2006-12-08 18:33:47.000000000 +0000
|
||||
+++ ioemu/hw/pc.c 2006-12-08 18:33:48.000000000 +0000
|
||||
@@ -875,6 +875,9 @@
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,8 @@ Index: ioemu/hw/pc.c
|
||||
Index: ioemu/hw/tpm_tis.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ ioemu/hw/tpm_tis.c 2006-12-08 18:21:18.000000000 +0000
|
||||
@@ -0,0 +1,1114 @@
|
||||
+++ ioemu/hw/tpm_tis.c 2006-12-08 18:35:25.000000000 +0000
|
||||
@@ -0,0 +1,1120 @@
|
||||
+/*
|
||||
+ * tpm_tis.c - QEMU emulator for a 1.2 TPM with TIS interface
|
||||
+ *
|
||||
@@ -185,7 +185,7 @@ Index: ioemu/hw/tpm_tis.c
|
||||
+
|
||||
+
|
||||
+/* local prototypes */
|
||||
+static int TPM_Send(tpmState *s, tpmBuffer *buffer, char *msg);
|
||||
+static int TPM_Send(tpmState *s, tpmBuffer *buffer, uint8_t locty, char *msg);
|
||||
+static int TPM_Receive(tpmState *s, tpmBuffer *buffer);
|
||||
+static uint32_t vtpm_instance_from_xenstore(void);
|
||||
+static void tis_poll_timer(void *opaque);
|
||||
@@ -324,6 +324,8 @@ Index: ioemu/hw/tpm_tis.c
|
||||
+/*
|
||||
+ * the 'write' method for sending requests to the vTPM
|
||||
+ * four bytes with the vTPM instance number are prepended to each request
|
||||
+ * the locality in which the command was sent is transmitted in the
|
||||
+ * highest 3 bits
|
||||
+ */
|
||||
+static int write_local_socket(tpmState *s, const tpmBuffer *buffer)
|
||||
+{
|
||||
@@ -661,7 +663,7 @@ Index: ioemu/hw/tpm_tis.c
|
||||
+ }
|
||||
+ }
|
||||
+ if (val & STS_TPM_GO) {
|
||||
+ n = TPM_Send(s, &s->buffer,"tpm_data_write");
|
||||
+ n = TPM_Send(s, &s->buffer, locty, "tpm_data_write");
|
||||
+ if (n > 0) {
|
||||
+ /* sending of data was successful */
|
||||
+ s->offset = 0;
|
||||
@@ -968,7 +970,7 @@ Index: ioemu/hw/tpm_tis.c
|
||||
+/*
|
||||
+ * Send a TPM request.
|
||||
+ */
|
||||
+static int TPM_Send(tpmState *s, tpmBuffer *buffer, char *msg)
|
||||
+static int TPM_Send(tpmState *s, tpmBuffer *buffer, uint8_t locty, char *msg)
|
||||
+{
|
||||
+ int len;
|
||||
+ uint32_t size = tpm_get_size_from_buffer(buffer->buf);
|
||||
@@ -998,6 +1000,10 @@ Index: ioemu/hw/tpm_tis.c
|
||||
+ showBuff(buffer->buf, "To TPM");
|
||||
+#endif
|
||||
+
|
||||
+ /* transmit the locality in the highest 3 bits */
|
||||
+ buffer->instance[0] &= 0x1f;
|
||||
+ buffer->instance[0] |= (locty << 5);
|
||||
+
|
||||
+ len = vTPMTransmit[s->Transmitlayer].write(s, buffer);
|
||||
+ if (len < 0) {
|
||||
+ s->Transmitlayer = -1;
|
||||
@@ -1167,8 +1173,8 @@ Index: ioemu/hw/tpm_tis.c
|
||||
+}
|
||||
Index: ioemu/vl.h
|
||||
===================================================================
|
||||
--- ioemu.orig/vl.h 2006-12-08 18:20:53.000000000 +0000
|
||||
+++ ioemu/vl.h 2006-12-08 18:21:18.000000000 +0000
|
||||
--- ioemu.orig/vl.h 2006-12-08 18:33:48.000000000 +0000
|
||||
+++ ioemu/vl.h 2006-12-08 18:35:14.000000000 +0000
|
||||
@@ -932,6 +932,10 @@
|
||||
void piix4_pm_init(PCIBus *bus, int devfn);
|
||||
void acpi_bios_init(void);
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
# HG changeset patch
|
||||
# User kfraser@localhost.localdomain
|
||||
# Node ID 60bbcf799384d779c2a561b9d9ba30f28e31d970
|
||||
# Parent fb3cb6f52a2905be938559529ae43b6ba990c878
|
||||
[HVM] qemu mouse: Adds support for USB mouse/tablet status check and
|
||||
restricts Universal Host Controller interrupt generating when received
|
||||
NAK in interrupt transfer.
|
||||
|
||||
According to usb spec, USB mouse/tablet device returns NAK to host
|
||||
controller if its status does not alter in interrupt transfer.
|
||||
And UHC should leave a TD active when receiving NAK and execute this
|
||||
incompleted TD in a subseqent frame. UHC only generates an interrupt
|
||||
on complete after the TD with ICO bit is completed.
|
||||
|
||||
This patch make UHC & USB mouse/tablet behave consistently with spec.
|
||||
|
||||
Signed-off-by: Xinmei Huang <xinmei.huang@intel.com>
|
||||
|
||||
diff -r fb3cb6f52a29 -r 60bbcf799384 tools/ioemu/hw/usb-hid.c
|
||||
--- a/tools/ioemu/hw/usb-hid.c Thu Dec 07 11:51:22 2006 +0000
|
||||
+++ b/tools/ioemu/hw/usb-hid.c Thu Dec 07 11:52:26 2006 +0000
|
||||
@@ -39,6 +39,7 @@ typedef struct USBMouseState {
|
||||
int x, y;
|
||||
int kind;
|
||||
int mouse_grabbed;
|
||||
+ int status_changed;
|
||||
} USBMouseState;
|
||||
|
||||
/* mostly the same values as the Bochs USB Mouse device */
|
||||
@@ -231,6 +232,7 @@ static void usb_mouse_event(void *opaque
|
||||
s->dy += dy1;
|
||||
s->dz += dz1;
|
||||
s->buttons_state = buttons_state;
|
||||
+ s->status_changed = 1;
|
||||
}
|
||||
|
||||
static void usb_tablet_event(void *opaque,
|
||||
@@ -242,6 +244,7 @@ static void usb_tablet_event(void *opaqu
|
||||
s->y = y;
|
||||
s->dz += dz;
|
||||
s->buttons_state = buttons_state;
|
||||
+ s->status_changed = 1;
|
||||
}
|
||||
|
||||
static inline int int_clamp(int val, int vmin, int vmax)
|
||||
@@ -483,10 +486,16 @@ static int usb_mouse_handle_data(USBDevi
|
||||
switch(pid) {
|
||||
case USB_TOKEN_IN:
|
||||
if (devep == 1) {
|
||||
- if (s->kind == USB_MOUSE)
|
||||
- ret = usb_mouse_poll(s, data, len);
|
||||
- else if (s->kind == USB_TABLET)
|
||||
- ret = usb_tablet_poll(s, data, len);
|
||||
+ if (s->kind == USB_MOUSE)
|
||||
+ ret = usb_mouse_poll(s, data, len);
|
||||
+ else if (s->kind == USB_TABLET)
|
||||
+ ret = usb_tablet_poll(s, data, len);
|
||||
+
|
||||
+ if (!s->status_changed)
|
||||
+ ret = USB_RET_NAK;
|
||||
+ else
|
||||
+ s->status_changed = 0;
|
||||
+
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
@@ -523,6 +532,7 @@ USBDevice *usb_tablet_init(void)
|
||||
s->dev.handle_data = usb_mouse_handle_data;
|
||||
s->dev.handle_destroy = usb_mouse_handle_destroy;
|
||||
s->kind = USB_TABLET;
|
||||
+ s->status_changed = 0;
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Tablet");
|
||||
|
||||
@@ -544,6 +554,7 @@ USBDevice *usb_mouse_init(void)
|
||||
s->dev.handle_data = usb_mouse_handle_data;
|
||||
s->dev.handle_destroy = usb_mouse_handle_destroy;
|
||||
s->kind = USB_MOUSE;
|
||||
+ s->status_changed = 0;
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Mouse");
|
||||
|
||||
diff -r fb3cb6f52a29 -r 60bbcf799384 tools/ioemu/hw/usb-uhci.c
|
||||
--- a/tools/ioemu/hw/usb-uhci.c Thu Dec 07 11:51:22 2006 +0000
|
||||
+++ b/tools/ioemu/hw/usb-uhci.c Thu Dec 07 11:52:26 2006 +0000
|
||||
@@ -424,12 +424,10 @@ static int uhci_handle_td(UHCIState *s,
|
||||
uint8_t buf[2048];
|
||||
int len, max_len, err, ret;
|
||||
|
||||
- if (td->ctrl & TD_CTRL_IOC) {
|
||||
- *int_mask |= 0x01;
|
||||
- }
|
||||
-
|
||||
- if (!(td->ctrl & TD_CTRL_ACTIVE))
|
||||
- return 1;
|
||||
+ if (!(td->ctrl & TD_CTRL_ACTIVE)){
|
||||
+ ret = 1;
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
/* TD is active */
|
||||
max_len = ((td->token >> 21) + 1) & 0x7ff;
|
||||
@@ -467,7 +465,8 @@ static int uhci_handle_td(UHCIState *s,
|
||||
/* invalid pid : frame interrupted */
|
||||
s->status |= UHCI_STS_HCPERR;
|
||||
uhci_update_irq(s);
|
||||
- return -1;
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
}
|
||||
if (td->ctrl & TD_CTRL_IOS)
|
||||
td->ctrl &= ~TD_CTRL_ACTIVE;
|
||||
@@ -479,10 +478,12 @@ static int uhci_handle_td(UHCIState *s,
|
||||
len < max_len) {
|
||||
*int_mask |= 0x02;
|
||||
/* short packet: do not update QH */
|
||||
- return 1;
|
||||
+ ret = 1;
|
||||
+ goto out;
|
||||
} else {
|
||||
/* success */
|
||||
- return 0;
|
||||
+ ret = 0;
|
||||
+ goto out;
|
||||
}
|
||||
} else {
|
||||
switch(ret) {
|
||||
@@ -501,23 +502,34 @@ static int uhci_handle_td(UHCIState *s,
|
||||
}
|
||||
td->ctrl = (td->ctrl & ~(3 << TD_CTRL_ERROR_SHIFT)) |
|
||||
(err << TD_CTRL_ERROR_SHIFT);
|
||||
- return 1;
|
||||
+ ret = 1;
|
||||
+ goto out;
|
||||
case USB_RET_NAK:
|
||||
td->ctrl |= TD_CTRL_NAK;
|
||||
if (pid == USB_TOKEN_SETUP)
|
||||
goto do_timeout;
|
||||
- return 1;
|
||||
+ ret = 1;
|
||||
+ goto out;
|
||||
case USB_RET_STALL:
|
||||
td->ctrl |= TD_CTRL_STALL;
|
||||
td->ctrl &= ~TD_CTRL_ACTIVE;
|
||||
- return 1;
|
||||
+ ret = 1;
|
||||
+ goto out;
|
||||
case USB_RET_BABBLE:
|
||||
td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
|
||||
td->ctrl &= ~TD_CTRL_ACTIVE;
|
||||
/* frame interrupted */
|
||||
- return -1;
|
||||
- }
|
||||
- }
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+out:
|
||||
+ /* If TD is inactive and IOC bit set to 1 then update int_mask */
|
||||
+ if ((td->ctrl & TD_CTRL_IOC) && (!(td->ctrl & TD_CTRL_ACTIVE))) {
|
||||
+ *int_mask |= 0x01;
|
||||
+ }
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static void uhci_frame_timer(void *opaque)
|
||||
@@ -0,0 +1,300 @@
|
||||
# HG changeset patch
|
||||
# User kfraser@localhost.localdomain
|
||||
# Node ID 67a06a9b7b1dca707e1cd3b08ae0a341d6e97b3d
|
||||
# Parent 3f0ca90351e268084fbdb733d70fc596cb46537d
|
||||
[HVM] qemu: Add guest address-space mapping cache.
|
||||
|
||||
On IA32 host or IA32 PAE host, at present, generally, we can't create
|
||||
an HVM guest with more than 2G memory, because generally it's almost
|
||||
impossible for Qemu to find a large enough and consecutive virtual
|
||||
address space to map an HVM guest's whole physical address space.
|
||||
The attached patch fixes this issue using dynamic mapping based on
|
||||
little blocks of memory.
|
||||
|
||||
Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
|
||||
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
|
||||
Signed-off-by: Keir Fraser <keir@xensource.com>
|
||||
|
||||
diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/target-i386-dm/cpu.h
|
||||
--- a/tools/ioemu/target-i386-dm/cpu.h Thu Dec 07 10:54:43 2006 +0000
|
||||
+++ b/tools/ioemu/target-i386-dm/cpu.h Thu Dec 07 11:12:52 2006 +0000
|
||||
@@ -25,7 +25,8 @@
|
||||
#ifdef TARGET_X86_64
|
||||
#define TARGET_LONG_BITS 64
|
||||
#else
|
||||
-#define TARGET_LONG_BITS 32
|
||||
+/* #define TARGET_LONG_BITS 32 */
|
||||
+#define TARGET_LONG_BITS 64 /* for Qemu map cache */
|
||||
#endif
|
||||
|
||||
/* target supports implicit self modifying code */
|
||||
diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/target-i386-dm/exec-dm.c
|
||||
--- a/tools/ioemu/target-i386-dm/exec-dm.c Thu Dec 07 10:54:43 2006 +0000
|
||||
+++ b/tools/ioemu/target-i386-dm/exec-dm.c Thu Dec 07 11:12:52 2006 +0000
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "exec-all.h"
|
||||
+#include "vl.h"
|
||||
|
||||
//#define DEBUG_TB_INVALIDATE
|
||||
//#define DEBUG_FLUSH
|
||||
@@ -426,6 +427,12 @@ static inline int paddr_is_ram(target_ph
|
||||
#endif
|
||||
}
|
||||
|
||||
+#if defined(__i386__) || defined(__x86_64__)
|
||||
+#define phys_ram_addr(x) (qemu_map_cache(x))
|
||||
+#elif defined(__ia64__)
|
||||
+#define phys_ram_addr(x) (phys_ram_base + (x))
|
||||
+#endif
|
||||
+
|
||||
void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
|
||||
int len, int is_write)
|
||||
{
|
||||
@@ -438,7 +445,7 @@ void cpu_physical_memory_rw(target_phys_
|
||||
l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK);
|
||||
if (l > len)
|
||||
l = len;
|
||||
-
|
||||
+
|
||||
io_index = iomem_index(addr);
|
||||
if (is_write) {
|
||||
if (io_index) {
|
||||
@@ -460,9 +467,10 @@ void cpu_physical_memory_rw(target_phys_
|
||||
}
|
||||
} else if (paddr_is_ram(addr)) {
|
||||
/* Reading from RAM */
|
||||
- memcpy(phys_ram_base + addr, buf, l);
|
||||
+ ptr = phys_ram_addr(addr);
|
||||
+ memcpy(ptr, buf, l);
|
||||
#ifdef __ia64__
|
||||
- sync_icache((unsigned long)(phys_ram_base + addr), l);
|
||||
+ sync_icache(ptr, l);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
@@ -485,7 +493,8 @@ void cpu_physical_memory_rw(target_phys_
|
||||
}
|
||||
} else if (paddr_is_ram(addr)) {
|
||||
/* Reading from RAM */
|
||||
- memcpy(buf, phys_ram_base + addr, l);
|
||||
+ ptr = phys_ram_addr(addr);
|
||||
+ memcpy(buf, ptr, l);
|
||||
} else {
|
||||
/* Neither RAM nor known MMIO space */
|
||||
memset(buf, 0xff, len);
|
||||
diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/vl.c
|
||||
--- a/tools/ioemu/vl.c Thu Dec 07 10:54:43 2006 +0000
|
||||
+++ b/tools/ioemu/vl.c Thu Dec 07 11:12:52 2006 +0000
|
||||
@@ -5807,6 +5807,92 @@ int set_mm_mapping(int xc_handle, uint32
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+#if defined(__i386__) || defined(__x86_64__)
|
||||
+static struct map_cache *mapcache_entry;
|
||||
+static unsigned long nr_buckets;
|
||||
+
|
||||
+static int qemu_map_cache_init(unsigned long nr_pages)
|
||||
+{
|
||||
+ unsigned long max_pages = MAX_MCACHE_SIZE >> PAGE_SHIFT;
|
||||
+ int i;
|
||||
+
|
||||
+ if (nr_pages < max_pages)
|
||||
+ max_pages = nr_pages;
|
||||
+
|
||||
+ nr_buckets = (max_pages << PAGE_SHIFT) >> MCACHE_BUCKET_SHIFT;
|
||||
+
|
||||
+ fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
|
||||
+
|
||||
+ mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
|
||||
+ if (mapcache_entry == NULL) {
|
||||
+ errno = ENOMEM;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ memset(mapcache_entry, 0, nr_buckets * sizeof(struct map_cache));
|
||||
+
|
||||
+ /*
|
||||
+ * To avoid ENOMEM from xc_map_foreign_batch() at runtime, we
|
||||
+ * pre-fill all the map caches in advance.
|
||||
+ */
|
||||
+ for (i = 0; i < nr_buckets; i++)
|
||||
+ (void)qemu_map_cache(((target_phys_addr_t)i) << MCACHE_BUCKET_SHIFT);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+uint8_t *qemu_map_cache(target_phys_addr_t phys_addr)
|
||||
+{
|
||||
+ struct map_cache *entry;
|
||||
+ unsigned long address_index = phys_addr >> MCACHE_BUCKET_SHIFT;
|
||||
+ unsigned long address_offset = phys_addr & (MCACHE_BUCKET_SIZE-1);
|
||||
+
|
||||
+ /* For most cases (>99.9%), the page address is the same. */
|
||||
+ static unsigned long last_address_index = ~0UL;
|
||||
+ static uint8_t *last_address_vaddr;
|
||||
+
|
||||
+ if (address_index == last_address_index)
|
||||
+ return last_address_vaddr + address_offset;
|
||||
+
|
||||
+ entry = &mapcache_entry[address_index % nr_buckets];
|
||||
+
|
||||
+ if (entry->vaddr_base == NULL || entry->paddr_index != address_index)
|
||||
+ {
|
||||
+ /* We need to remap a bucket. */
|
||||
+ uint8_t *vaddr_base;
|
||||
+ unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ if (entry->vaddr_base != NULL) {
|
||||
+ errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
|
||||
+ if (errno) {
|
||||
+ fprintf(logfile, "unmap fails %d\n", errno);
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < MCACHE_BUCKET_SIZE >> PAGE_SHIFT; i++)
|
||||
+ pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-PAGE_SHIFT)) + i;
|
||||
+
|
||||
+ vaddr_base = xc_map_foreign_batch(
|
||||
+ xc_handle, domid, PROT_READ|PROT_WRITE,
|
||||
+ pfns, MCACHE_BUCKET_SIZE >> PAGE_SHIFT);
|
||||
+ if (vaddr_base == NULL) {
|
||||
+ fprintf(logfile, "xc_map_foreign_batch error %d\n", errno);
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ entry->vaddr_base = vaddr_base;
|
||||
+ entry->paddr_index = address_index;;
|
||||
+ }
|
||||
+
|
||||
+ last_address_index = address_index;
|
||||
+ last_address_vaddr = entry->vaddr_base;
|
||||
+
|
||||
+ return last_address_vaddr + address_offset;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -6130,6 +6216,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
case QEMU_OPTION_m:
|
||||
ram_size = atol(optarg) * 1024 * 1024;
|
||||
+ ram_size = (uint64_t)atol(optarg) * 1024 * 1024;
|
||||
if (ram_size <= 0)
|
||||
help();
|
||||
#ifndef CONFIG_DM
|
||||
@@ -6400,50 +6487,41 @@ int main(int argc, char **argv)
|
||||
shared_page_nr = nr_pages - 1;
|
||||
#endif
|
||||
|
||||
+#if defined(__i386__) || defined(__x86_64__)
|
||||
+
|
||||
+ if ( qemu_map_cache_init(tmp_nr_pages) )
|
||||
+ {
|
||||
+ fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
|
||||
+ PROT_READ|PROT_WRITE, shared_page_nr);
|
||||
+ if (shared_page == NULL) {
|
||||
+ fprintf(logfile, "map shared IO page returned error %d\n", errno);
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ fprintf(logfile, "shared page at pfn:%lx\n", shared_page_nr);
|
||||
+
|
||||
+ buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
|
||||
+ PROT_READ|PROT_WRITE,
|
||||
+ shared_page_nr - 2);
|
||||
+ if (buffered_io_page == NULL) {
|
||||
+ fprintf(logfile, "map buffered IO page returned error %d\n", errno);
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ fprintf(logfile, "buffered io page at pfn:%lx\n", shared_page_nr - 2);
|
||||
+
|
||||
+#elif defined(__ia64__)
|
||||
+
|
||||
page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
|
||||
if (page_array == NULL) {
|
||||
fprintf(logfile, "malloc returned error %d\n", errno);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
-#if defined(__i386__) || defined(__x86_64__)
|
||||
- for ( i = 0; i < tmp_nr_pages; i++)
|
||||
- page_array[i] = i;
|
||||
-
|
||||
- phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
|
||||
- PROT_READ|PROT_WRITE, page_array,
|
||||
- tmp_nr_pages);
|
||||
- if (phys_ram_base == NULL) {
|
||||
- fprintf(logfile, "batch map guest memory returned error %d\n", errno);
|
||||
- exit(-1);
|
||||
- }
|
||||
-
|
||||
- shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
|
||||
- PROT_READ|PROT_WRITE,
|
||||
- page_array[shared_page_nr]);
|
||||
- if (shared_page == NULL) {
|
||||
- fprintf(logfile, "map shared IO page returned error %d\n", errno);
|
||||
- exit(-1);
|
||||
- }
|
||||
-
|
||||
- fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n",
|
||||
- shared_page_nr, (uint64_t)(page_array[shared_page_nr]));
|
||||
-
|
||||
- buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
|
||||
- PROT_READ|PROT_WRITE,
|
||||
- page_array[shared_page_nr - 2]);
|
||||
- if (buffered_io_page == NULL) {
|
||||
- fprintf(logfile, "map buffered IO page returned error %d\n", errno);
|
||||
- exit(-1);
|
||||
- }
|
||||
-
|
||||
- fprintf(logfile, "buffered io page at pfn:%lx, mfn: %"PRIx64"\n",
|
||||
- shared_page_nr - 2, (uint64_t)(page_array[shared_page_nr - 2]));
|
||||
-
|
||||
- free(page_array);
|
||||
-
|
||||
-#elif defined(__ia64__)
|
||||
-
|
||||
if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
|
||||
IO_PAGE_START >> PAGE_SHIFT, 3) != 3) {
|
||||
fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
|
||||
diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/vl.h
|
||||
--- a/tools/ioemu/vl.h Thu Dec 07 10:54:43 2006 +0000
|
||||
+++ b/tools/ioemu/vl.h Thu Dec 07 11:12:52 2006 +0000
|
||||
@@ -156,6 +156,26 @@ extern void *shared_vram;
|
||||
|
||||
extern FILE *logfile;
|
||||
|
||||
+
|
||||
+#if defined(__i386__) || defined(__x86_64__)
|
||||
+#if defined(__i386__)
|
||||
+#define MAX_MCACHE_SIZE 0x40000000 /* 1GB max for x86 */
|
||||
+#define MCACHE_BUCKET_SHIFT 16
|
||||
+#elif defined(__x86_64__)
|
||||
+#define MAX_MCACHE_SIZE 0x1000000000 /* 64GB max for x86_64 */
|
||||
+#define MCACHE_BUCKET_SHIFT 20
|
||||
+#endif
|
||||
+
|
||||
+#define MCACHE_BUCKET_SIZE (1UL << MCACHE_BUCKET_SHIFT)
|
||||
+
|
||||
+struct map_cache {
|
||||
+ unsigned long paddr_index;
|
||||
+ uint8_t *vaddr_base;
|
||||
+};
|
||||
+
|
||||
+uint8_t *qemu_map_cache(target_phys_addr_t phys_addr);
|
||||
+#endif
|
||||
+
|
||||
extern int xc_handle;
|
||||
extern int domid;
|
||||
|
||||