Add command p2v to translate Guest physical address to Host virtual address.
Signed-off-by: Max Asbock <masb...@linux.vnet.ibm.com> Jiajia Zheng <jiajia.zh...@intel.com> --- diff --git a/monitor.c b/monitor.c index b33b01f..83d9ac7 100644 --- a/monitor.c +++ b/monitor.c @@ -668,6 +668,11 @@ static void do_info_uuid(Monitor *mon, QObject **ret_data) *ret_data = qobject_from_jsonf("{ 'UUID': %s }", uuid); } +static void do_info_p2v(Monitor *mon) +{ + monitor_printf(mon, "p2v implemented\n"); +} + /* get the current CPU defined by the user */ static int mon_set_cpu(int cpu_index) { @@ -2283,6 +2288,14 @@ static void do_inject_mce(Monitor *mon, const QDict *qdict) break; } } +static void do_p2v(Monitor *mon, const QDict *qdict) +{ + target_long size = 4096; + target_long addr = qdict_get_int(qdict, "addr"); + + monitor_printf(mon, "Guest physical address %p is mapped at host virtual address %p\n", (void *)addr, cpu_physical_memory_map( (target_phys_addr_t)addr, (target_phys_addr_t *)&size, 0)); +} + #endif static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data) @@ -2659,6 +2672,13 @@ static const mon_cmd_t info_cmds[] = { .mhandler.info = do_info_qdm, }, { + .name = "p2v", + .args_type = "", + .params = "", + .help = "translate guest physical to host virtual address", + .mhandler.info = do_info_p2v, + }, + { .name = "roms", .args_type = "", .params = "", diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 9e3ea3c..ab9743c 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -326,6 +326,16 @@ Start gdbserver session (default @var{port}=1234) ETEXI { + .name = "p2v", + .args_type = "fmt:/,addr:l", + .params = "/fmt addr", + .help = "translate guest physical 'addr' to host virtual address", + .mhandler.cmd = do_p2v, + }, +STEXI +ETEXI + + { .name = "x", .args_type = "fmt:/,addr:l", .params = "/fmt addr",