[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [IOEMU] Locking needed to access mapcache.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 0946c90c11056954f041cecb81fa03000f878926
# Parent  65c3287306dbcfb809cc12a48111c4ca7ed7428f
[IOEMU] Locking needed to access mapcache.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/ioemu/target-i386-dm/exec-dm.c |   11 ++++++++++-
 tools/ioemu/vl.c                     |    7 +++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff -r 65c3287306db -r 0946c90c1105 tools/ioemu/target-i386-dm/exec-dm.c
--- a/tools/ioemu/target-i386-dm/exec-dm.c      Wed Dec 13 10:24:20 2006 +0000
+++ b/tools/ioemu/target-i386-dm/exec-dm.c      Wed Dec 13 11:01:33 2006 +0000
@@ -439,7 +439,12 @@ void cpu_physical_memory_rw(target_phys_
     int l, io_index;
     uint8_t *ptr;
     uint32_t val;
-    
+
+#if defined(__i386__) || defined(__x86_64__)
+    static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+    pthread_mutex_lock(&mutex);
+#endif
+
     while (len > 0) {
         /* How much can we copy before the next page boundary? */
         l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK); 
@@ -504,6 +509,10 @@ void cpu_physical_memory_rw(target_phys_
         buf += l;
         addr += l;
     }
+
+#if defined(__i386__) || defined(__x86_64__)
+    pthread_mutex_unlock(&mutex);
+#endif
 }
 #endif
 
diff -r 65c3287306db -r 0946c90c1105 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Wed Dec 13 10:24:20 2006 +0000
+++ b/tools/ioemu/vl.c  Wed Dec 13 11:01:33 2006 +0000
@@ -5820,8 +5820,8 @@ static int qemu_map_cache_init(unsigned 
     if (nr_pages < max_pages)
         max_pages = nr_pages;
 
-    nr_buckets = (max_pages << PAGE_SHIFT) >> MCACHE_BUCKET_SHIFT;
-
+    nr_buckets   = max_pages + (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1;
+    nr_buckets >>= (MCACHE_BUCKET_SHIFT - PAGE_SHIFT);
     fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
 
     mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
@@ -5857,8 +5857,7 @@ uint8_t *qemu_map_cache(target_phys_addr
 
     entry = &mapcache_entry[address_index % nr_buckets];
 
-    if (entry->vaddr_base == NULL || entry->paddr_index != address_index)
-    { 
+    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];

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.