From patchwork Tue Oct 17 15:37:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116139 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1374381edb; Tue, 17 Oct 2017 08:42:58 -0700 (PDT) X-Received: by 10.200.24.50 with SMTP id q47mr6059748qtj.290.1508254978401; Tue, 17 Oct 2017 08:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254978; cv=none; d=google.com; s=arc-20160816; b=Hj1g+qEimvQN3CuTlrX2HWIoN1mSAhiPflIS9LxziCcrJpIYb5uTq0MERy1nAPpXIj 9ESmTb4hcdRAa38VSsCj/H0TtIt30eTnTunG2/FT3bKsFr+KmI4xek7+jw0hEiKYUTVn jNFitlblwbKNMxvEI87jFYMGxGAdjg9qR5ES0GyeQphWoyb28Hs19wJqKiF65g40AgpN IitrK4hqCZ4/xajcZY68A9Uej5Jh1c6ySECqJtKaOs1cz0AM9OrRmJPGVdXYQKqU46ra wtG9TN4ckZ/4wSE7I7tw8/wEzjtKE3Yz+7CZWrVGG84lva+JkLOgaEAKC3nGl3Zl7Oaj bWWQ== 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=GDQ7o8bMA5JYotApUrKVPtviJVZsbS/8pXdXMpY8hDw=; b=InTbs/CT3Ch8bGR6QYW1ab1BLz927Wd+aH4YK0eCar2LIY/1SOMuVskCaIY2Ky7NIw BJ5zku4Crz18+tU4hanfmjjSNMuBal3cgiEmqhvy49Eb4zMRovH/QrFA3Xk6pX67Tp/l k6Xg7iIM7Nu1IC0jUKCqVm6j5yfg5TOMgcJiHkpG8heGeexgi30JteRUe3PG6PCwjyro Oh5yHun300oHO8BTjlkxS+5jjPJ18YBd/5NKqteT6hjIdnnvzOLa+Jib9Qbqm/xrHpJF X260b+20UxVycpSrP3xiMCT5ofA/ok4Jacz2u5V27RMiMpZWtaVNt/C8Kgb01kJcraEy 80Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=d9Kq6KEp; 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 r1si9076211qtf.38.2017.10.17.08.42.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:42:58 -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=d9Kq6KEp; 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]:40109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4U1A-0008G6-5K for patch@linaro.org; Tue, 17 Oct 2017 11:42:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwJ-0004HA-Mi for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwH-0005nc-CG for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:55 -0400 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]:53806) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwH-0005mS-5g for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:53 -0400 Received: by mail-pf0-x231.google.com with SMTP id t188so1605003pfd.10 for ; Tue, 17 Oct 2017 08:37:53 -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=GDQ7o8bMA5JYotApUrKVPtviJVZsbS/8pXdXMpY8hDw=; b=d9Kq6KEpiXilScVfWot2KOPWqO9dfpFNSjBZmULt38CF5dp9fK9jcVxCNQQhV1hBla 0j4tVPPuOJXqadkE+gS+ItplmLXm24qOYS+Ds/MVIFoyRmDhQKyqbA8VxbkZAy/Yku4K Jh0BUABkd+TOW6DVsPr9c9sC/tJqNDIsGmLG0= 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=GDQ7o8bMA5JYotApUrKVPtviJVZsbS/8pXdXMpY8hDw=; b=W8k4PBH4CsYZFDviPaQhjXfaOighqyGeyvPfrp9bl1n9vAjW25xFvwsHrhFtvA+ZMa AaCxvrS2q7YiB4jl7rNYiz+GoUzTSz/4f72FE1Jj6pwIsNxuGL0y0CYlztnPPbuu+oTN OXlaLLQyzMpoipZ7HHKIWQIUOuime1PJ+64k9kMf5oaozvcsZWuDJFdCPyNzrJxAikCp jHiESQd/a3MHa6GuSFeH3w1DFaXeFzR7OK7hESKlMDAuVAF1z7kWR74IJ+ZRK9F2J1u1 52T1Z11nsB+GSHeSompW7jUd1R250hY0gY0ne5bYcc1lpWE7Ug2G7aksWVa4mMzY+a8o UtAw== X-Gm-Message-State: AMCzsaWBFwQUsSqWGSdDdSTKCQ39+3dt03W0rHNUGlbTMuxHj9cy6IRl wr13ECytMJu36pw2eJ6hjBxADkeNFOc= X-Google-Smtp-Source: ABhQp+TWbWez1FVPz0sP8aS5ri3R4U4OkwZmPAgdztgIsq4+xBmCcwzdLTaBW+MsC3ohUed0RT8osg== X-Received: by 10.98.33.15 with SMTP id h15mr5244848pfh.319.1508254671774; Tue, 17 Oct 2017 08:37:51 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id y84sm20094415pff.158.2017.10.17.08.37.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:38 -0700 Message-Id: <20171017153742.10026-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171017153742.10026-1-richard.henderson@linaro.org> References: <20171017153742.10026-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::231 Subject: [Qemu-devel] [PATCH v5 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" 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 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[] = {