From patchwork Thu Oct 19 15:51:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116406 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp647618qgn; Thu, 19 Oct 2017 08:54:15 -0700 (PDT) X-Received: by 10.55.109.195 with SMTP id i186mr2612468qkc.147.1508428454861; Thu, 19 Oct 2017 08:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508428454; cv=none; d=google.com; s=arc-20160816; b=dlfjd42PPWODCr9O+ksa+0fw6RuglbsX9FB9K0wBqB7iGXG9APPb1x5Qq8wTTxGvnb 8rvmolY+NjJj7U9+XRMmC6w9LEW50b5tmdNLwejV3Sik/L8VlTUJnU62ZLyUbfkT6fB+ bxJpjqa0wWlWcseJMe0R/ELUdv0PL4cGluklIUIllBv1xBeJ5uIEHkK+hKY+CiZpNdhT +yc/zm6VsAgJIKpkzL5R1/jvArXuzXx34PumdtCr8mMdWp/FPPTnkTp30QKyJlJ4p1Qo xH/NKDTfpCPSdRxoBR3HO9JLPrpdK6d9Z6Bc75Jsl6WZMllgQg5uGbJ9z9khP7t8c9Pw gl8w== 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=v2cfPsTL4FP75FaKJwqc72lqYTxbji6GG2AudOwx3UZTd7rDa2Fg1gaEJCObey0ZJQ ZfHLZS0ipIk/f8Y6og5Z4JwXCCB8Q3NJr/mISb/fVHR1sPirBM+bAjj7bwi2N2gGu/b/ iHuJuisZhuaQ0PugMYROgN0Ny7odWY1xU2kgSeI0FbAjYMzUaa8Z3kYLamV7U6xPBh0a gyWBpFCDP8E9n/hga+wUmCYYUBgRXXvu/y+BoIXVPGBk+Al+3eNlrUx+UiRc8nSO176m UP6yNRim8z00Qv78bMghlhhfCrUB0t2hUWjyCSkb6Ba1fG9ckJV+KUYezKvkkx3QLDiX WYqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=iiTYv/Og; 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 202si4948612qkm.81.2017.10.19.08.54.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 19 Oct 2017 08:54:14 -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=iiTYv/Og; 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]:49835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D9A-0008Na-Qv for patch@linaro.org; Thu, 19 Oct 2017 11:54:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5D70-0007BC-LN 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 1e5D6z-0000FE-Ia for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:58 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:50831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5D6z-0000ET-Dt for qemu-devel@nongnu.org; Thu, 19 Oct 2017 11:51:57 -0400 Received: by mail-pf0-x243.google.com with SMTP id b6so6866228pfh.7 for ; Thu, 19 Oct 2017 08:51:57 -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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=iiTYv/Og4vUV1DuE7+hEsKOnBybeu6p1Ue5Ll5WgHBUQul5XYUop6z0gRCkvy5hBrA 2ZVNBezsUF7StW8/IK3LAvqfQAkjlFuB/XTXafX0lU3ITTkSK0DTQBmqeXF4hNwaeTIq QZ2LKDvoQFsc4jCIqC7lGfXrEdIAG5KQ/+Cdw= 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=WtwmPAQWVUHMwjrkJYeEx5T3XPaj+qiQd6X/NwplkD4KOwulIg1pJg3SdLs7I0YfU3 PjW4Zp2Xq2CW6vhQufLkwtujlmQHK7m1ssCGqNuMQByyUMWKIO8RWJ0LgsQKeWbihlu3 6tZ3p+AAewMKD1Jg9BPXC47JlHUpzo4cP2P2ssIH1uZqINWYRE7JXIMOnlh0il2Lwo3s ifua4qg3nnWo+gZEyXJ2t+yAS91cNVvl2G36/F30s7bjnPsMEx3Jw8T5pfRkyK5IKKDj D3/q3t1t+CcSbu+WsB5b3izOxIuUl72SYuT61PyEhYxYQ9IsHT+uUSdW1TSFneztTr9o /I5A== X-Gm-Message-State: AMCzsaXHuGINtodDpldk1CmgoDeDGvi6GTrSgnkFUQjpBhP8yugZL1qX C1Lzyqbyv6PopJCobH94lFvCezQ9HfY= X-Google-Smtp-Source: ABhQp+QwcRktxjzBc7p53096ZTOQqBM+w7lco8L1TXuApiqRk/QkLz76RMBlHLNiDeGAKacDD488yg== X-Received: by 10.99.95.216 with SMTP id t207mr1743996pgb.185.1508428316009; Thu, 19 Oct 2017 08:51:56 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 08:51:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 08:51:42 -0700 Message-Id: <20171019155146.30434-6-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::243 Subject: [Qemu-devel] [PATCH v6 5/9] i386: 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: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 11 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index e392a2926e..63dc573e9f 100644 --- a/disas.c +++ b/disas.c @@ -438,9 +438,13 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__i386__) s.info.mach = bfd_mach_i386_i386; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_32; #elif defined(__x86_64__) s.info.mach = bfd_mach_x86_64; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_64; #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 13b2f8fbc5..cf890b763b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -51,6 +51,8 @@ #include "hw/i386/apic_internal.h" #endif +#include "disas/capstone.h" + /* Cache topology CPUID constants: */ @@ -4106,6 +4108,11 @@ static void x86_disas_set_info(CPUState *cs, disassemble_info *info) : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 : bfd_mach_i386_i8086); info->print_insn = print_insn_i386; + + info->cap_arch = CS_ARCH_X86; + info->cap_mode = (env->hflags & HF_CS64_MASK ? CS_MODE_64 + : env->hflags & HF_CS32_MASK ? CS_MODE_32 + : CS_MODE_16); } static Property x86_cpu_properties[] = {