From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH -v2] Monitor command: pfa2hva, translate guest physical address to host virtual address Date: Mon, 01 Nov 2010 13:49:15 -0500 Message-ID: <4CCF0BAB.9000304@linux.vnet.ibm.com> References: <1288060789.2862.336.camel@yhuang-dev> <20101101160952.GE1429@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Huang Ying , Anthony Liguori , Avi Kivity , "kvm@vger.kernel.org" , Andi Kleen , Dean Nelson To: Marcelo Tosatti Return-path: Received: from e37.co.us.ibm.com ([32.97.110.158]:45441 "EHLO e37.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754063Ab0KAStX (ORCPT ); Mon, 1 Nov 2010 14:49:23 -0400 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id oA1Il8W1023992 for ; Mon, 1 Nov 2010 12:47:08 -0600 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oA1InJXY209518 for ; Mon, 1 Nov 2010 12:49:19 -0600 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oA1InIfS006344 for ; Mon, 1 Nov 2010 12:49:19 -0600 In-Reply-To: <20101101160952.GE1429@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 11/01/2010 11:09 AM, Marcelo Tosatti wrote: > On Tue, Oct 26, 2010 at 10:39:48AM +0800, Huang Ying wrote: > >> Author: Max Asbock >> >> Add command pfa2hva to translate guest physical address to host >> virtual address. >> >> The pfa2hva 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. >> >> v2: >> >> - Add QMP support >> > > Looks good to me. Anthony? > The translation is not stable so this is really a bad interface. It definitely shouldn't be a QMP command and I don't think it's generally useful enough that it should be a monitor command. It's impossible to use correctly as a general interface. I gave this feedback when it was initially submitted. Regards, Anthony Liguori >> Signed-off-by: Max Asbock >> Signed-off-by: Jiajia Zheng >> Signed-off-by: Huang Ying >> --- >> hmp-commands.hx | 15 +++++++++++++++ >> monitor.c | 22 ++++++++++++++++++++++ >> qmp-commands.hx | 27 +++++++++++++++++++++++++++ >> 3 files changed, 64 insertions(+) >> >> --- a/monitor.c >> +++ b/monitor.c >> @@ -2272,6 +2272,28 @@ static void do_inject_mce(Monitor *mon, >> } >> #endif >> >> +static void do_pfa2hva_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_pfa2hva(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 = "pfa2hva", >> + .args_type = "fmt:/,addr:l", >> + .params = "/fmt addr", >> + .help = "translate guest physical 'addr' to host virtual address", >> + .user_print = do_pfa2hva_print, >> + .mhandler.cmd_new = do_pfa2hva, >> + }, >> + >> +STEXI >> +@item pfa2hva @var{addr} >> +@findex pfa2hva >> +Translate guest physical @var{addr} to host virtual address. >> +ETEXI >> + >> + { >> .name = "x", >> .args_type = "fmt:/,addr:l", >> .params = "/fmt addr", >> --- a/qmp-commands.hx >> +++ b/qmp-commands.hx >> @@ -738,6 +738,33 @@ Example: >> EQMP >> >> { >> + .name = "pfa2hva", >> + .args_type = "addr:l", >> + .params = "addr", >> + .help = "translate guest physical 'addr' to host virtual address", >> + .user_print = do_pfa2hva_print, >> + .mhandler.cmd_new = do_pfa2hva, >> + }, >> + >> +SQMP >> +pfa2hva >> +--- >> + >> +Translate guest physical 'addr' to host virtual address. >> + >> +Arguments: >> + >> +- "addr": the guest physical address >> + >> +Example: >> + >> +-> { "execute": "pfa2hva", >> + "arguments": { "addr": 196608 } } >> +<- { "return": 139888084717568 } >> + >> +EQMP >> + >> + { >> .name = "qmp_capabilities", >> .args_type = "", >> .params = "", >> >>