From patchwork Sat Aug 13 11:52:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 658962 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sBKrV4MqYz9sR9 for ; Sat, 13 Aug 2016 21:52:57 +1000 (AEST) Received: from localhost ([::1]:56770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYXUk-00045D-Jf for incoming@patchwork.ozlabs.org; Sat, 13 Aug 2016 07:52:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYXU3-0003nk-AJ for qemu-devel@nongnu.org; Sat, 13 Aug 2016 07:52:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bYXTz-0000Ox-6M for qemu-devel@nongnu.org; Sat, 13 Aug 2016 07:52:10 -0400 Received: from gate.crashing.org ([63.228.1.57]:51132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bYXTy-0000Op-TM for qemu-devel@nongnu.org; Sat, 13 Aug 2016 07:52:07 -0400 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id u7DBq1FO018244 for ; Sat, 13 Aug 2016 06:52:03 -0500 Message-ID: <1471089120.12231.48.camel@kernel.crashing.org> From: Benjamin Herrenschmidt To: QEMU Developers Date: Sat, 13 Aug 2016 21:52:00 +1000 X-Mailer: Evolution 3.20.4 (3.20.4-1.fc24) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 Subject: [Qemu-devel] [PATCH] monitor: Add an "xlate" command for translating a virtual address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is very handy when debugging a guest, especially when it's stuck on accessing some HW and the only way to figure out what specific piece of HW is to translate the virtual address to a hardware address that can then be matched with the mtree Signed-off-by: Benjamin Herrenschmidt --- hmp-commands.hx | 15 +++++++++++++++ monitor.c | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 848efee..2d0ce4e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -569,6 +569,21 @@ Write to I/O port. ETEXI { + .name = "xlate", + .args_type = "addr:l", + .params = "addr", + .help = "Translate virtual address via the MMU", + .mhandler.cmd = hmp_mmu_xlate, + }, + +STEXI +@item xlate @var{addr} +@findex xlate +Translate virtual address + +ETEXI + + { .name = "sendkey", .args_type = "keys:s,hold-time:i?", .params = "keys [hold_ms]", diff --git a/monitor.c b/monitor.c index 5d68a5d..b2b3a6e 100644 --- a/monitor.c +++ b/monitor.c @@ -1505,6 +1505,17 @@ static void hmp_ioport_write(Monitor *mon, const QDict *qdict) } } +static void hmp_mmu_xlate(Monitor *mon, const QDict *qdict) +{ + CPUState *cpu = mon_get_cpu(); + vaddr va = qdict_get_int(qdict, "addr"); + hwaddr pa; + + pa = cpu_get_phys_page_debug(cpu, va); + pa |= (va & ~TARGET_PAGE_MASK); + monitor_printf(mon, "0x%#" HWADDR_PRIx "\n", pa); +} + static void hmp_boot_set(Monitor *mon, const QDict *qdict) { Error *local_err = NULL;