Hi all,
this patch makes the new mapcache code cleaner and fixes few problems
introduced by the recent mapcache improvements.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index cbd32c7..b01605b 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -173,15 +173,13 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr,
uint8_t lock)
void qemu_invalidate_entry(uint8_t *buffer)
{
- struct map_cache *entry = NULL, *next;
+ struct map_cache *entry = NULL, *pentry = NULL;
struct map_cache_rev *reventry;
unsigned long paddr_index;
int found = 0;
- if (last_address_vaddr == buffer) {
+ if (last_address_vaddr == buffer)
last_address_index = ~0UL;
- last_address_vaddr = NULL;
- }
TAILQ_FOREACH(reventry, &locked_entries, next) {
if (reventry->vaddr_req == buffer) {
@@ -200,26 +198,26 @@ void qemu_invalidate_entry(uint8_t *buffer)
TAILQ_REMOVE(&locked_entries, reventry, next);
qemu_free(reventry);
- next = &mapcache_entry[paddr_index];
- if (next->paddr_index == paddr_index) {
- next->lock--;
+ entry = &mapcache_entry[paddr_index % nr_buckets];
+ while (entry && entry->paddr_index != paddr_index) {
+ pentry = entry;
+ entry = entry->next;
+ }
+ if (!entry) {
+ fprintf(logfile, "Trying to unmap address %p that is not in the
mapcache!\n", buffer);
return;
}
+ entry->lock--;
+ if (entry->lock > 0 || pentry == NULL)
+ return;
- while (next != NULL && next->paddr_index != paddr_index) {
- entry = next;
- next = next->next;
- }
- if (!next)
- fprintf(logfile, "Trying to unmap address %p that is not in the
mapcache!\n", buffer);
-
- entry->next = next->next;
- errno = munmap(next->vaddr_base, MCACHE_BUCKET_SIZE);
+ pentry->next = entry->next;
+ errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
if (errno) {
fprintf(logfile, "unmap fails %d\n", errno);
exit(-1);
}
- qemu_free(next);
+ qemu_free(entry);
}
void qemu_invalidate_map_cache(void)
diff --git a/i386-dm/exec-dm.c b/i386-dm/exec-dm.c
index a509fc5..dbf03a8 100644
--- a/i386-dm/exec-dm.c
+++ b/i386-dm/exec-dm.c
@@ -801,4 +801,5 @@ void cpu_physical_memory_unmap(void *buffer,
target_phys_addr_t len,
int is_write, target_phys_addr_t access_len)
{
qemu_invalidate_entry(buffer);
+ cpu_notify_map_clients();
}
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|