mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00

While the machine is paused, in guest_phys_blocks_append() we register a one-shot MemoryListener, solely for the initial collection of the valid guest-physical memory ranges that happens at listener registration time. For each range that is reported to guest_phys_blocks_region_add(), we attempt to merge the range with the preceding one. Ranges can only be joined if they are contiguous in both guest-physical address space, and contiguous in host virtual address space. The "maximal" ranges that remain in the end constitute the guest-physical memory map that the dump will be based on. Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=981582 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
79 lines
2.2 KiB
C
79 lines
2.2 KiB
C
/*
|
|
* QEMU memory mapping
|
|
*
|
|
* Copyright Fujitsu, Corp. 2011, 2012
|
|
*
|
|
* Authors:
|
|
* Wen Congyang <wency@cn.fujitsu.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*
|
|
*/
|
|
|
|
#ifndef MEMORY_MAPPING_H
|
|
#define MEMORY_MAPPING_H
|
|
|
|
#include "qemu/queue.h"
|
|
#include "qemu/typedefs.h"
|
|
|
|
typedef struct GuestPhysBlock {
|
|
/* visible to guest, reflects PCI hole, etc */
|
|
hwaddr target_start;
|
|
|
|
/* implies size */
|
|
hwaddr target_end;
|
|
|
|
/* points into host memory */
|
|
uint8_t *host_addr;
|
|
|
|
QTAILQ_ENTRY(GuestPhysBlock) next;
|
|
} GuestPhysBlock;
|
|
|
|
/* point-in-time snapshot of guest-visible physical mappings */
|
|
typedef struct GuestPhysBlockList {
|
|
unsigned num;
|
|
QTAILQ_HEAD(GuestPhysBlockHead, GuestPhysBlock) head;
|
|
} GuestPhysBlockList;
|
|
|
|
/* The physical and virtual address in the memory mapping are contiguous. */
|
|
typedef struct MemoryMapping {
|
|
hwaddr phys_addr;
|
|
target_ulong virt_addr;
|
|
ram_addr_t length;
|
|
QTAILQ_ENTRY(MemoryMapping) next;
|
|
} MemoryMapping;
|
|
|
|
struct MemoryMappingList {
|
|
unsigned int num;
|
|
MemoryMapping *last_mapping;
|
|
QTAILQ_HEAD(, MemoryMapping) head;
|
|
};
|
|
|
|
/*
|
|
* add or merge the memory region [phys_addr, phys_addr + length) into the
|
|
* memory mapping's list. The region's virtual address starts with virt_addr,
|
|
* and is contiguous. The list is sorted by phys_addr.
|
|
*/
|
|
void memory_mapping_list_add_merge_sorted(MemoryMappingList *list,
|
|
hwaddr phys_addr,
|
|
hwaddr virt_addr,
|
|
ram_addr_t length);
|
|
|
|
void memory_mapping_list_free(MemoryMappingList *list);
|
|
|
|
void memory_mapping_list_init(MemoryMappingList *list);
|
|
|
|
void guest_phys_blocks_free(GuestPhysBlockList *list);
|
|
void guest_phys_blocks_init(GuestPhysBlockList *list);
|
|
void guest_phys_blocks_append(GuestPhysBlockList *list);
|
|
|
|
void qemu_get_guest_memory_mapping(MemoryMappingList *list, Error **errp);
|
|
|
|
/* get guest's memory mapping without do paging(virtual address is 0). */
|
|
void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list);
|
|
|
|
void memory_mapping_filter(MemoryMappingList *list, int64_t begin,
|
|
int64_t length);
|
|
|
|
#endif
|