From patchwork Wed Oct 25 12:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117123 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1695825edm; Wed, 25 Oct 2017 05:36:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RqqsXXsb3inO/IpqROsVwblZVwSkeqdW5jyi2CvZM3pvcQYp1lsoN0t60AqMHYC4KCVo8d X-Received: by 10.37.17.2 with SMTP id 2mr1115352ybr.398.1508935017195; Wed, 25 Oct 2017 05:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508935017; cv=none; d=google.com; s=arc-20160816; b=fae0e6fWzKvqStCLsrElWmD78Hv/sgtWezPjyoA7SxxCYCvXCh8zcY6onVzQ43xtWA 9Evk3axobdFaxpYO57BVP/1fwHkGkB6A4mRrcnTzL4iTU7wvqaXWxtIlk+O9IcMebck7 KVa6lEzhCReGY237wiTH2c5gZpAu4l92N9V8FqkZzQ9NVsKvkv4slgiooneCJDelH9wu w5j66KclZrOvcJ62t3icjJI4ndK4z6gLv7Lrdt+hklRvmJfDseDDw72M3gM2rVV5uokm qEWsZGuWEKqOi8iwCbte2Po1t+rhZqikv/QGCokkgma8Le2Q27FTasx78t7At26bJpT5 kejA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=TCN0xneNfttwKl2xUhyvfIPk2bGtYS+leDsQ70J4miI40k09ZI5x+4IuY8tuM09IdX dS6M864Hi86W6gHefY0XFadlkae+gFQtlNU52EOkhAci8+chOslX/e6/EHFRzvR5dD+5 MG4pIbu3mnQeEIRlMNZXnGEYyQhc/723gOsvp9rvjVt3MOaSo1aCBWkvrDrA/bn84yBL NdpyJTHKNJR3M825Gx16rRmAvvziN43JmO1GT7RWG56zmABbJfd+RuzGCtdvn+AfMg1M qhqpCeGp3NAoUasiZNc7xlkLwtv0F9p1LS2c6sv40km82EdnpvBsb9NJFTIIs89HHw4T 3GWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eA5nym/5; 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 z192si418730ywz.774.2017.10.25.05.36.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:36:57 -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=eA5nym/5; 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]:48106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KvY-0003PL-KG for patch@linaro.org; Wed, 25 Oct 2017 08:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq9-0007cL-Ix for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq3-00083n-AD for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:21 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:47770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq3-00083Z-3r for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:15 -0400 Received: by mail-wm0-x241.google.com with SMTP id r196so1574862wmf.2 for ; Wed, 25 Oct 2017 05:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=eA5nym/5f2Gvf/+83HohC97diuD287ZglfbhhiJIB5uzbSwuUrxFAToJ79KUGE2/H/ LerBE4U7Hx5rZEQt6F5hL7oXm3hO4Ug0F0iazBMpAVYjQWYj9WJ88KQGEJrUpAkzBLDo IYppQeK7C/Uy7hS+RwfK4Ef2XU3RNoYEifwmU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=WbjDznW0SFi8sehnHy3UEXE49bAeFXTrmknxiMB5DC+guIBamFqE36JuCpZ2yB7hp+ ieXNTwmj3hGakUwTE6hGY9MSzaV1HyR4bKIcN8hJ5rmJPQUP8zAe6iOT3KXZinhh+zjT o4q9G5Nlo7pPvagI7O32p8tXVXB3o30aLYAkpmw+/8YOeBu64RhsdbUYosOUy6gU7spW 7Zb80b9uszE0WoogCKWOx8lus2Z8TaRLxdYUK7GZjYhZtIojZQ/pgpMk5gB5ytA+IBA+ /AcWAmMkPHIAQavjsLwn0jeNAYVMCz5/ED9C+4GsfuZYeuSI+cnzgB2RiPr6krW2uPP2 DCcg== X-Gm-Message-State: AMCzsaWaF95XbBjjKbF7h4q2HbzLF30sAqHzdeSdrUoVKFj6yFQhQ1PF L46BqOUKl3L5Eo7Rc8AefRjZlNJd0ps= X-Received: by 10.28.22.2 with SMTP id 2mr1652072wmw.47.1508934673958; Wed, 25 Oct 2017 05:31:13 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:53 +0200 Message-Id: <20171025123056.3165-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 08/11] 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: , Cc: peter.maydell@linaro.org 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 63dc573e9f..8d9bd4901c 100644 --- a/disas.c +++ b/disas.c @@ -450,6 +450,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__) @@ -457,6 +458,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 a92d86faa0..a0ed11c9a5 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) { @@ -487,10 +488,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; } sctlr_b = arm_sctlr_b(env);