public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Andi Kleen <andi@firstfloor.org>,
	Dean Nelson <dnelson@redhat.com>
Subject: [PATCH] Monitor command to translate guest physical address to host virtual address
Date: Fri, 01 Oct 2010 09:52:25 +0800	[thread overview]
Message-ID: <1285897945.24402.5.camel@yhuang-dev> (raw)

From: Max Asbock <masbock@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 <masbock@linux.vnet.ibm.com>
Signed-off-by: Jiajia Zheng <jiajia.zheng@intel.com>
Signed-off-by: Huang Ying <ying.huang@intel.com>
---
 monitor.c       |   11 +++++++++++
 qemu-monitor.hx |   13 +++++++++++++
 2 files changed, 24 insertions(+)

--- a/monitor.c
+++ b/monitor.c
@@ -2301,6 +2301,17 @@ static void do_inject_mce(Monitor *mon,
 }
 #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);
+}
+
 static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     const char *fdname = qdict_get_str(qdict, "fdname");
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -459,6 +459,19 @@ Start gdbserver session (default @var{po
 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",



             reply	other threads:[~2010-10-01  1:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-01  1:52 Huang Ying [this message]
2010-10-01 22:53 ` [PATCH] Monitor command to translate guest physical address to host virtual address Marcelo Tosatti
2010-10-02  8:16   ` Avi Kivity
2010-10-03 10:07     ` Avi Kivity
2010-10-03 10:33       ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285897945.24402.5.camel@yhuang-dev \
    --to=ying.huang@intel.com \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=dnelson@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox