From patchwork Fri Jan 14 01:51:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Ying" X-Patchwork-Id: 477081 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 p0E1qf3Y007217 for ; Fri, 14 Jan 2011 01:52:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757471Ab1ANBvZ (ORCPT ); Thu, 13 Jan 2011 20:51:25 -0500 Received: from mga02.intel.com ([134.134.136.20]:48617 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756924Ab1ANBvY (ORCPT ); Thu, 13 Jan 2011 20:51:24 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 13 Jan 2011 17:51:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,320,1291622400"; d="scan'208";a="592836768" Received: from yhuang-dev.sh.intel.com (HELO [10.239.13.101]) ([10.239.13.101]) by orsmga002.jf.intel.com with ESMTP; 13 Jan 2011 17:51:22 -0800 Subject: Re: [PATCH uq/master 2/2] MCE, unpoison memory address across reboot From: Huang Ying To: Jan Kiszka Cc: Avi Kivity , Marcelo Tosatti , Anthony Liguori , "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" , Dean Nelson , Andi Kleen In-Reply-To: <4D2EBF69.9070208@siemens.com> References: <1294907685.4596.44.camel@yhuang-dev> <4D2EBF69.9070208@siemens.com> Date: Fri, 14 Jan 2011 09:51:21 +0800 Message-ID: <1294969881.4596.80.camel@yhuang-dev> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 14 Jan 2011 01:52:41 +0000 (UTC) Author: Max Asbock Subject: [PATCH -v3] Monitor command: x-gpa2hva, translate guest physical address to host virtual address 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 Signed-off-by: Jiajia Zheng Signed-off-by: Huang Ying --- hmp-commands.hx | 15 +++++++++++++++ monitor.c | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) --- a/monitor.c +++ b/monitor.c @@ -2708,6 +2708,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 @@ -311,6 +311,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",