From patchwork Tue Sep 26 20:14:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 114293 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4244117qgf; Tue, 26 Sep 2017 13:23:25 -0700 (PDT) X-Received: by 10.55.123.1 with SMTP id w1mr16884793qkc.114.1506457405173; Tue, 26 Sep 2017 13:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506457405; cv=none; d=google.com; s=arc-20160816; b=xLSPRG3an5vusyNluhofK0Z6OnRn+/fioA4jES3yNjs3tjRHkdDFVRQK7Nk4qAJlDe hoCbvtzxMgwx4+KNXeIrsKEOfR0fMPGCNbCKI08P6R9xjP8PO+zNYULWQHRZUgSkR0DO RmlBlc+tDpjuutXuf3+6nf4DnC8A8dSYXZfv1K8Oi8JmMGprv25BfBi1i/5Ckxxejaxf vvzss+ezfPsYofpRBiyzEvD4ePdUR+aElF9y2u7mZAVKQPDQiwI813X8AV5cnfrmAJAG jw6JDZRb+gVAIdvvqMJu+GCCxZLECE5YyAMUqBwW5FyJ/Y7bmR2lu7sKboGqyhhmt4L3 lgSg== 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=zMC0NKR2kUHL8+PcGxOPQFS0+lj7R04nlWLL0JapJto=; b=GeUOzbDDU8GdUcosLyO/SfDmL+a6AX59TYpqJ7cQgKqA9JmzCYnFU27b99seqcNxB3 wFkmzHUfaOQhey3IPMCGcrd+UoXUuss/btWTMoGY1OZFRTYXuRTWhEQ5AsJ1XBOvkGnh od34i1nAyeZ0dotxVxme87Dq8Zt+XKtqAfTmJYkCaAMmLO0Eq7c4BdIik3XGSzrSl3OX 3afV7fAjRsOoTB/HR831sZ2sPz9eJtO5LmGLBqFoveH/HhUYli+ETFxnTfNuAi8/OmG/ h1Cj8RgZpIGWNFXUaSgzEi9H3NdX9PSEn7JDaAXTkjzGJw6b7Ps4uKDQ+xaDqe/VicVI Qpqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kWsFTzPG; 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 j63si2476721qke.421.2017.09.26.13.23.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 13:23:25 -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=kWsFTzPG; 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]:51022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwwO2-0001U0-Vv for patch@linaro.org; Tue, 26 Sep 2017 16:23:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwwFf-0002xI-8R for qemu-devel@nongnu.org; Tue, 26 Sep 2017 16:14:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwwFc-0003El-Kr for qemu-devel@nongnu.org; Tue, 26 Sep 2017 16:14:43 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:46433) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwwFc-0003EB-Fi for qemu-devel@nongnu.org; Tue, 26 Sep 2017 16:14:40 -0400 Received: by mail-pg0-x236.google.com with SMTP id i130so6514097pgc.3 for ; Tue, 26 Sep 2017 13:14:40 -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=zMC0NKR2kUHL8+PcGxOPQFS0+lj7R04nlWLL0JapJto=; b=kWsFTzPG7z7fGpL4vVm61fPSZsbyhd6xiw3kQ15pkIQJXHEIKHnmejeL8MqYE0dx2R oGKD9IOjZD3oxKrPhddcrzBXOyNKSwcIwvEK9EjQTpLYoZCF/QOYiHTSPhvI900a2mcM MLjpwCR4ayg9RChOtDNCQi+edM8SG35bPB9pc= 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=zMC0NKR2kUHL8+PcGxOPQFS0+lj7R04nlWLL0JapJto=; b=daoTJc6QSCjLqc3N8o7c4aeUvXajaQl7n1b0NI+EwyzggEQ1bpeGZH2a6Z6GmqmOX2 LLhn4xtDISVkOTtmzr9YU4cd2cNcvmUSIDPvQYQlHoPlUwNtneIfxwbvIaynjni3xkwT 8hvJQkfdQOJjc9kt2JGw7tH9qdYDhrubwHe3RY8AIZdQ08mhrwoJ8MXW2XH6Nri43/q+ LGf9cfmgobKihjNLFv/1h8nhIhDN7ZZam0U5gvQDBGSKmx5N3tTL0JVQaEsElMT9jOt1 7oopvu7Ru7j+e+ST3YD4TDpf0zCFju++6fEkl+uHvq+VcNJTBNIsXlRsfTNZRpwvBZqm sXrw== X-Gm-Message-State: AHPjjUj3dHqSUfKbRj91ZBNvizFid8IpFSVMBrvxgvFvq0BfCiAf1+Sv VPjM2Ve5dyOhlGguGuY4MJvfp4DtscU= X-Google-Smtp-Source: AOwi7QC5k6Agcp6oWQr7Lb4SEutoLoGuxrHMAXsm5sxAU42853AuL0TR+uWjsBK4mKgv609MDTzsPA== X-Received: by 10.84.238.142 with SMTP id v14mr11825802plk.388.1506456879353; Tue, 26 Sep 2017 13:14:39 -0700 (PDT) Received: from bigtime.twiddle.net ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id r138sm15582470pgr.12.2017.09.26.13.14.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Sep 2017 13:14:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 26 Sep 2017 13:14:24 -0700 Message-Id: <20170926201427.2833-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170926201427.2833-1-richard.henderson@linaro.org> References: <20170926201427.2833-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:c05::236 Subject: [Qemu-devel] [PATCH v3 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: , Cc: peter.maydell@linaro.org, qemu-ppc@nongnu.org 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 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