From d01a6fffa9e5e605cde216733948f97beb01bdb1 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Wed, 10 Jul 2024 13:28:52 -0700 Subject: [PATCH 1/3] MAINTAINERS: add Edgar as Xen maintainer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Edgar as Xen subsystem maintainer in QEMU. Edgar has been a QEMU maintainer for years, and has already made key changes to one of the most difficult areas of the Xen subsystem (the mapcache). Edgar volunteered helping us maintain the Xen subsystem in QEMU and we are very happy to welcome him to the team. His knowledge and expertise with QEMU internals will be of great help. Signed-off-by: Stefano Stabellini Reviewed-by: Paul Durrant Acked-by: Anthony PERARD Reviewed-by: Alex Bennée Signed-off-by: Edgar E. Iglesias --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 6725913c8b..63e11095a2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -536,6 +536,7 @@ X86 Xen CPUs M: Stefano Stabellini M: Anthony PERARD M: Paul Durrant +M: Edgar E. Iglesias L: xen-devel@lists.xenproject.org S: Supported F: */xen* From 596ccccdbfa124adb42be8c2faf0c74f4849c7a6 Mon Sep 17 00:00:00 2001 From: "Edgar E. Iglesias" Date: Tue, 2 Jul 2024 00:44:20 +0200 Subject: [PATCH 2/3] physmem: Bail out qemu_ram_block_from_host() for invalid ram addrs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bail out in qemu_ram_block_from_host() when xen_ram_addr_from_mapcache() does not find an existing mapping. Signed-off-by: Edgar E. Iglesias Reviewed-by: Alex Bennée Reviewed-by: Stefano Stabellini --- system/physmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/physmem.c b/system/physmem.c index 14aa025d41..2154432cb6 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2277,6 +2277,10 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, ram_addr_t ram_addr; RCU_READ_LOCK_GUARD(); ram_addr = xen_ram_addr_from_mapcache(ptr); + if (ram_addr == RAM_ADDR_INVALID) { + return NULL; + } + block = qemu_get_ram_block(ram_addr); if (block) { *offset = ram_addr - block->offset; From 872cb9cced796e75d4f719c31d70ed5fd629efca Mon Sep 17 00:00:00 2001 From: "Edgar E. Iglesias" Date: Tue, 2 Jul 2024 00:44:21 +0200 Subject: [PATCH 3/3] 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 Signed-off-by: Edgar E. Iglesias Reviewed-by: Anthony PERARD Reviewed-by: Stefano Stabellini --- hw/xen/xen-mapcache.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 5f23b0adbe..18ba7b1d8f 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; } }