diff mbox

[-v3] Monitor command: x-gpa2hva, translate guest physical address to host virtual address

Message ID 1289874187.8719.1127.camel@yhuang-dev (mailing list archive)
State New, archived
Headers show

Commit Message

Huang, Ying Nov. 16, 2010, 2:23 a.m. UTC
None

Comments

Marcelo Tosatti April 27, 2011, 11:06 p.m. UTC | #1
On Fri, Nov 19, 2010 at 04:17:35PM +0800, Huang Ying wrote:
> On Tue, 2010-11-16 at 10:23 +0800, Huang Ying wrote:
> > 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
> 
> Is this patch an acceptable solution for now? This command is useful for
> our testing.

Anthony?

> 
> Best Regards,
> Huang Ying
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Anthony Liguori April 28, 2011, 1 p.m. UTC | #2
On 04/27/2011 06:06 PM, Marcelo Tosatti wrote:
> On Fri, Nov 19, 2010 at 04:17:35PM +0800, Huang Ying wrote:
>> On Tue, 2010-11-16 at 10:23 +0800, Huang Ying wrote:
>>> 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
>>
>> Is this patch an acceptable solution for now? This command is useful for
>> our testing.
>
> Anthony?

Yeah, but it should come through qemu-devel, no?

Regards,

Anthony Liguori

>
>>
>> Best Regards,
>> Huang Ying
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Huang, Ying April 29, 2011, 12:30 a.m. UTC | #3
On 04/28/2011 10:04 PM, Marcelo Tosatti wrote:
> On Thu, Apr 28, 2011 at 08:00:19AM -0500, Anthony Liguori wrote:
>> On 04/27/2011 06:06 PM, Marcelo Tosatti wrote:
>>> On Fri, Nov 19, 2010 at 04:17:35PM +0800, Huang Ying wrote:
>>>> On Tue, 2010-11-16 at 10:23 +0800, Huang Ying wrote:
>>>>> 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
>>>>
>>>> Is this patch an acceptable solution for now? This command is useful for
>>>> our testing.
>>>
>>> Anthony?
>>
>> Yeah, but it should come through qemu-devel, no?
> 
> Yes, Huang Ying, can you please resend?

Via QEMU git or uq/master branch of KVM git?

Best Regards,
Huang Ying
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luiz Capitulino April 29, 2011, 1:14 p.m. UTC | #4
On Fri, 29 Apr 2011 08:30:25 +0800
Huang Ying <ying.huang@intel.com> wrote:

> On 04/28/2011 10:04 PM, Marcelo Tosatti wrote:
> > On Thu, Apr 28, 2011 at 08:00:19AM -0500, Anthony Liguori wrote:
> >> On 04/27/2011 06:06 PM, Marcelo Tosatti wrote:
> >>> On Fri, Nov 19, 2010 at 04:17:35PM +0800, Huang Ying wrote:
> >>>> On Tue, 2010-11-16 at 10:23 +0800, Huang Ying wrote:
> >>>>> 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
> >>>>
> >>>> Is this patch an acceptable solution for now? This command is useful for
> >>>> our testing.
> >>>
> >>> Anthony?
> >>
> >> Yeah, but it should come through qemu-devel, no?
> > 
> > Yes, Huang Ying, can you please resend?
> 
> Via QEMU git or uq/master branch of KVM git?

If there isn't anything qemu-kvm.git specific, it should be against
qemu.git.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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