aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar E. Iglesias <edgar.iglesias@amd.com>2024-07-02 00:44:21 +0200
committerEdgar E. Iglesias <edgar.iglesias@amd.com>2024-07-12 00:17:36 +0200
commit872cb9cced796e75d4f719c31d70ed5fd629efca (patch)
treedc16cbbedeba1ace4fe79ce7ab4e24a0aecef455
parent596ccccdbfa124adb42be8c2faf0c74f4849c7a6 (diff)
downloadqemu-872cb9cced796e75d4f719c31d70ed5fd629efca.zip
qemu-872cb9cced796e75d4f719c31d70ed5fd629efca.tar.gz
qemu-872cb9cced796e75d4f719c31d70ed5fd629efca.tar.bz2
xen: mapcache: Fix unmapping of first entries in buckets
This fixes the clobbering of the entry->next pointer when unmapping the first entry in a bucket of a mapcache. Fixes: 123acd816d ("xen: mapcache: Unmap first entries in buckets") Reported-by: Anthony PERARD <anthony.perard@vates.tech> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> Reviewed-by: Anthony PERARD <anthony.perard@vates.tech> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
-rw-r--r--hw/xen/xen-mapcache.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c
index 5f23b0a..18ba7b1 100644
--- a/hw/xen/xen-mapcache.c
+++ b/hw/xen/xen-mapcache.c
@@ -597,7 +597,17 @@ static void xen_invalidate_map_cache_entry_unlocked(MapCache *mc,
pentry->next = entry->next;
g_free(entry);
} else {
- memset(entry, 0, sizeof *entry);
+ /*
+ * Invalidate mapping but keep entry->next pointing to the rest
+ * of the list.
+ *
+ * Note that lock is already zero here, otherwise we don't unmap.
+ */
+ entry->paddr_index = 0;
+ entry->vaddr_base = NULL;
+ entry->valid_mapping = NULL;
+ entry->flags = 0;
+ entry->size = 0;
}
}