From: Max Asbock <masb...@linux.vnet.ibm.com>

Add command p2v to translate guest physical address to host virtual
address.

The p2v command provides one step in a chain of translations from
guest virtual to guest physical to host virtual to host physical. Host
physical is then used to inject a machine check error. As a
consequence the HWPOISON code on the host and the MCE injection code
in qemu-kvm are exercised.

Signed-off-by: Max Asbock <masb...@linux.vnet.ibm.com>
Signed-off-by: Jiajia Zheng <jiajia.zh...@intel.com>
Signed-off-by: Huang Ying <ying.hu...@intel.com>
Signed-off-by: Marcelo Tosatti <mtosa...@redhat.com>

diff --git a/monitor.c b/monitor.c
index 9072c06..df0cb33 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2301,6 +2301,18 @@ static void do_inject_mce(Monitor *mon, const QDict 
*qdict)
 }
 #endif
 
+static void do_p2v(Monitor *mon, const QDict *qdict)
+{
+    target_phys_addr_t size = TARGET_PAGE_SIZE;
+    target_phys_addr_t addr = qdict_get_int(qdict, "addr");
+    void *vaddr;
+
+    vaddr = cpu_physical_memory_map(addr, &size, 0);
+    monitor_printf(mon, "Guest physical address %p is mapped at "
+                   "host virtual address %p\n", (void *)addr, vaddr);
+    cpu_physical_memory_unmap(vaddr, size, 0, 0);
+}
+
 static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     const char *fdname = qdict_get_str(qdict, "fdname");
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 620f937..2698a42 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -459,6 +459,19 @@ 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
+...@item p2v @var{addr}
+...@findex mce
+Translate guest physical @var{addr} to host virtual address.
+ETEXI
+
+    {
         .name       = "x",
         .args_type  = "fmt:/,addr:l",
         .params     = "/fmt addr",
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to