mirror of
https://github.com/mii443/qemu.git
synced 2025-12-16 17:18:49 +00:00
memory: Rework "info mtree" to print flat views and dispatch trees
This adds a new "-d" switch to "info mtree" to print dispatch tree internals. This changes the way "-f" is handled - it prints now flat views and associated address spaces. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Message-Id: <20170921085110.25598-15-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
committed by
Paolo Bonzini
parent
67ace39b25
commit
5e8fd947e2
84
exec.c
84
exec.c
@@ -3616,3 +3616,87 @@ void page_size_init(void)
|
||||
}
|
||||
qemu_host_page_mask = -(intptr_t)qemu_host_page_size;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
|
||||
static void mtree_print_phys_entries(fprintf_function mon, void *f,
|
||||
int start, int end, int skip, int ptr)
|
||||
{
|
||||
if (start == end - 1) {
|
||||
mon(f, "\t%3d ", start);
|
||||
} else {
|
||||
mon(f, "\t%3d..%-3d ", start, end - 1);
|
||||
}
|
||||
mon(f, " skip=%d ", skip);
|
||||
if (ptr == PHYS_MAP_NODE_NIL) {
|
||||
mon(f, " ptr=NIL");
|
||||
} else if (!skip) {
|
||||
mon(f, " ptr=#%d", ptr);
|
||||
} else {
|
||||
mon(f, " ptr=[%d]", ptr);
|
||||
}
|
||||
mon(f, "\n");
|
||||
}
|
||||
|
||||
#define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \
|
||||
int128_sub((size), int128_one())) : 0)
|
||||
|
||||
void mtree_print_dispatch(fprintf_function mon, void *f,
|
||||
AddressSpaceDispatch *d, MemoryRegion *root)
|
||||
{
|
||||
int i;
|
||||
|
||||
mon(f, " Dispatch\n");
|
||||
mon(f, " Physical sections\n");
|
||||
|
||||
for (i = 0; i < d->map.sections_nb; ++i) {
|
||||
MemoryRegionSection *s = d->map.sections + i;
|
||||
const char *names[] = { " [unassigned]", " [not dirty]",
|
||||
" [ROM]", " [watch]" };
|
||||
|
||||
mon(f, " #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx " %s%s%s%s%s",
|
||||
i,
|
||||
s->offset_within_address_space,
|
||||
s->offset_within_address_space + MR_SIZE(s->mr->size),
|
||||
s->mr->name ? s->mr->name : "(noname)",
|
||||
i < ARRAY_SIZE(names) ? names[i] : "",
|
||||
s->mr == root ? " [ROOT]" : "",
|
||||
s == d->mru_section ? " [MRU]" : "",
|
||||
s->mr->is_iommu ? " [iommu]" : "");
|
||||
|
||||
if (s->mr->alias) {
|
||||
mon(f, " alias=%s", s->mr->alias->name ?
|
||||
s->mr->alias->name : "noname");
|
||||
}
|
||||
mon(f, "\n");
|
||||
}
|
||||
|
||||
mon(f, " Nodes (%d bits per level, %d levels) ptr=[%d] skip=%d\n",
|
||||
P_L2_BITS, P_L2_LEVELS, d->phys_map.ptr, d->phys_map.skip);
|
||||
for (i = 0; i < d->map.nodes_nb; ++i) {
|
||||
int j, jprev;
|
||||
PhysPageEntry prev;
|
||||
Node *n = d->map.nodes + i;
|
||||
|
||||
mon(f, " [%d]\n", i);
|
||||
|
||||
for (j = 0, jprev = 0, prev = *n[0]; j < ARRAY_SIZE(*n); ++j) {
|
||||
PhysPageEntry *pe = *n + j;
|
||||
|
||||
if (pe->ptr == prev.ptr && pe->skip == prev.skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mtree_print_phys_entries(mon, f, jprev, j, prev.skip, prev.ptr);
|
||||
|
||||
jprev = j;
|
||||
prev = *pe;
|
||||
}
|
||||
|
||||
if (jprev != ARRAY_SIZE(*n)) {
|
||||
mtree_print_phys_entries(mon, f, jprev, j, prev.skip, prev.ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user