From patchwork Tue Oct 17 15:37:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116140 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1375465edb; Tue, 17 Oct 2017 08:44:10 -0700 (PDT) X-Received: by 10.55.122.135 with SMTP id v129mr17588594qkc.171.1508255050363; Tue, 17 Oct 2017 08:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508255050; cv=none; d=google.com; s=arc-20160816; b=eH0BrhNnJ1dvJ40jDBB0CYOgB/WOaT4wSQAzlfLJzsSexAI37ni22J78OrnTgXW4Zi 8M4Qsmydx0ZGDBYpnVM+7ALCRzATlkv+5mk8BpYETIYMRpN90QGCD54UbTSNqqjA2AJv Y8MImIW38gEAlLuTVHJpgQVd1qy1q4ShuIFEDS5Fmcdzhc9ZPtvj7cxqUMuTOMlT+qyj iWmIUbP7DIW7QkX7poqasX85fyDYfh/EFzAoxICY0Yh0VnD5slI9w4bljXndMrr+OWC1 ucwXEglfuTmVl7mrpfOrMjj+mIy6mA6Ao8bMaeuE7sVAyTbgFl5VejexH2jwT6JRJ3cS VwqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=3BLOcxnnPg/ZIwB7QEQ1fWCFx1Q2/Js7qiibntMGJnE=; b=NeKPsMCOMDwiuip0TKgoGKBcUEWiwPsJf7kXf2ttl8Q6yutDgoJT5nPVmpJY3JjEEC uTCYstUcauMQN/AE0YhabXQ/Mnn2yNY4xihsTPX7ziU5KhjzSMBXftadcX/nUEKoERNg nqN5YjW/NcyVw5XlCh5vuH7cQYmV3vpY3jA2YQAAMRu8Rgt6a2aWdEgpqXRMLzagZ3K5 JbQcq2b1pqrDfpjUwOxdjysqkNQkxGHD+j1xn1Gk0Rw8kVpC57cfIsiEe5yROXHBBFCU krPaof7LIH6M927FHp3qhNKVv3XUnfU5EzKWS1ubHGNfRt01G+4kDpAcOYXvRLT5Jtu3 /iig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PphiX9/g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s2si728473qtj.322.2017.10.17.08.44.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:44:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PphiX9/g; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4U2K-0000XX-6f for patch@linaro.org; Tue, 17 Oct 2017 11:44:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwJ-0004Gx-DQ for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwI-0005oh-Dp for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:55 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:52275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwI-0005nj-88 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:54 -0400 Received: by mail-pf0-x22d.google.com with SMTP id e64so1605147pfk.9 for ; Tue, 17 Oct 2017 08:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3BLOcxnnPg/ZIwB7QEQ1fWCFx1Q2/Js7qiibntMGJnE=; b=PphiX9/gXClcSzdvDqmoSHtqa0U9T26ynFoaWLn4+Z4IidD3/9U5xtGF1gKlcw6Q2C SZvdduXQx4ced+Dj4a4mYVpzLDp0H+Ex0Y8mxdYck+X1D43eR8rS+XYgi4PclClO73IS l+O5/5+aaT3cGPNWP6aN1LMUxK17wzjIj233g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3BLOcxnnPg/ZIwB7QEQ1fWCFx1Q2/Js7qiibntMGJnE=; b=Kf6s3WwSIY2ov+SSSy9+lC4ZhkaO1FR8LAA0XKVHOaANphyXTLt1sJokrBpY9guzCj 42UUvXV1iffluXVzIsLQ4llEd1Kjmh34+UOl12CCnleYMFwWjvsOCpshleu8dw7QI3bK KevJQSl2CMKGAm9Ns+vlR3ohSS1Lc3IQv7N2y0ZrJVBK9gTjd/LsQKt4O9OqF56Az8Q+ qSJa1w9zCs3ZkwMWcoURcJzaq1DBd9UHiF6KgNxxlz24Dtgc3lFRGlp9ZGJNdmyva/mf UZ2XBr1ct6xNC5cKAvoYLxzNCh912MPYeR0KZqw/KGsEeybLuxvQd41LyNOhsix6NIuk foXA== X-Gm-Message-State: AMCzsaVN+Ch5kMOo4TeHbAdiTnfo/ErMon/iQWZG+keVYCp81M6I5J6q uBQ2WvS/nPjhglW97GQy5cLrq+Od0ww= X-Google-Smtp-Source: AOwi7QCvLBaLlhBfA2fkEdGQKEkBF3IwVIvxcgcoHC4hCPOObJlwxxtoHrw6xJt/Qj0bK+Ny4oUPZQ== X-Received: by 10.98.137.156 with SMTP id n28mr12193826pfk.93.1508254672979; Tue, 17 Oct 2017 08:37:52 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id y84sm20094415pff.158.2017.10.17.08.37.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:39 -0700 Message-Id: <20171017153742.10026-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171017153742.10026-1-richard.henderson@linaro.org> References: <20171017153742.10026-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22d Subject: [Qemu-devel] [PATCH v5 6/9] arm: Support Capstone in disas_set_info 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 3 +++ target/arm/cpu.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 1c44514254..23c4742f8d 100644 --- a/disas.c +++ b/disas.c @@ -451,6 +451,7 @@ void disas(FILE *out, void *code, unsigned long size) print_insn = print_insn_ppc; #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; + s.info.cap_arch = CS_ARCH_ARM64; #elif defined(__alpha__) print_insn = print_insn_alpha; #elif defined(__sparc__) @@ -458,6 +459,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.mach = bfd_mach_sparc_v9b; #elif defined(__arm__) print_insn = print_insn_arm; + s.info.cap_arch = CS_ARCH_ARM; + /* TCG only generates code for arm mode. */ #elif defined(__MIPSEB__) print_insn = print_insn_big_mips; #elif defined(__MIPSEL__) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 88578f360e..1576a6d372 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -33,6 +33,7 @@ #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "kvm_arm.h" +#include "disas/capstone.h" static void arm_cpu_set_pc(CPUState *cs, vaddr value) { @@ -501,10 +502,24 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) #if defined(CONFIG_ARM_A64_DIS) info->print_insn = print_insn_arm_a64; #endif - } else if (env->thumb) { - info->print_insn = print_insn_thumb1; + info->cap_arch = CS_ARCH_ARM64; } else { - info->print_insn = print_insn_arm; + int cap_mode; + if (env->thumb) { + info->print_insn = print_insn_thumb1; + cap_mode = CS_MODE_THUMB; + } else { + info->print_insn = print_insn_arm; + cap_mode = CS_MODE_ARM; + } + if (arm_feature(env, ARM_FEATURE_V8)) { + cap_mode |= CS_MODE_V8; + } + if (arm_feature(env, ARM_FEATURE_M)) { + cap_mode |= CS_MODE_MCLASS; + } + info->cap_arch = CS_ARCH_ARM; + info->cap_mode = cap_mode; } if (bswap_code(arm_sctlr_b(env))) { #ifdef TARGET_WORDS_BIGENDIAN