From patchwork Thu Sep 28 16:54:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 114458 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp967170qgf; Thu, 28 Sep 2017 09:58:32 -0700 (PDT) X-Received: by 10.237.39.219 with SMTP id m27mr2008621qtg.34.1506617911991; Thu, 28 Sep 2017 09:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506617911; cv=none; d=google.com; s=arc-20160816; b=XqY8LxT4COutDfRb1GW3198XaBxW45t2P9c5yCgQN6OT/ZBzDmWpAMxf66sDxeNv5J CmiVzxibHAzErsQkJDUWkM5Rnz/lOVbgFPcT6hHpJZOEdrQi2UlsNV0cdNAg1nn8zVZ+ dcAKXMXjXho4YGjo5tM3Ih9K9j8jwitIeksXKWyLgxGm7WrXlIvULY43RkpEA4Gir7Go /aLYoZjAOWqXc3RTofpqPcge3XZZNBWru012yq5DqtZciw25ZS0bLRx153rrgrugAOf4 MzLntSsc4KjcnTOyzFMNE8egWRonWQwbBIpLyVS923OJ5yH+wpJ2P4M4t4pj5+pa5SLE rxWg== 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=H1wqHIjont5qZFEBAawyVACPy8IpDxXA5bA8KuHdecE=; b=BUSuE9yT/qy6a1YqO6GsruhJeKC5ppzRnd/PROm3yEmquMTfeFMKfmb8dAbp2LlnZw KewAGAId9BOyN6mcYkHzMQBk7vfZEqbbx40sBiIyM4ec48SqljEIgIRf6YAfYXYgKrPF Uoa48ZvvI+fA+6VOnOGiXaofZ0yklOfOSChmYTM+1p57hIV6YRZuTA3UIY4erKnBV0nr sXxBQiCEndduhWH/lG3RINJ45QaSIMj9XLCuHG9lIhCeJgjoQJibsA5pjsoF4lE1voAQ aEY/U7sYgufGlOeCxd/BH96qu8w6AOaV7I7Ldkc/Wkl6HnrBWxNWKbUUKeYGzTtryOf5 8V9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PEw2KURq; 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 b32si1952032qtc.127.2017.09.28.09.58.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 28 Sep 2017 09:58:31 -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=PEw2KURq; 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]:60073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxc8r-0007fY-U6 for patch@linaro.org; Thu, 28 Sep 2017 12:58:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxc4y-0004nn-7I for qemu-devel@nongnu.org; Thu, 28 Sep 2017 12:54:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxc4x-0004Mh-Jx for qemu-devel@nongnu.org; Thu, 28 Sep 2017 12:54:28 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:49170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxc4x-0004MD-FS for qemu-devel@nongnu.org; Thu, 28 Sep 2017 12:54:27 -0400 Received: by mail-pf0-x229.google.com with SMTP id l188so1140943pfc.6 for ; Thu, 28 Sep 2017 09:54:27 -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=H1wqHIjont5qZFEBAawyVACPy8IpDxXA5bA8KuHdecE=; b=PEw2KURqX8Iqdmu1PhPB4m6IguEiUj/RHp9mArBVvi8dcbh4W269b4s+MCeHe3ce9f brNmyEosepcgazgDPsxTt7Ofxd/XbD+L13PPM1+0HOyLLRaCQ+qVt9ldzYgYqxLF4UCf KNPB4IrJGoYiN5CMxtXzJyTQCBYfkkRmIc1a0= 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=H1wqHIjont5qZFEBAawyVACPy8IpDxXA5bA8KuHdecE=; b=WSr1qLEwZorLKF+gHg5IqJBeH+wQE0OtXcKfYVKQX6/HUKQe6iiqX1JdesGl4ZIXQW mqGcKnp6/EB203KNnoiI0ywfYHnuQm4wfxpo6cxysNJkxS7nMxsZy6jrQfIs7+P4wDyC ExRW0/ZRIyxweiwUUGC3oqixbS1Yl/VI7Qlb9EGQ3JCUDSHHW06NFne2MnCdssirncsy zqd+EwhCf04K8adIkuGGPcm329Mt2wrxpSd9OxAGVHrM+mkzSCq2fGd9FP4aLDpHoJxv bRP6UqBbcE02Cy8GAZH3H0HRuojkJ2OM88lhbByx843u7CPD/P/tOLomRvoA6Fv53t5j vgTQ== X-Gm-Message-State: AHPjjUi5utzss1I0RmBONESBCkSaJdxXT+A+0/KNrsNTtqqpE7olhRGM NzpZFzZKsqK5VQb8ZGK/nXdka6lPyHk= X-Google-Smtp-Source: AOwi7QCtbhKpMjqWMxz+8+2tpqFR/TUDTCnnFoozWQ8iSxFgkIHZG4+8m5XYKHf7wZaAoj+mvjqOKg== X-Received: by 10.84.233.70 with SMTP id k6mr4576068plt.138.1506617664743; Thu, 28 Sep 2017 09:54:24 -0700 (PDT) Received: from bigtime.twiddle.net ([70.35.39.2]) by smtp.gmail.com with ESMTPSA id e133sm3062332pfh.177.2017.09.28.09.54.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Sep 2017 09:54:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Sep 2017 09:54:10 -0700 Message-Id: <20170928165414.7339-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170928165414.7339-1-richard.henderson@linaro.org> References: <20170928165414.7339-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::229 Subject: [Qemu-devel] [PATCH v4 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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.5 Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé 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[] = {