From patchwork Thu Oct 19 15:51:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116412 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp651719qgn; Thu, 19 Oct 2017 08:58:50 -0700 (PDT) X-Received: by 10.55.152.132 with SMTP id a126mr2717839qke.12.1508428730898; Thu, 19 Oct 2017 08:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428730; cv=none; d=google.com; s=arc-20160816; b=UiOAsXiAbj06XBp1cfLJkV2oeF0gOGWGTR3PgZwwoQFfo17EGaJgHWSLbufZ00dbiu Eq9OkEHnPKN8B7WSzYAx1HvKEeJERnGjSRdILrW6fqaLDG5j5P92eCj307dndSmZAktJ y84Wn2TK7iDyXYRN1mMC5s1ufxtlP+vOtB2lEFL0+ElR2s6OPAILveyyZbMySWMssIhc sQFV1p4snepPOFhSLfB9AkWRMWU5GQqJQPwIwj9rSbnAhja8vqXTXRCWUN0tFMjJThlH 0lnuSXHw1U+RHS0oL8wL69rrdxp1gmNtQ4cXQDbaoihkE4ysrPGFJmCFUWklSNQbe4mv aCHg== 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=rWY4OMdoeV9v98K8DBlMdcrG9KdMMl/feKQRxVN3ZwI=; b=YelbbLcplQTcUOBS4yekqRv1zw2a0mNM+hSlXAn3vfAbe3E1gR+pr6pAoPdoNsorzL nUFUBIl9vnCpqYrs9bSMcODRTQErylu9P3S3u3GO1yMvG3aF0XAtNZdf+xdSlfmyIaZT OcCr8zcVhQJb/g3qxcg/L0mDZp/tVHuHtoJexCcpymi7rl/0KT0CZBaBgxyfNIveD5p7 Gn7pK7hl4Oj1cAxkvL1SXyeKlUTslSHeV9QbHKSDni7qUZ6xy177/wPJGhJYVCzHVoN5 +MhyDIZoZ1Alau28S4/tW4KRrqX3x5xaL02RkL1hT3dcoK3d5TGwQPV/HEKA0hKl2C9l HBTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G76cTymy; 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 k7si161634qtk.147.2017.10.19.08.58.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:58:50 -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=G76cTymy; 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]:49855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5DDc-0003n0-T7 for patch@linaro.org; Thu, 19 Oct 2017 11:58:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D71-0007Bp-Pv for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:52:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5D70-0000G8-VM for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:59 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:54331) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D70-0000FZ-PR for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:58 -0400 Received: by mail-pf0-x241.google.com with SMTP id n89so6854418pfk.11 for ; Thu, 19 Oct 2017 08:51:58 -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=rWY4OMdoeV9v98K8DBlMdcrG9KdMMl/feKQRxVN3ZwI=; b=G76cTymyupc4s7VFY9TUpXV2FEa6XyhO5ZIzmObOUni3MWefRlkME0qbL2rCvAGv+O JKd9JEY0vhMV7Tf5PYT2v6v8cGRVWIO/2hyjGBgmtn5mRVhk4oaeycItQrOHE+wPnyg7 HVDRgPesCc0AG1ayBnUTxvHL9c5F7jNu9ENDI= 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=rWY4OMdoeV9v98K8DBlMdcrG9KdMMl/feKQRxVN3ZwI=; b=k+iFgvILiqdPm/bfRQP0xXXiXLwvmIIkiRnGayLIMyJB/IwZ7sJqt4TH1/QZXjFkzm w3UpZtHxQ7Q9DFlP47lL3MPREs9VlVaZY+4Km0Ij8vavb4Ys5yPfvQFM+/JEeIe2Fm9d 1JPKuowmJHu3jvZtcHmybEQLAbByNpblZLNds04YIb+c+Ena/QB+uC/PjkDd75bqzgEm Z4fbLnFlks3ruBYKljs0rSkV0DbMMNkL/RPudxyg8OZk/hkePSuZiYHHlEljllpSaGMz HzTyfqOYWLdShsTU5qAlZzIbRvKprEggXv1pQZyxjyvvk/O1mgyBZoCrt1kfeVEA5PHI YkCA== X-Gm-Message-State: AMCzsaVfl8a2aS2VD3UWQNMRcTHr/O3RwwWkkkrjpInj/cPbaqpPWdjy vgF6I7TOxZAWMFLubBeQEem3DLmazc8= X-Google-Smtp-Source: ABhQp+Slle6XckJ1ZiDB9j6NQGXbBND0YjcHTr5B63XAx9JT1Fn3iAM065rrin0z69M9/pc/6kuKng== X-Received: by 10.99.133.200 with SMTP id u191mr1766522pgd.426.1508428317451; Thu, 19 Oct 2017 08:51:57 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id 76sm27971114pfq.4.2017.10.19.08.51.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:43 -0700 Message-Id: <20171019155146.30434-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171019155146.30434-1-richard.henderson@linaro.org> References: <20171019155146.30434-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::241 Subject: [Qemu-devel] [PATCH v6 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: kraxel@redhat.com 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 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