ia64/xen-unstable

changeset 12993:0946c90c1105

[IOEMU] Locking needed to access mapcache.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Dec 13 11:01:33 2006 +0000 (2006-12-13)
parents 65c3287306db
children 73b59ad4dd42
files tools/ioemu/target-i386-dm/exec-dm.c tools/ioemu/vl.c
line diff
     1.1 --- a/tools/ioemu/target-i386-dm/exec-dm.c	Wed Dec 13 10:24:20 2006 +0000
     1.2 +++ b/tools/ioemu/target-i386-dm/exec-dm.c	Wed Dec 13 11:01:33 2006 +0000
     1.3 @@ -439,7 +439,12 @@ void cpu_physical_memory_rw(target_phys_
     1.4      int l, io_index;
     1.5      uint8_t *ptr;
     1.6      uint32_t val;
     1.7 -    
     1.8 +
     1.9 +#if defined(__i386__) || defined(__x86_64__)
    1.10 +    static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
    1.11 +    pthread_mutex_lock(&mutex);
    1.12 +#endif
    1.13 +
    1.14      while (len > 0) {
    1.15          /* How much can we copy before the next page boundary? */
    1.16          l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK); 
    1.17 @@ -504,6 +509,10 @@ void cpu_physical_memory_rw(target_phys_
    1.18          buf += l;
    1.19          addr += l;
    1.20      }
    1.21 +
    1.22 +#if defined(__i386__) || defined(__x86_64__)
    1.23 +    pthread_mutex_unlock(&mutex);
    1.24 +#endif
    1.25  }
    1.26  #endif
    1.27  
     2.1 --- a/tools/ioemu/vl.c	Wed Dec 13 10:24:20 2006 +0000
     2.2 +++ b/tools/ioemu/vl.c	Wed Dec 13 11:01:33 2006 +0000
     2.3 @@ -5820,8 +5820,8 @@ static int qemu_map_cache_init(unsigned 
     2.4      if (nr_pages < max_pages)
     2.5          max_pages = nr_pages;
     2.6  
     2.7 -    nr_buckets = (max_pages << PAGE_SHIFT) >> MCACHE_BUCKET_SHIFT;
     2.8 -
     2.9 +    nr_buckets   = max_pages + (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1;
    2.10 +    nr_buckets >>= (MCACHE_BUCKET_SHIFT - PAGE_SHIFT);
    2.11      fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
    2.12  
    2.13      mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
    2.14 @@ -5857,8 +5857,7 @@ uint8_t *qemu_map_cache(target_phys_addr
    2.15  
    2.16      entry = &mapcache_entry[address_index % nr_buckets];
    2.17  
    2.18 -    if (entry->vaddr_base == NULL || entry->paddr_index != address_index)
    2.19 -    { 
    2.20 +    if (entry->vaddr_base == NULL || entry->paddr_index != address_index) {
    2.21          /* We need to remap a bucket. */
    2.22          uint8_t *vaddr_base;
    2.23          unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];