From patchwork Wed Jan 23 21:45:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Feiner X-Patchwork-Id: 215051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 711622C008C for ; Thu, 24 Jan 2013 08:46:17 +1100 (EST) Received: from localhost ([::1]:48936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty898-00007n-K8 for incoming@patchwork.ozlabs.org; Wed, 23 Jan 2013 16:46:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty890-00006J-KC for qemu-devel@nongnu.org; Wed, 23 Jan 2013 16:46:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ty88x-0006TM-9I for qemu-devel@nongnu.org; Wed, 23 Jan 2013 16:46:06 -0500 Received: from mail-ie0-f173.google.com ([209.85.223.173]:57181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty88x-0006T8-3n for qemu-devel@nongnu.org; Wed, 23 Jan 2013 16:46:03 -0500 Received: by mail-ie0-f173.google.com with SMTP id e13so14578639iej.18 for ; Wed, 23 Jan 2013 13:46:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=wg3GHfRWQ/IvWPGMQkyKMsQNMjaHQSnCc0oVNJdoMTo=; b=FgAv1kV4GB2i8gVQ/DERHVbTLbtoc8rhr2Ka3qfaNGZNxCF4pSG7d8ddkIGp0HZsSK B8M/WR21A3G8QNJZrlC6rSgFOTDp7nXT0UvIHk3bneM8mAHL+GGkZqnbd+e7eX5Bz4MC KOahfCg+cw8OVJuMJ3bF+2+UaH2/WKmOT/OcOBJUoff5iEYbba1J8btowUwepq+114h/ KPeUPw7y1HD7kY+NzYW0TUKi/LESIKYpK4CcQi9/LGDzIjGWc7bsdETgRZhVOkBBtUL+ xy2lx5T6su4hCsEZ9NJuPc0TapgUU2CMLA9yWmNiVH1xxR5g48IidsZ+2+DDm10Gw7TD dZGw== X-Received: by 10.50.183.167 with SMTP id en7mr2494690igc.49.1358977561829; Wed, 23 Jan 2013 13:46:01 -0800 (PST) Received: from jam.gridcentric.ca ([206.223.182.18]) by mx.google.com with ESMTPS id u4sm15556868igw.6.2013.01.23.13.46.01 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jan 2013 13:46:01 -0800 (PST) From: peter@gridcentric.ca To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2013 16:45:50 -0500 Message-Id: <1358977550-8217-1-git-send-email-peter@gridcentric.ca> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQkNeVJZx68HOnPB5vclvGKBk+Eo+lOCpXz17g27Pi8PzS4lgTlnkYckGan1KTNIAE+a+89S X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.223.173 Cc: andreslc@gridcentric.ca, Peter Feiner , lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] qapi/x86: add control registers to query-cpus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Feiner Adds control registers that govern virtual address translation to query-cpus. Given these registers and the guest's physical memory, which can be obtained with dump-guest-memory, a client can perform virtual-to-physical translations. This is useful for debugging and introspection. Signed-off-by: Peter Feiner --- cpus.c | 8 ++++++++ qapi-schema.json | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/cpus.c b/cpus.c index a4390c3..e9cc620 100644 --- a/cpus.c +++ b/cpus.c @@ -1224,6 +1224,14 @@ CpuInfoList *qmp_query_cpus(Error **errp) #if defined(TARGET_I386) info->value->has_pc = true; info->value->pc = env->eip + env->segs[R_CS].base; + info->value->has_cr0 = true; + info->value->cr0 = env->cr[0]; + info->value->has_cr3 = true; + info->value->cr3 = env->cr[3]; + info->value->has_cr4 = true; + info->value->cr4 = env->cr[4]; + info->value->has_efer = true; + info->value->efer = env->efer; #elif defined(TARGET_PPC) info->value->has_nip = true; info->value->nip = env->nip; diff --git a/qapi-schema.json b/qapi-schema.json index 6d7252b..80df503 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -569,6 +569,15 @@ # If the target is Sparc, this is the PC component of the # instruction pointer. # +# @cr0: #optional If the target is i386 or x86_64, this is the CR1 register. +# +# @cr3: #optional If the target is i386 or x86_64, this is the CR3 register. +# +# @cr4: #optional If the target is i386 or x86_64, this is the CR4 register. +# +# @efer: #optional If the target is i386 or x86_64, this is the "efer" +# (extended features) register. +# # @nip: #optional If the target is PPC, the instruction pointer # # @npc: #optional If the target is Sparc, the NPC component of the instruction @@ -585,6 +594,7 @@ ## { 'type': 'CpuInfo', 'data': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', '*pc': 'int', + '*cr0': 'int', '*cr3': 'int', '*cr4': 'int', '*efer', 'int', '*nip': 'int', '*npc': 'int', '*PC': 'int', 'thread_id': 'int'} } ##