From de2ae81a44973398c75ca5a7e4934d0c4f0b5979 Mon Sep 17 00:00:00 2001 From: "Takacs, Philipp" Date: Tue, 2 Jul 2024 12:29:15 +0200 Subject: [PATCH] address_space_dispatch_clear remove subpage with higher priority --- qemu/exec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qemu/exec.c b/qemu/exec.c index a6e698c2bd..9786b19557 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -1395,6 +1395,7 @@ static subpage_t *subpage_init(struct uc_struct *uc, FlatView *fv, hwaddr base) memory_region_init_io(fv->root->uc, &mmio->iomem, &subpage_ops, mmio, TARGET_PAGE_SIZE); mmio->iomem.subpage = true; + mmio->iomem.priority = uc->snapshot_level; #if defined(DEBUG_SUBPAGE) printf("%s: %p base " TARGET_FMT_plx " len %08x\n", __func__, mmio, base, TARGET_PAGE_SIZE); @@ -1457,6 +1458,15 @@ AddressSpaceDispatch *address_space_dispatch_new(struct uc_struct *uc, FlatView void address_space_dispatch_clear(AddressSpaceDispatch *d) { + MemoryRegionSection *section; + struct uc_struct *uc = d->uc; + while (d->map.sections_nb > 0) { + d->map.sections_nb--; + section = &d->map.sections[d->map.sections_nb]; + if (section->mr->priority > uc->snapshot_level) { + phys_section_destroy(section->mr); + } + } g_free(d->map.sections); g_free(d->map.nodes); g_free(d);