From: Huang Ying <ying.huang@intel.com>
To: Avi Kivity <avi@redhat.com>,
Anthony Liguori <aliguori@linux.vnet.ibm.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Andi Kleen <andi@firstfloor.org>,
Dean Nelson <dnelson@redhat.com>,
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Max Asbock <masbock@linux.vnet.ibm.com>
Subject: [PATCH -v3] Monitor command: x-gpa2hva, translate guest physical address to host virtual address
Date: Tue, 16 Nov 2010 10:23:07 +0800 [thread overview]
Message-ID: <1289874187.8719.1127.camel@yhuang-dev> (raw)
Author: Max Asbock <masbock@linux.vnet.ibm.com>
Add command x-gpa2hva to translate guest physical address to host
virtual address. Because gpa to hva translation is not consistent, so
this command is only used for debugging.
The x-gpa2hva 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.
v3:
- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent
v2:
- Add QMP support
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>
---
hmp-commands.hx | 15 +++++++++++++++
monitor.c | 22 ++++++++++++++++++++++
2 files changed, 37 insertions(+)
--- a/monitor.c
+++ b/monitor.c
@@ -2272,6 +2272,28 @@ static void do_inject_mce(Monitor *mon,
}
#endif
+static void do_gpa2hva_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_gpa2hva(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");
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -293,6 +293,21 @@ Start gdbserver session (default @var{po
ETEXI
{
+ .name = "x-gpa2hva",
+ .args_type = "fmt:/,addr:l",
+ .params = "/fmt addr",
+ .help = "translate guest physical 'addr' to host virtual address, only for debugging",
+ .user_print = do_gpa2hva_print,
+ .mhandler.cmd_new = do_gpa2hva,
+ },
+
+STEXI
+@item x-gpa2hva @var{addr}
+@findex x-gpa2hva
+Translate guest physical @var{addr} to host virtual address, only for debugging.
+ETEXI
+
+ {
.name = "x",
.args_type = "fmt:/,addr:l",
.params = "/fmt addr",
next reply other threads:[~2010-11-16 2:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 2:23 Huang Ying [this message]
2010-11-19 8:17 ` [PATCH -v3] Monitor command: x-gpa2hva, translate guest physical address to host virtual address Huang Ying
2011-04-27 23:06 ` Marcelo Tosatti
2011-04-28 13:00 ` Anthony Liguori
2011-04-28 14:04 ` Marcelo Tosatti
2011-04-29 0:30 ` Huang Ying
2011-04-29 13:14 ` Luiz Capitulino
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=1289874187.8719.1127.camel@yhuang-dev \
--to=ying.huang@intel.com \
--cc=aliguori@linux.vnet.ibm.com \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=dnelson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=masbock@linux.vnet.ibm.com \
--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;
as well as URLs for NNTP newsgroup(s).