From patchwork Tue Sep 26 20:14:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9972679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCAFA602BD for ; Tue, 26 Sep 2017 20:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2E4528BD9 for ; Tue, 26 Sep 2017 20:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7A5E28F99; Tue, 26 Sep 2017 20:16:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C58828BD9 for ; Tue, 26 Sep 2017 20:16:27 +0000 (UTC) Received: from localhost ([::1]:50978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwwHK-0003D2-Gl for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Sep 2017 16:16:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwwFc-0002wO-0m for qemu-devel@nongnu.org; Tue, 26 Sep 2017 16:14:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwwFb-0003DN-7M for qemu-devel@nongnu.org; Tue, 26 Sep 2017 16:14:39 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:46177) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dwwFb-0003BO-2F for qemu-devel@nongnu.org; Tue, 26 Sep 2017 16:14:39 -0400 Received: by mail-pf0-x233.google.com with SMTP id r68so6078534pfj.3 for ; Tue, 26 Sep 2017 13:14:39 -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=H1wqHIjont5qZFEBAawyVACPy8IpDxXA5bA8KuHdecE=; b=O/KhGcojlmhrI000TYo9EvdiD7n+1rmCaRTThRpoUJLXHru8CYbRn9O0TOhR4h/Lq7 SaHIukBHX1+mm/U/AvHyP1ogjAllLYOnnfEodGIyJjyzgnM6A63U0FZFp2COGPH3RROh nm+m19fBz6R4TdGaTHOrYXOaj8dJy1SAq/kuY= 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=H1wqHIjont5qZFEBAawyVACPy8IpDxXA5bA8KuHdecE=; b=UDZqrHLtFl3svIrOFI35nvXDXsGczdoq34hVccfoS+/as/2TpdIHUT5pBdA7jyPVpx /V+EtkihfDIWL+WOzgsxJW9uN+8euF1pu1INgiWu8y43eKYLE7zwrrXbWCvLXsYqzwbc ntEV4dgfcMUuFdm69ajDItjhXFUFxqFefj9D/IjpVH5INHTlEsI8BR8U2IBSwsc6NgfM M+A7/I0CbC7GaliKGJIrr65vnJJWO6zUWCEd/x6TeoIcHYI7n5cFi2qr+Mj0GCg8pZvm wS3LxZ0ZLA7DIDHpqBt0R5q7kSlF/5nL6W4/rqtgT7SiYKXSXaW8e+1LwfvOAwj3tEy3 mTXQ== X-Gm-Message-State: AHPjjUhQSkcuhCSebJ4XKosSYFOL8Hx9TePJPKHO9JdO9Eu/0enk1J6P 8sVlXQZL4FfoebCEWLqEGQU+tmv6bOc= X-Google-Smtp-Source: AOwi7QDH7K+D6B+0sdadbZdyhXKUGwbkVEo7rBDmS1ujSm+lcedHtD8A2zdWfweEIMkVDPg+fTwJ6g== X-Received: by 10.84.234.137 with SMTP id n9mr11848517plk.383.1506456877885; Tue, 26 Sep 2017 13:14:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Sep 2017 13:14:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 26 Sep 2017 13:14:23 -0700 Message-Id: <20170926201427.2833-6-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:c00::233 Subject: [Qemu-devel] [PATCH v3 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: peter.maydell@linaro.org, qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/disas.c b/disas.c index 746d76c07d..1c44514254 100644 --- a/disas.c +++ b/disas.c @@ -439,9 +439,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[] = {