diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2019-04-12 16:26:52 +0100 |
---|---|---|
committer | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2019-05-01 10:46:59 +0100 |
commit | 574d96933ceff60b2d13fe97602572fc7e95f7c6 (patch) | |
tree | ec4a2ca2ebff19f5620c50a147d972562928866e /monitor.c | |
parent | b4e492db03a25395087e867f8f944f7b2a2e1cef (diff) |
hmp: gva2gpa debug command
Add a gva2gpa command purely for debug which performs
address translation on the gva, the existing gpa2hva
command can then also be used to find it in the qemu
userspace; e.g.
(qemu) info registers
.... RSP=ffffffff81c03e98
....
(qemu) gva2gpa 0xffffffff81c03e98
gpa: 0x1c03e98
(qemu) gpa2hva 0x1c03e98
Host virtual address for 0x1c03e98 (pc.ram) is 0x7f0599a03e98
(qemu) x/10x 0xffffffff81c03e98
ffffffff81c03e98: 0x81c03eb8 0xffffffff 0x8101ea3f 0xffffffff
ffffffff81c03ea8: 0x81d27b00 0xffffffff 0x00000000 0x00000000
ffffffff81c03eb8: 0x81c03ec8 0xffffffff
gdb -p ...qemu...
(gdb) x/10x 0x7f0599a03e98
0x7f0599a03e98: 0x81c03eb8 0xffffffff 0x8101ea3f 0xffffffff
0x7f0599a03ea8: 0x81d27b00 0xffffffff 0x00000000 0x00000000
0x7f0599a03eb8: 0x81c03ec8 0xffffffff
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190412152652.827-1-dgilbert@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -1673,6 +1673,28 @@ static void hmp_gpa2hva(Monitor *mon, const QDict *qdict) memory_region_unref(mr); } +static void hmp_gva2gpa(Monitor *mon, const QDict *qdict) +{ + target_ulong addr = qdict_get_int(qdict, "addr"); + MemTxAttrs attrs; + CPUState *cs = mon_get_cpu(); + hwaddr gpa; + + if (!cs) { + monitor_printf(mon, "No cpu\n"); + return; + } + + gpa = cpu_get_phys_page_attrs_debug(mon_get_cpu(), + addr & TARGET_PAGE_MASK, &attrs); + if (gpa == -1) { + monitor_printf(mon, "Unmapped\n"); + } else { + monitor_printf(mon, "gpa: %#" HWADDR_PRIx "\n", + gpa + (addr & ~TARGET_PAGE_MASK)); + } +} + #ifdef CONFIG_LINUX static uint64_t vtop(void *ptr, Error **errp) { |