From patchwork Fri Oct 1 01:52:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 222072 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o911qXac013020 for ; Fri, 1 Oct 2010 01:52:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751364Ab0JABwa (ORCPT ); Thu, 30 Sep 2010 21:52:30 -0400 Received: from mga02.intel.com ([134.134.136.20]:14544 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952Ab0JABwa (ORCPT ); Thu, 30 Sep 2010 21:52:30 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 30 Sep 2010 18:52:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.57,262,1283756400"; d="scan'208";a="662910377" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.2]) ([10.239.13.2]) by orsmga001.jf.intel.com with ESMTP; 30 Sep 2010 18:52:28 -0700 Subject: [PATCH] Monitor command to translate guest physical address to host virtual address From: Huang Ying To: Avi Kivity , Marcelo Tosatti Cc: "kvm@vger.kernel.org" , Andi Kleen , Dean Nelson Date: Fri, 01 Oct 2010 09:52:25 +0800 Message-ID: <1285897945.24402.5.camel@yhuang-dev> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Oct 2010 01:52:33 +0000 (UTC) --- 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",