From patchwork Sun Oct 22 00:46:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116623 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3189784qgn; Sat, 21 Oct 2017 17:55:20 -0700 (PDT) X-Received: by 10.55.95.133 with SMTP id t127mr12949810qkb.24.1508633720316; Sat, 21 Oct 2017 17:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633720; cv=none; d=google.com; s=arc-20160816; b=cqgmIMcbMzp1+qqn+FJT5cBGvkR9M2a154N6EwYbJ5nIsVCMk+pPdWI1Vyu5Tp6bfb 7cnoy+4NXlvrvWQryxki6kdVAJBLNhuzuZFIHaWscHp5s+5Rg5zfWxFMyOpSgZiX2QdK p54hY+FyMkboitD3nV9hL77fEey0Y8bem9l0vM5fYYFI+cceRhFGyGfAmgRN/uMBW7Ye Io/uDYNVrlBgTBlgc7fzZFxafkAgNYWVmuCKt9WRp1c+ijgWVfzarjblDfUIL/4rpwkY LsUEmPFRKuOS7u/CtG/gkpwJsC47Xs3MKcmpTwwuEpb14PowfBiAtyEcKvcLK5pjH8z1 74fg== 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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=u2Eo0shySmvK/Gcanf/Kfbgx1Z+lcvn56DU+hji8jKeJ+eW6ZVwxGYc4lNc7jusbW7 FuvXdsnx2FRs+fGDn9GI5lf8JMUl4ne+vOqZK/rj9oo7DbmG9UMDwx3s433ZGQxjII4/ QfwhRIeX2KEgUTD24Qn5S8srPYsTt7afhMULpjil/oNJxpIsGqOv+89ulqXY1zfRZiBG f797jD57EUdCDZ+6OCkQQFjx3EWkX2WSEIaHOhJWF1pxAJdxyIQyXDUWG5ChfyaGylz+ wEPWKcIQA/Keyzi77/WkmXPvIyVCkKJENa+X8JeMqQJ3CZdrwENa1GZvLLz2n5ElwQOo YzRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aKuHYRg7; 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 x43si325587qtk.383.2017.10.21.17.55.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:55:20 -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=aKuHYRg7; 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]:59652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Xu-00006v-9K for patch@linaro.org; Sat, 21 Oct 2017 20:55:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PZ-0002Hw-SP for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e64PW-0008MP-M8 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:43776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PW-0008Lr-G5 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:38 -0400 Received: by mail-pf0-x244.google.com with SMTP id a8so14600294pfc.0 for ; Sat, 21 Oct 2017 17:46:38 -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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=aKuHYRg77no9oflkgb5lmez626Jfh5XJnnicnadnZxY74Ad5fMyeUuhf4Os1Nb2I// 4FmI+vM6jo+bRMH4LgO/pQWzFxYr2x2kFnKLSEIwo2ch2tTSkmJ/hdg4ZU81DZJkgn02 BMMV40WjRi6YN6vF/6vS4hVlj4LDMKeZPgVOw= 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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=puCw1mpzNZm71unl9qMYhdRQSm74NjFezDARl47ijh3+jhw2XPleq+g4A7wkBdfmjR mwxm2Dqdecq21JJfsQEThEzBzFSpZ3ApQLkmm+ts3igebVKgo+HGY/ztXRn/9G4QzBcT kxPsiCzLJugmWyWm+nxqfPwgBeLz1xTNBoY4iFvIW4UIB6/Nx+w2wDb9KXMjWiEPu05+ w5aCQzWVX6OtkU3hlhFXiZXYeWQ75CTCts+ngnvfgM2HRcZrnPZn5duu47g8URaBo4Yy ZNdaXyS4sulTU55Um2ZL9AnA2gwYxqLxXRajVK3vF/WRmKKQxbJeCQUrx+l/NuzNms74 zAQg== X-Gm-Message-State: AMCzsaVZM4zzNQxDZvdjKjsUISUFTi7+pFpESoCNU7K6U1Z+YTkOGimP NP5KGBg94T7GOu/FDemQtCUfQriMGAg= X-Google-Smtp-Source: ABhQp+QB3463BnYm+8a4M7LOBu4RLU3FoLpc/udlHYi6mcQfZ1uNCrnFPX6Z4g7WmUtqYw2Kv/tCXw== X-Received: by 10.99.134.200 with SMTP id x191mr7916797pgd.86.1508633197053; Sat, 21 Oct 2017 17:46:37 -0700 (PDT) Received: from cloudburst.twiddle.net (174-21-9-158.tukw.qwest.net. [174.21.9.158]) by smtp.gmail.com with ESMTPSA id j12sm5766728pgs.35.2017.10.21.17.46.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:18 -0700 Message-Id: <20171022004621.28372-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org> References: <20171022004621.28372-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::244 Subject: [Qemu-devel] [PATCH v7 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: , 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);