From patchwork Sun Oct 22 00:46:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116620 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3188149qgn; Sat, 21 Oct 2017 17:52:05 -0700 (PDT) X-Received: by 10.55.170.15 with SMTP id t15mr12221005qke.232.1508633525159; Sat, 21 Oct 2017 17:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508633525; cv=none; d=google.com; s=arc-20160816; b=O3mIsE12KdSJ7zR3Wq5l7vKFm5LTeibLtWsD6rcPaHWzFZOAHrV3OVm4r5BkNxZaFw zbMdLQk9/g83AFtndHMltN/sKTnRgmqrawKo6n/ydvQAh55ZdbZQytAQU7G0Md8Bji/t VSl0fYltWC4Zbqw2JFUwnezzWja0aaO0h+Xo+0OF4EU31nEH5xcTnyngA4LiSPEA3tEy SBTk3xT2J7Wg21CBGR6H1YTIncJZvm8V9zReZqAsYHfk1Gj8MBWVH+0korauig0zEO7S 4HaBPmjGvHHatPpVIwchopmGwYcBiR7GaWgvys7yYLEx4FJM68AfQOvqHHwvmou3ykFJ O4IA== 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=OS3S1qBJRLjTIJMmgNCx5qlhB1Oq1JJ0wL49vtrAfst/nkvXPAB8E4kHcH1wP9/kjW oIRTG0UfI+JSutX3GvmxubRbRHFsbWlrapMn4AlPpWNKsXHZZJmgWHR/xXpFjz0m5kmp l3FjO7YYqDO4kZpUoQ6e8Jitu9uo2nWLemFPU2ai+cG/Azv6z2wYi0VtNnymPTsD33gs Oz6KHY7ZdE7HLdVR22j/lqpTWTl8hXaPBnAKXZNqFMNVormJwIiHLfVghM+g/RPMzfCg z3jo3aaYjksf0zfXJEZgwtNw4cIvsAlZUPM/tTou5FePK0bisPlf/Yzc6CMfzyY+xef3 8f/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MlC3nGiV; 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 9si1975442qtd.34.2017.10.21.17.52.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 21 Oct 2017 17:52:05 -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=MlC3nGiV; 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]:59643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64Ul-00061O-5p for patch@linaro.org; Sat, 21 Oct 2017 20:52:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e64PZ-0002Hh-Kd 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 1e64PU-0008Kk-V4 for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:41 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:44753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e64PU-0008K0-Ol for qemu-devel@nongnu.org; Sat, 21 Oct 2017 20:46:36 -0400 Received: by mail-pg0-x241.google.com with SMTP id j3so9213592pga.1 for ; Sat, 21 Oct 2017 17:46:36 -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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=MlC3nGiVANjPjHtEsuAtl+Ekhk9mGJhHIu3ujJeV4O6AvlvQ/nPqC6CLrQImlP4AWT b0gBEHovkeRWkWs1ePOTqlnYYyHcsB1E7yn85TsNvqF1cqOzFJCKenICZF89+8XQwffW NzNkJ20Tnp0tcoNM9aweyxwElrRBkAMn4y3tw= 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=j0vEvcaz9kfjSnCNBPFOl4CwKKr/yFeVqaZ+WpxglXYDVT1wY5Q77SuGeQ1tCuYONS la2rDW2GZRFJt0jhc5KnpBEcZAVr2EQpDxBZQpOwtcXP3eDAtvf4APqvoKaVhTkSyYXW wGvhRHW6dLD30Fs7hr7/8yVzQl6vJOtvVvzMDlYTr8mwDiLliYAR/eOALa+ifv8pXNN+ Twp7kKth/LdJZpDXzHVbwAVjADAN26kERN9ua5raAXKl6BL2r+bz4b+i5J9Lcb94YNoL yR/hpMBSDb285EigDzQRzI3eaZ5ckqvGnmwKXZhF/K8ZpXVXEn2S1fVIPEV0U78vaqF1 OyPg== X-Gm-Message-State: AMCzsaXqpNBcWWNu5gH+tn4GwY52P03dYc+9USd801DT4ChSJI23tcvZ /OCdZtlWoNmdsmoqNlzWX1mEHiK8NQ4= X-Google-Smtp-Source: ABhQp+QEPKIjZI2WNflITYKAxe2VLScsGolEIefx9pSXbUZ/iUTwO00+TMoL8HED0MUMm/C76DkEFQ== X-Received: by 10.98.34.79 with SMTP id i76mr1835409pfi.42.1508633195543; Sat, 21 Oct 2017 17:46:35 -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.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Oct 2017 17:46:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 21 Oct 2017 17:46:17 -0700 Message-Id: <20171022004621.28372-8-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:c05::241 Subject: [Qemu-devel] [PATCH v7 07/11] 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: , 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[] = {