]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
Fix invalidate if memory requested was not bucket aligned
authorFrediano Ziglio <frediano.ziglio@citrix.com>
Mon, 10 Sep 2012 18:10:52 +0000 (18:10 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Mon, 10 Sep 2012 18:10:52 +0000 (18:10 +0000)
When memory is mapped in qemu_map_cache with lock != 0 a reverse mapping
is created pointing to the virtual address of location requested.
The cached mapped entry is saved in last_address_vaddr with the memory
location of the base virtual address (without bucket offset).
However when this entry is invalidated the virtual address saved in the
reverse mapping is used. This cause that the mapping is freed but the
last_address_vaddr is not reset.

upstream-commit: 27b7652ef515bb4c694f79d657d2052c72b19536

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
xen-mapcache.c

index 16b7a869c6e012c8ec608c1c76dcfa8f043950fc..5fb3f18b27055132e814c4018ebe85e78d29fc53 100644 (file)
@@ -318,10 +318,6 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer)
     target_phys_addr_t size;
     int found = 0;
 
-    if (mapcache->last_address_vaddr == buffer) {
-        mapcache->last_address_index = -1;
-    }
-
     QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
         if (reventry->vaddr_req == buffer) {
             paddr_index = reventry->paddr_index;
@@ -340,6 +336,11 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer)
     QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
     g_free(reventry);
 
+    if (mapcache->last_address_index == paddr_index) {
+        mapcache->last_address_index = -1;
+        mapcache->last_address_vaddr = NULL;
+    }
+
     entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
     while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
         pentry = entry;