@@ -2272,6 +2272,28 @@ static void do_inject_mce(Monitor *mon,
}
#endif
+static void do_pfa2hva_print(Monitor *mon, const QObject *data)
+{
+ QInt *qint;
+
+ qint = qobject_to_qint(data);
+ monitor_printf(mon, "0x%lx\n", (unsigned long)qint->value);
+}
+
+static int do_pfa2hva(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+ target_phys_addr_t paddr;
+ target_phys_addr_t size = TARGET_PAGE_SIZE;
+ void *vaddr;
+
+ paddr = qdict_get_int(qdict, "addr");
+ vaddr = cpu_physical_memory_map(paddr, &size, 0);
+ cpu_physical_memory_unmap(vaddr, size, 0, 0);
+ *ret_data = qobject_from_jsonf("%ld", (unsigned long)vaddr);
+
+ return 0;
+}
+
static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
const char *fdname = qdict_get_str(qdict, "fdname");
@@ -293,6 +293,21 @@ Start gdbserver session (default @var{po
ETEXI
{
+ .name = "pfa2hva",
+ .args_type = "fmt:/,addr:l",
+ .params = "/fmt addr",
+ .help = "translate guest physical 'addr' to host virtual address",
+ .user_print = do_pfa2hva_print,
+ .mhandler.cmd_new = do_pfa2hva,
+ },
+
+STEXI
+@item pfa2hva @var{addr}
+@findex pfa2hva
+Translate guest physical @var{addr} to host virtual address.
+ETEXI
+
+ {
.name = "x",
.args_type = "fmt:/,addr:l",
.params = "/fmt addr",
@@ -738,6 +738,33 @@ Example:
EQMP
{
+ .name = "pfa2hva",
+ .args_type = "addr:l",
+ .params = "addr",
+ .help = "translate guest physical 'addr' to host virtual address",
+ .user_print = do_pfa2hva_print,
+ .mhandler.cmd_new = do_pfa2hva,
+ },
+
+SQMP
+pfa2hva
+---
+
+Translate guest physical 'addr' to host virtual address.
+
+Arguments:
+
+- "addr": the guest physical address
+
+Example:
+
+-> { "execute": "pfa2hva",
+ "arguments": { "addr": 196608 } }
+<- { "return": 139888084717568 }
+
+EQMP
+
+ {
.name = "qmp_capabilities",
.args_type = "",
.params = "",