public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Monitor command to translate guest physical address to host virtual address
@ 2010-10-01  1:52 Huang Ying
  2010-10-01 22:53 ` Marcelo Tosatti
  0 siblings, 1 reply; 5+ messages in thread
From: Huang Ying @ 2010-10-01  1:52 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm@vger.kernel.org, Andi Kleen, Dean Nelson

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",



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Monitor command to translate guest physical address to host virtual address
  2010-10-01  1:52 [PATCH] Monitor command to translate guest physical address to host virtual address Huang Ying
@ 2010-10-01 22:53 ` Marcelo Tosatti
  2010-10-02  8:16   ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Marcelo Tosatti @ 2010-10-01 22:53 UTC (permalink / raw)
  To: Huang Ying; +Cc: Avi Kivity, kvm@vger.kernel.org, Andi Kleen, Dean Nelson

On Fri, Oct 01, 2010 at 09:52:25AM +0800, Huang Ying wrote:
> 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>

Added missing cpu_physical_memory_unmap and applied, thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Monitor command to translate guest physical address to host virtual address
  2010-10-01 22:53 ` Marcelo Tosatti
@ 2010-10-02  8:16   ` Avi Kivity
  2010-10-03 10:07     ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2010-10-02  8:16 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Huang Ying, kvm@vger.kernel.org, Andi Kleen, Dean Nelson

  On 10/02/2010 12:53 AM, Marcelo Tosatti wrote:
> On Fri, Oct 01, 2010 at 09:52:25AM +0800, Huang Ying wrote:
> >  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>
>
> Added missing cpu_physical_memory_unmap and applied, thanks.
>

This should have been copied to qemu-devel so that the monitor people 
can review it.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Monitor command to translate guest physical address to host virtual address
  2010-10-02  8:16   ` Avi Kivity
@ 2010-10-03 10:07     ` Avi Kivity
  2010-10-03 10:33       ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2010-10-03 10:07 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Huang Ying, kvm@vger.kernel.org, Andi Kleen, Dean Nelson

  On 10/02/2010 10:16 AM, Avi Kivity wrote:
>  On 10/02/2010 12:53 AM, Marcelo Tosatti wrote:
>> On Fri, Oct 01, 2010 at 09:52:25AM +0800, Huang Ying wrote:
>> >  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>
>>
>> Added missing cpu_physical_memory_unmap and applied, thanks.
>>
>
> This should have been copied to qemu-devel so that the monitor people 
> can review it.
>

It also breaks the build:
>
> I  CC    x86_64-softmmu/monitor.o
> cc1: warnings being treated as errors
> /var/lib/buildbot/qemu-kvm/disable_kvm_i386_out_of_tree/build/monitor.c: 
> In function 'do_p2v':
> /var/lib/buildbot/qemu-kvm/disable_kvm_i386_out_of_tree/build/monitor.c:2312: 
> error: cast to pointer from integer of different size
> make[1]: *** [monitor.o] Error 1
> make: *** [subdir-x86_64-softmmu] Error 2

I've reverted it for now.  Please resubmit to qemu upstream 
(qemu-devel@nongnu.org).  I also suggest coming up with a better name 
for the command, and QMP support.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Monitor command to translate guest physical address to host virtual address
  2010-10-03 10:07     ` Avi Kivity
@ 2010-10-03 10:33       ` Avi Kivity
  0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-10-03 10:33 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Huang Ying, kvm@vger.kernel.org, Andi Kleen, Dean Nelson

  On 10/03/2010 12:07 PM, Avi Kivity wrote:
>
>>
>> I  CC    x86_64-softmmu/monitor.o
>> cc1: warnings being treated as errors
>> /var/lib/buildbot/qemu-kvm/disable_kvm_i386_out_of_tree/build/monitor.c: 
>> In function 'do_p2v':
>> /var/lib/buildbot/qemu-kvm/disable_kvm_i386_out_of_tree/build/monitor.c:2312: 
>> error: cast to pointer from integer of different size
>> make[1]: *** [monitor.o] Error 1
>> make: *** [subdir-x86_64-softmmu] Error 2
>
> I've reverted it for now.  Please resubmit to qemu upstream 
> (qemu-devel@nongnu.org).  I also suggest coming up with a better name 
> for the command, and QMP support.
>

Another thing to consider is making it work on ranges, not pages.  This 
can be used with page migration for rebinding guest numa nodes to host 
numa nodes.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-03 10:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-01  1:52 [PATCH] Monitor command to translate guest physical address to host virtual address Huang Ying
2010-10-01 22:53 ` Marcelo Tosatti
2010-10-02  8:16   ` Avi Kivity
2010-10-03 10:07     ` Avi Kivity
2010-10-03 10:33       ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox