From patchwork Thu Sep 28 16:54:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 114459 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp969281qgf; Thu, 28 Sep 2017 10:00:39 -0700 (PDT) X-Received: by 10.200.22.142 with SMTP id r14mr1870842qtj.279.1506618039126; Thu, 28 Sep 2017 10:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506618039; cv=none; d=google.com; s=arc-20160816; b=zGezF8HiPYbFRjPjdYBs9tihDqecW4pbTdB5IYeHIYIniGNAR0fO4AJZ6XN3wBsHPf ZwLojevb3H3p3roVkXL/Z1c/4QjBnlS+7Z8kjeq7iCUgnm23aMRsMtDUVnnj0umV+lNB YT/tRr3cnw6lCAgnYc9Dy9HtAWm5nWcL1SEobglkorYVWYYvyiVFKLhkYVTX/ypjpYyX aSKRaiDZKuEPYdI0UWa7P8Z8i98wcLOxAoz/NlB+qi15XnZu1SfNJXaUrhOTO9qpWx6A R/JAVyQvORPnuldw9qILXWNU5l4Vo8N2q4yNVmG0fbudQv0ndgz33rLEpBW3IH3GytsW A0/g== 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=zMC0NKR2kUHL8+PcGxOPQFS0+lj7R04nlWLL0JapJto=; b=ea04TepS5F1C06vsb2i2UfFGiy6Fy65RvrkgM3Dq+XWbVPjbAuph9u6UDHkP9hjB/e HVyLA+qv+HwT1Ctp0tYF9fWCh9YmPtI4AnxaDgUEnXPsVrfpgoyOGdU9O+KJjkKaLLer QKuxvotnD7DA1FIIWFrA7KOaT1/Z5rDoAS4CxYtZzacvnyXhRn81OhR07MFDwZJ9wLX6 W5gzsCyAC9Ih8p3Y6Pqo5CooD3LjPFeLUj3hILTLiEJKFDdNA/w5ppGvC+ZeO/iYnrBO M5LRk63iGFecfM3JvLPOygT7mFD48qnxVJspRAaVMgzIHV1dSfTTLARhjs7eTOdXluMu 1sVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ervqqB+W; 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 r189si1079180qkd.255.2017.09.28.10.00.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Sep 2017 10:00:39 -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=ervqqB+W; 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]:60078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxcAv-0000wt-2Q for patch@linaro.org; Thu, 28 Sep 2017 13:00:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxc4y-0004ns-C1 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 12:54:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxc4x-0004Ma-JD for qemu-devel@nongnu.org; Thu, 28 Sep 2017 12:54:28 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:54707) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxc4x-0004M0-D1 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 12:54:27 -0400 Received: by mail-pf0-x22f.google.com with SMTP id d187so1138635pfg.11 for ; Thu, 28 Sep 2017 09:54:27 -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=zMC0NKR2kUHL8+PcGxOPQFS0+lj7R04nlWLL0JapJto=; b=ervqqB+WypH7k7hFNAyDyv34978kNITzun3oAz9l7qjk5Gh9XofMK1gvMPwqNwbnef r8h/0KGn9+r/m055BzwevhJWZQE0mkeeJjEM/dgOTo2c0APtyOstTnFisnm+O7Cu0tq8 hn0xikQN12H/GLihsbov+EB0sqsBJwXDiSvpo= 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=zMC0NKR2kUHL8+PcGxOPQFS0+lj7R04nlWLL0JapJto=; b=hWAyNkM8jS5HtKkdJR4zI2na9vGamnZrATpOpcUUUigR1BXTW/ivu6Wra0Xp/JDrMl 17fH+gJLFqHqX+BF3RA9pkrkcmWIZh/V9qLe7iQCtPXZ+9Iyzidlyt8+0wcr0ydyMz8V zDtY0HiExi+EtvwLrSSH+GfHyuSS2OZQXYP/Q1BFtGGVfBQpt2E21IRftIpMfZeER0od AouC1Y8QwTNzNP4VMcJx7sFPEKPtogGX7LtOv85BEOiE8wD0VwVqq9XyvhTqjbeQSAhh 3N0bbINfhB9QyOhVtt/pEDkzAe0Dw4dyXbmWl9pBR8E+N6iyZg/KBt3h5BQ3BWSVPu91 SePw== X-Gm-Message-State: AHPjjUh7HzlFRKHnZPjedvnvbhTcBAzqPus0dV8VIRTeGGk+saAsyFXD 1wv/SvrD4YyAo8zNDvdX8+0uFPjvOhc= X-Google-Smtp-Source: AOwi7QDNRZNrlj18IhNkZNkLJOnhRJY2C2N4iuvEYjjjsCy+JmKypqXSPHNTWD7o9DT+AoHNYBqwBA== X-Received: by 10.101.81.137 with SMTP id h9mr1113289pgq.347.1506617665988; Thu, 28 Sep 2017 09:54:25 -0700 (PDT) Received: from bigtime.twiddle.net ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id e133sm3062332pfh.177.2017.09.28.09.54.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Sep 2017 09:54:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Sep 2017 09:54:11 -0700 Message-Id: <20170928165414.7339-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170928165414.7339-1-richard.henderson@linaro.org> References: <20170928165414.7339-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::22f Subject: [Qemu-devel] [PATCH v4 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 Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 3 +++ target/arm/cpu.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) -- 2.13.5 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé 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 4300de66e2..e5f84066b4 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) { @@ -489,10 +490,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