X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/4a9a8876a14653fd03918945dbb96de3e84b3e3f..421cc3e7e89cb807d3c5f6de486abb2167c8e792:/memory_mapping.c diff --git a/memory_mapping.c b/memory_mapping.c index eeeeb44026..e3e0d95172 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -11,10 +11,11 @@ * */ -#include +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" #include "cpu.h" -#include "exec/cpu-all.h" #include "sysemu/memory_mapping.h" #include "exec/memory.h" #include "exec/address-spaces.h" @@ -177,6 +178,7 @@ void guest_phys_blocks_free(GuestPhysBlockList *list) QTAILQ_FOREACH_SAFE(p, &list->head, next, q) { QTAILQ_REMOVE(&list->head, p, next); + memory_region_unref(p->mr); g_free(p); } list->num = 0; @@ -203,7 +205,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener, GuestPhysBlock *predecessor; /* we only care about RAM */ - if (!memory_region_is_ram(section->mr)) { + if (!memory_region_is_ram(section->mr) || + memory_region_is_skip_dump(section->mr)) { return; } @@ -239,6 +242,8 @@ static void guest_phys_blocks_region_add(MemoryListener *listener, block->target_start = target_start; block->target_end = target_end; block->host_addr = host_addr; + block->mr = section->mr; + memory_region_ref(section->mr); QTAILQ_INSERT_TAIL(&g->list->head, block, next); ++g->list->num; @@ -270,7 +275,7 @@ static CPUState *find_paging_enabled_cpu(CPUState *start_cpu) { CPUState *cpu; - for (cpu = start_cpu; cpu != NULL; cpu = cpu->next_cpu) { + CPU_FOREACH(cpu) { if (cpu_paging_enabled(cpu)) { return cpu; } @@ -289,7 +294,8 @@ void qemu_get_guest_memory_mapping(MemoryMappingList *list, first_paging_enabled_cpu = find_paging_enabled_cpu(first_cpu); if (first_paging_enabled_cpu) { - for (cpu = first_paging_enabled_cpu; cpu != NULL; cpu = cpu->next_cpu) { + for (cpu = first_paging_enabled_cpu; cpu != NULL; + cpu = CPU_NEXT(cpu)) { Error *err = NULL; cpu_get_memory_mapping(cpu, list, &err); if (err) {