From patchwork Tue Oct 17 15:37:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116132 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1370064edb; Tue, 17 Oct 2017 08:38:23 -0700 (PDT) X-Received: by 10.55.214.17 with SMTP id t17mr19467956qki.199.1508254696164; Tue, 17 Oct 2017 08:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254696; cv=none; d=google.com; s=arc-20160816; b=dhZ7LY5AZCFbufelzKV0yEsrfLpQjzxPq5rLXbWzeSV//Igb6OQQCqEM/C4EnpaKX+ WZe229sTImQGb1eAbiLWwZANr3ujAx/AvUMxYw5+QbSPRYj434mJjnSsudU9zgGDoXpm 9tW/1+jNtf2JI3P+Yfw0HitnetEovm1j4mkmOdZmsjK5WWQnkIfLDNbjBi6Mjuecu3Cs 33pGQYpnn+SYxTMWSZp29EWDX25jRIS8+wjQrM2G3VdQ+ktY92I6iZ1FSBXH+Y1HExgy QekpPNstgBXT60YX3W/m98jzDfUrzSFuird6nx9vBtj6WzL0LZP8WEAufoK/DhoiE6QT 92yA== 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=iwMm53bCPIaibzK+BrQzHlrVfAW5jrzMH/23z87sg3I=; b=PDJgD+oCVAGeDAMj/0jFej1aEjh/PPiBtzGKzlsOeypE40c93vgBHk86z+gTWLh4Oh GB76V9vezrzNO+7XBJ0GOk0UK9MIIOkt48+0E8CE3NNPu0ZblBa4x5nJJqbk8xBG3vCt cr2OpHngZQTw5kBkTeriG7EmTk2LoCXWrgiTbSI930QHR/rMQqlwNDzEyEpVQdvvrOwU AkDvFseYmunF1O0hyvjAt1TB9u4cdTLMliINAmqJbp2dEC8WzUP3r1ZKXL+pof9b5MfZ /mg6qIS805divPrxVYt3DUoXYnJjGVsPssiIz97+9mZYC5NvK7h6eoBUqS3aPVIxeJM3 M/rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=baNrs4Ty; 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 x141si4250507qkb.235.2017.10.17.08.38.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:38:16 -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=baNrs4Ty; 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]:40091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Twb-0004Dn-R4 for patch@linaro.org; Tue, 17 Oct 2017 11:38:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwD-0004CB-Ns for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwB-0005ja-HM for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:49 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:49723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwB-0005jJ-98 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:47 -0400 Received: by mail-pf0-x243.google.com with SMTP id i5so1609315pfe.6 for ; Tue, 17 Oct 2017 08:37:47 -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=iwMm53bCPIaibzK+BrQzHlrVfAW5jrzMH/23z87sg3I=; b=baNrs4TyOKRg0Efa/Bj+Nnf8T2WeOWdpCZLvTetHcfNWi6nbCF5fRyjxlcpL1/Q3MJ VeGPdRAhyXSJOrupavzI6Hh5EJZWbx/NkKlnRdt4BWi2v1rUOaRvMKCC3K8uw3I3e4Ku wAlbMKnnqX9v2mu4tSeYxeR4/SmGwjKJmfvdo= 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=iwMm53bCPIaibzK+BrQzHlrVfAW5jrzMH/23z87sg3I=; b=dTFUXRfXQyicuiYfgGjsm+x+oQN0q0fLvGZQiqoMG0gL0LPt2+tNuG278kuw0R5u45 2a3I3aXIp01tQkau1ejoLZAGUavG7xNhIp+kv3IrIs6Fo7EoN4obVIJ3GTBwEnkGX1D/ wUnmekN/L7oT27Llclb0IVtcy2JILOfzrkhSRk8YH3yuWUJttwf1VTvuBRriUTL0W/di Or1fWidGNFJD20zc6IKtrSYVL+6+rPugQ1sXQZG6Z4h6C3fBBrBppqkrOVKch9nSj+Yb zTtZKvBJ/8QE8UwP3PjVdFxs+MiN91O/qHKT4E9Y0BsxM1OZ4MVmybiqUj/Wp1Iuhqrv oKEQ== X-Gm-Message-State: AMCzsaWqk5Plk5+DtsLVtixpFHVgy2+ucXHBL9+DC4eOFdhRA6/qgfMB CdSB/feBN4brDlNkj879RsKzvpzdYB4= X-Google-Smtp-Source: AOwi7QAU8v+SBKON8YKrGehuDQI9Vr9dHDbu7+MIAVajnRHXe9OFY9lvFWLZnrkkuoYc6ZF2JndOQg== X-Received: by 10.84.248.144 with SMTP id q16mr12646245pll.345.1508254665958; Tue, 17 Oct 2017 08:37:45 -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.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:34 -0700 Message-Id: <20171017153742.10026-2-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::243 Subject: [Qemu-devel] [PATCH v5 1/9] target/i386: Convert to disas_set_info hook 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 | 22 ++-------------------- monitor.c | 21 --------------------- target/i386/cpu.c | 12 ++++++++++++ target/i386/translate.c | 8 +------- 4 files changed, 15 insertions(+), 48 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index d6a1eb9c8e..2be716fdb2 100644 --- a/disas.c +++ b/disas.c @@ -205,16 +205,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_I386) - if (flags == 2) { - s.info.mach = bfd_mach_x86_64; - } else if (flags == 1) { - s.info.mach = bfd_mach_i386_i8086; - } else { - s.info.mach = bfd_mach_i386_i386; - } - s.info.print_insn = print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if ((flags >> 16) & 1) { s.info.endian = BFD_ENDIAN_LITTLE; } @@ -390,16 +381,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_I386) - if (flags == 2) { - s.info.mach = bfd_mach_x86_64; - } else if (flags == 1) { - s.info.mach = bfd_mach_i386_i8086; - } else { - s.info.mach = bfd_mach_i386_i386; - } - s.info.print_insn = print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if (flags & 0xFFFF) { /* If we have a precise definition of the instruction set, use it. */ s.info.mach = flags & 0xFFFF; diff --git a/monitor.c b/monitor.c index fe0d1bdbb4..a736ae9a81 100644 --- a/monitor.c +++ b/monitor.c @@ -1310,27 +1310,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (format == 'i') { int flags = 0; -#ifdef TARGET_I386 - CPUArchState *env = mon_get_cpu_env(); - if (wsize == 2) { - flags = 1; - } else if (wsize == 4) { - flags = 0; - } else { - /* as default we use the current CS size */ - flags = 0; - if (env) { -#ifdef TARGET_X86_64 - if ((env->efer & MSR_EFER_LMA) && - (env->segs[R_CS].flags & DESC_L_MASK)) - flags = 2; - else -#endif - if (!(env->segs[R_CS].flags & DESC_B_MASK)) - flags = 1; - } - } -#endif #ifdef TARGET_PPC CPUArchState *env = mon_get_cpu_env(); flags = msr_le << 16; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 98732cd65f..13b2f8fbc5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4097,6 +4097,17 @@ static bool x86_cpu_has_work(CPUState *cs) !(env->hflags & HF_SMM_MASK)); } +static void x86_disas_set_info(CPUState *cs, disassemble_info *info) +{ + X86CPU *cpu = X86_CPU(cs); + CPUX86State *env = &cpu->env; + + info->mach = (env->hflags & HF_CS64_MASK ? bfd_mach_x86_64 + : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 + : bfd_mach_i386_i8086); + info->print_insn = print_insn_i386; +} + static Property x86_cpu_properties[] = { #ifdef CONFIG_USER_ONLY /* apic_id = 0 by default for *-user, see commit 9886e834 */ @@ -4216,6 +4227,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) #endif cc->cpu_exec_enter = x86_cpu_exec_enter; cc->cpu_exec_exit = x86_cpu_exec_exit; + cc->disas_set_info = x86_disas_set_info; dc->user_creatable = true; } diff --git a/target/i386/translate.c b/target/i386/translate.c index 5d61fa96ad..046fc5dfe2 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8520,15 +8520,9 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); - int disas_flags = !dc->code32; qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); -#ifdef TARGET_X86_64 - if (dc->code64) { - disas_flags = 2; - } -#endif - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, disas_flags); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); } static const TranslatorOps i386_tr_ops = { From patchwork Tue Oct 17 15:37:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116138 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1373701edb; Tue, 17 Oct 2017 08:42:15 -0700 (PDT) X-Received: by 10.55.215.93 with SMTP id m90mr19069042qki.197.1508254935047; Tue, 17 Oct 2017 08:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254935; cv=none; d=google.com; s=arc-20160816; b=vNHZU4WoLIouo3W/ka2tz8DzesO2BMjhjv2vI7GqM85UeqS1t5NwRz7zBAuiVWyGc4 pHiMq2o7ofTY5CxI6vVjto5tJ9AWjmaf/XML6OiGk3HGGvxsIdZzr/zFkicFNL0Pn8Sf KxmqSBBrZxohIDSrGq7y6i5zk3p37TqPBEkffTS7EPSuF5OHQxAwzgAE81MJQABHbPzb CGbO7dXhDuX2eUv6DMwweCk5gxzaf13OU5pG08L+zbbmDbKFIPL3aTwkStL+k0asqm3e ZBwda96dqmgfZsnm8pcKuuwPt0gnQNLBB0thCrEL3NJzYv4i824kDzPAePVGQSN/QZmF dB9g== 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=DujOZWDLQXyTmFWZGQ6qNVKoVqZ6fqxl5TfOEJNh3AQ=; b=d68uYW0vKfQgn/F786XovS16AAtmxoaOu1d1WeaxHiTrxKI6uVqQ83wFxYKoTlVJlC lMPuDE920jaey0K1Zq6JlhZLacr8nYxOXtNKACsdGydRuLhG7TyrgsOmJ0cApZ6zGOpZ vpFH250oyK7GUoWJDniuoMeBoUo7mdzRQ31RNqJUzTwOnq45wB3kf74lsPRZpHRnQiqy jsik+HvoLGrRutWw5kSFkMGV8D1nKKGSso2cPoKpQgTK1kNzAq94iQ2KBhxoZriatVry EjuwmyouP1Q7MsAtBx2sEINQQ600rmzBbS9oUduGCiuvmmksbEV/UFQ6VPq+80/hw9dg Yh/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B6Pdn1Fx; 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 t30si1593205qtg.264.2017.10.17.08.42.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:42:15 -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=B6Pdn1Fx; 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]:40107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4U0S-0007RF-Pj for patch@linaro.org; Tue, 17 Oct 2017 11:42:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwE-0004CC-42 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwC-0005kI-UU for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:50 -0400 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]:44614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwC-0005k0-M2 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:48 -0400 Received: by mail-pf0-x22a.google.com with SMTP id x7so1620398pfa.1 for ; Tue, 17 Oct 2017 08:37:48 -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=DujOZWDLQXyTmFWZGQ6qNVKoVqZ6fqxl5TfOEJNh3AQ=; b=B6Pdn1Fxz6C4w0DZ9Wtv9vTL90mEWdTChex9w3uiMDAxxaOVKd6TRqv5MxXblewY9s LawLseK7j9x0Pjmqyiwm2R3Yx2JLtSo4uNxL3pQCTBFM0LCMTCN3SyqH/xCij52u+L90 Wqw+yRoW1bBanTWLLaaXEoBVSvejnwrWd51xc= 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=DujOZWDLQXyTmFWZGQ6qNVKoVqZ6fqxl5TfOEJNh3AQ=; b=kwNWo0oBXJLO3DwvFRLBoIwd/sCmY0VK59E1nuIbRrNDwaoBGCFxmSvISfxDs1lIH6 oKdAVetuCD9tq732I66mSoBcc2xrj6xGayLqzZuYWx+AwYTyqqp6oYgJf90z22V6IMxt BJD5cCbnhMAdq7ErBt2fFwJwLQjJtshxldI/dAbfb9gON/VQgu6/+16yVN7AQpmNRiwK jUA3F59TOgws8Mn0IkDwyu8Tx1DVtr7XC/Q2DIlPnOMAokwwjwbRD3MkM5D4DR1v3OZX HDb62GfXpgd4eCbqOH5nmE1W9t0m78efsswEdWf7PtK3bmETvR7PDFtKuFOKYQWNzw1l 0bJQ== X-Gm-Message-State: AMCzsaXXuAWVkVeoFbrCATlVizwsE+4F2tIVS61hyPQoj1esk8PoMaz4 sFD+mw5Bt3IT9WqvfptSXd56FPkTLcg= X-Google-Smtp-Source: ABhQp+R1WTjnGaG0U0cJjwKYo6whmD6AdAtaGxBV3/aSDtgxtO0jNH1O2lro7eEqVd+nA5HhL85/zQ== X-Received: by 10.84.164.104 with SMTP id m37mr4356311plg.242.1508254667351; Tue, 17 Oct 2017 08:37:47 -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.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:35 -0700 Message-Id: <20171017153742.10026-3-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::22a Subject: [Qemu-devel] [PATCH v5 2/9] target/ppc: Convert to disas_set_info hook 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 | 33 --------------------------------- monitor.c | 5 ----- target/ppc/translate.c | 5 +---- target/ppc/translate_init.c | 21 +++++++++++++++++++++ 4 files changed, 22 insertions(+), 42 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 2be716fdb2..3a375a3b6c 100644 --- a/disas.c +++ b/disas.c @@ -205,23 +205,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_PPC) - if ((flags >> 16) & 1) { - s.info.endian = BFD_ENDIAN_LITTLE; - } - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it. */ - s.info.mach = flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach = bfd_mach_ppc64; -#else - s.info.mach = bfd_mach_ppc; -#endif - } - s.info.disassembler_options = (char *)"any"; - s.info.print_insn = print_insn_ppc; -#endif if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; } @@ -381,22 +364,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } -#if defined(TARGET_PPC) - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it. */ - s.info.mach = flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach = bfd_mach_ppc64; -#else - s.info.mach = bfd_mach_ppc; -#endif - } - if ((flags >> 16) & 1) { - s.info.endian = BFD_ENDIAN_LITTLE; - } - s.info.print_insn = print_insn_ppc; -#endif if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); diff --git a/monitor.c b/monitor.c index a736ae9a81..2164dfcc3b 100644 --- a/monitor.c +++ b/monitor.c @@ -1310,11 +1310,6 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (format == 'i') { int flags = 0; -#ifdef TARGET_PPC - CPUArchState *env = mon_get_cpu_env(); - flags = msr_le << 16; - flags |= env->bfd_mach; -#endif monitor_disas(mon, cs, addr, count, is_physical, flags); return; } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 606b605ba0..bc155f1036 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7395,12 +7395,9 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - int flags; - flags = env->bfd_mach; - flags |= ctx.le_mode << 16; qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.nip - pc_start, flags); + log_target_disas(cs, pc_start, ctx.nip - pc_start, 0); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index c6399a3a0d..2863e2c0b0 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10681,6 +10681,26 @@ static gchar *ppc_gdb_arch_name(CPUState *cs) #endif } +static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) +{ + PowerPCCPU *cpu = POWERPC_CPU(cs); + CPUPPCState *env = &cpu->env; + + if ((env->hflags >> MSR_LE) & 1) { + info->endian = BFD_ENDIAN_LITTLE; + } + info->mach = env->bfd_mach; + if (!env->bfd_mach) { +#ifdef TARGET_PPC64 + info->mach = bfd_mach_ppc64; +#else + info->mach = bfd_mach_ppc; +#endif + } + info->disassembler_options = (char *)"any"; + info->print_insn = print_insn_ppc; +} + static Property ppc_cpu_properties[] = { DEFINE_PROP_BOOL("pre-2.8-migration", PowerPCCPU, pre_2_8_migration, false), DEFINE_PROP_BOOL("pre-2.10-migration", PowerPCCPU, pre_2_10_migration, @@ -10742,6 +10762,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #ifndef CONFIG_USER_ONLY cc->virtio_is_big_endian = ppc_cpu_is_big_endian; #endif + cc->disas_set_info = ppc_disas_set_info; dc->fw_name = "PowerPC,UNKNOWN"; } From patchwork Tue Oct 17 15:37:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116134 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1371680edb; Tue, 17 Oct 2017 08:40:05 -0700 (PDT) X-Received: by 10.55.139.70 with SMTP id n67mr4787114qkd.275.1508254805727; Tue, 17 Oct 2017 08:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254805; cv=none; d=google.com; s=arc-20160816; b=FvJqDL1QioBv6n4c3rbaF9wRqezDmdK63/JhIja5zblJaoCvdX3AyM9JScvzuDvNXk U03P1Q1cyQo6BzsGUAF6wYwqzF2QqSHZRTl7exX3d7f4S3GJS3VTab4aN9nVpOLvvaMV y93m5qdnTqomSPuzVkv4frDOSD/KpWNuF6nnc0D4qxO9N4AfrfCsfjy0YECswOYWjo60 M5w7ObKEwey4/ZGnG8KzZ+mDEM1d9+hRvfyppyaG8tiqSoOy0Hj61m7WuhjNRUiefzR+ HaGx+akoN5PQgwEFU6qBtxfRpprvJZTAtJHvvwFbDFzlDkwBo1BTgxiBIwndnGc10JSP fA+w== 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=hB8AZwvmRCLXN31Jhod9LFpLholMjxL6hx1+1UO+7iM=; b=EYsRT/tdaXUFwdOO9y3ofcqp322hRo62RmHO23NMaMyCJL9CP6Xytx7rczmWIJYEkX 4IDg4Xyai7TVM9WRFAjPjhZW7Ja5r5tQ7rgJuHCiMog7non6iI5FJLnzoteDQyx4uUiR Ylmgq8JjVtUqLeOFe9Do5mSPd5Rr+aRJiouL5jP1sm45tlls59fA45Aq2I+vMUzK17C1 lvfXAHWek4eFBFthSFzNMWDWtyIPd5iI3jLcVKYOAZ4b3aF2UjAgKpNLOHPWAcBgYKvI k9tz1R3/3Iv3/G/cgiRllUD4V2YBr0Tl+MFF0Nma9OhSZbLCVqf1bvy6MDjr0Ge/5Nmm t+1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Qw+BapOK; 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 b16si9044502qkb.358.2017.10.17.08.40.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:40: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=Qw+BapOK; 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]:40097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TyN-0005R1-7a for patch@linaro.org; Tue, 17 Oct 2017 11:40:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwG-0004DJ-MN for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwE-0005lK-Cx for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:52 -0400 Received: from mail-pg0-x229.google.com ([2607:f8b0:400e:c05::229]:44374) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwE-0005km-45 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:50 -0400 Received: by mail-pg0-x229.google.com with SMTP id j3so1718567pga.1 for ; Tue, 17 Oct 2017 08:37:50 -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=hB8AZwvmRCLXN31Jhod9LFpLholMjxL6hx1+1UO+7iM=; b=Qw+BapOKmYFcryWIZrzSJ2iM0JHJ6ve+xRS0F4iVITcEsu5TmxbdUwCsuFItxU4GL2 j+0e2FkaPvnCx6m7+16TmG7MHR+8sbRDpb4Gm8DVPdwDKWaNJ1zKHw/OT/3KdZCyV4Ev SRK5DTOhnx66x3BRhbK+/bAre8ChcO6P1zA9M= 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=hB8AZwvmRCLXN31Jhod9LFpLholMjxL6hx1+1UO+7iM=; b=uZKMd169mcyTQ+wvdQA9pHLZla+D3bGMno+0RsADsqVCwRZVze/SDunsOLvfTMJ/8N B0CoDLtSw3dp/YMlUcCy4snuXR5xHqMmAKi1+q+laULDDMGh01Wf6VS7zw7bLplvk2NV xZDSJOT/omKnveveRjsoYHl6UlbEZj4fzcwzKSt4Du7GSbYKYn52qAb2MQTKJBEY+N2m eXGS8Q/Ypugqq+OFN22VbiWgZG2rmgbI4Ggvs88zRcu+xl6BhFIlMayn4h/lIFA102bl plBBYUsINYYNMi0paz1wJEDxee8GLyGI8/Vs37Ssi980GiZXBWzDsZGh7/pl3v0RLf7r DABw== X-Gm-Message-State: AMCzsaW5mbRLBpRB7dGgBtyNsiyWA2Knc09+jaGcG273h0IIhbxuRvBs JptMUAzQAF85TlPBRJh1IROipyxcdr8= X-Google-Smtp-Source: ABhQp+Ta0HQaCGu6G7Tulr7WuGC+HZ7slW2dLdKAScpdt5xm6UFlH5uuCL1JXRBZpSnPclpdCGXHOA== X-Received: by 10.159.229.203 with SMTP id t11mr4700751plq.190.1508254668629; Tue, 17 Oct 2017 08:37:48 -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.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:36 -0700 Message-Id: <20171017153742.10026-4-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:c05::229 Subject: [Qemu-devel] [PATCH v5 3/9] disas: Remove unused flags arguments 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" Now that every target is using the disas_set_info hook, the flags argument is unused. Remove it. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/disas/disas.h | 4 ++-- include/exec/log.h | 4 ++-- disas.c | 15 ++++----------- monitor.c | 3 +-- target/alpha/translate.c | 2 +- target/arm/translate-a64.c | 3 +-- target/arm/translate.c | 3 +-- target/cris/translate.c | 3 +-- target/hppa/translate.c | 2 +- target/i386/translate.c | 2 +- target/lm32/translate.c | 2 +- target/m68k/translate.c | 2 +- target/microblaze/translate.c | 2 +- target/mips/translate.c | 2 +- target/nios2/translate.c | 2 +- target/openrisc/translate.c | 2 +- target/ppc/translate.c | 2 +- target/s390x/translate.c | 2 +- target/sh4/translate.c | 2 +- target/sparc/translate.c | 2 +- target/tricore/translate.c | 2 +- target/unicore32/translate.c | 2 +- target/xtensa/translate.c | 2 +- 23 files changed, 28 insertions(+), 39 deletions(-) -- 2.13.6 diff --git a/include/disas/disas.h b/include/disas/disas.h index e549ca24a1..4d48c13c65 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -9,10 +9,10 @@ /* Disassemble this for me please... (debugging). */ void disas(FILE *out, void *code, unsigned long size); void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size, int flags); + target_ulong size); void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flags); + target_ulong pc, int nb_insn, int is_physical); /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol(target_ulong orig_addr); diff --git a/include/exec/log.h b/include/exec/log.h index ba1c9b5682..c249307911 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -38,9 +38,9 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) #ifdef NEED_CPU_H /* disas() and target_disas() to qemu_logfile: */ static inline void log_target_disas(CPUState *cpu, target_ulong start, - target_ulong len, int flags) + target_ulong len) { - target_disas(qemu_logfile, cpu, start, len, flags); + target_disas(qemu_logfile, cpu, start, len); } static inline void log_disas(void *code, unsigned long size) diff --git a/disas.c b/disas.c index 3a375a3b6c..ad675dc361 100644 --- a/disas.c +++ b/disas.c @@ -171,15 +171,9 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } -/* Disassemble this for me please... (debugging). 'flags' has the following - values: - i386 - 1 means 16 bit code, 2 means 64 bit code - ppc - bits 0:15 specify (optionally) the machine instruction set; - bit 16 indicates little endian. - other targets - unused - */ +/* Disassemble this for me please... (debugging). */ void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size, int flags) + target_ulong size) { CPUClass *cc = CPU_GET_CLASS(cpu); target_ulong pc; @@ -336,10 +330,9 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, return 0; } -/* Disassembler for the monitor. - See target_disas for a description of flags. */ +/* Disassembler for the monitor. */ void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flags) + target_ulong pc, int nb_insn, int is_physical) { CPUClass *cc = CPU_GET_CLASS(cpu); int count, i; diff --git a/monitor.c b/monitor.c index 2164dfcc3b..7a802a345e 100644 --- a/monitor.c +++ b/monitor.c @@ -1309,8 +1309,7 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, } if (format == 'i') { - int flags = 0; - monitor_disas(mon, cs, addr, count, is_physical, flags); + monitor_disas(mon, cs, addr, count, is_physical); return; } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index f32c95b9a1..3de369b17e 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -3048,7 +3048,7 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) static void alpha_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) { qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size, 1); + log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps alpha_tr_ops = { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index a39b9d3633..fc5419df7f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11403,8 +11403,7 @@ static void aarch64_tr_disas_log(const DisasContextBase *dcbase, DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, - 4 | (bswap_code(dc->sctlr_b) ? 2 : 0)); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } const TranslatorOps aarch64_translator_ops = { diff --git a/target/arm/translate.c b/target/arm/translate.c index 4da1a4cbc6..9d31769c8d 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12371,8 +12371,7 @@ static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, - dc->thumb | (dc->sctlr_b << 1)); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps arm_translator_ops = { diff --git a/target/cris/translate.c b/target/cris/translate.c index 38a999e6f1..b1fda57c74 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3297,8 +3297,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, - env->pregs[PR_VR]); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); qemu_log_unlock(); diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 26242f4b3c..ca6a6d3372 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -3904,7 +3904,7 @@ static void hppa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) break; default: qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, tb->size, 1); + log_target_disas(cs, tb->pc, tb->size); break; } } diff --git a/target/i386/translate.c b/target/i386/translate.c index 046fc5dfe2..be0a1e9f05 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8522,7 +8522,7 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, DisasContext *dc = container_of(dcbase, DisasContext, base); qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps i386_tr_ops = { diff --git a/target/lm32/translate.c b/target/lm32/translate.c index 65bc9c0bf6..a83cbdf729 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -1156,7 +1156,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("\n"); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); qemu_log_unlock(); diff --git a/target/m68k/translate.c b/target/m68k/translate.c index d738f32f9c..e1e31f622c 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5620,7 +5620,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 067b0878d6..fecc61a1ec 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1810,7 +1810,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log_lock(); qemu_log("--------------\n"); #if DISAS_GNU - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); #endif qemu_log("\nisize=%d osize=%d\n", dc->pc - pc_start, tcg_op_buf_count()); diff --git a/target/mips/translate.c b/target/mips/translate.c index ac05f3aa09..7c96aff1a0 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20370,7 +20370,7 @@ done_generating: && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 6b0961837d..7a0fa860da 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -907,7 +907,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) && qemu_log_in_addr_range(tb->pc)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, dc->pc - tb->pc, 0); + log_target_disas(cs, tb->pc, dc->pc - tb->pc); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 112db1ad0f..99f2b463ce 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1653,7 +1653,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - log_target_disas(cs, pc_start, tb->size, 0); + log_target_disas(cs, pc_start, tb->size); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/ppc/translate.c b/target/ppc/translate.c index bc155f1036..8e92e4579c 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7397,7 +7397,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.nip - pc_start, 0); + log_target_disas(cs, pc_start, ctx.nip - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 165d2cac3e..4fa7609c64 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -5970,7 +5970,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) qemu_log("IN: EXECUTE %016" PRIx64 "\n", dc.ex_value); } else { qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc.pc - pc_start, 1); + log_target_disas(cs, pc_start, dc.pc - pc_start); qemu_log("\n"); } qemu_log_unlock(); diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 8db9fba26e..27067cbd30 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2347,7 +2347,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN:\n"); /* , lookup_symbol(pc_start)); */ - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 6290705b11..e89b6227f2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5855,7 +5855,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock * tb) qemu_log_lock(); qemu_log("--------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, last_pc + 4 - pc_start, 0); + log_target_disas(cs, pc_start, last_pc + 4 - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 4e4198e887..e807500e26 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8839,7 +8839,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && qemu_log_in_addr_range(pc_start)) { qemu_log_lock(); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, ctx.pc - pc_start, 0); + log_target_disas(cs, pc_start, ctx.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 6c094d59d7..f9aa248a80 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -2031,7 +2031,7 @@ done_generating: qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc->pc - pc_start, 0); + log_target_disas(cs, pc_start, dc->pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index d7bf07e8e6..03719ce12b 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -3250,7 +3250,7 @@ done: qemu_log_lock(); qemu_log("----------------\n"); qemu_log("IN: %s\n", lookup_symbol(pc_start)); - log_target_disas(cs, pc_start, dc.pc - pc_start, 0); + log_target_disas(cs, pc_start, dc.pc - pc_start); qemu_log("\n"); qemu_log_unlock(); } From patchwork Tue Oct 17 15:37:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116136 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1372564edb; Tue, 17 Oct 2017 08:41:05 -0700 (PDT) X-Received: by 10.200.63.242 with SMTP id v47mr21071794qtk.29.1508254865799; Tue, 17 Oct 2017 08:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254865; cv=none; d=google.com; s=arc-20160816; b=xbS6ZLzFRZ/SJQK4gMPf97gwi/sXa2KdTKNUEm8Kv8AFmEmkBbv08J5s9sY6F93Kad YPv0SmZn6kN1fIv/Z9HBOlnSyre8+9G3vSTYecKZ2lNa22nWGPDcIiO04XFe82U9wBvW I9oN6DQbmHlFseRFHX0+612TSbfLR+WAU4EReDgJfwz/l2h335ATfBXYP6mOXSBT9uae S7SMv1HE9xCriWNBgfdbAaaKQQNTmlvATT8YafDov4e+hfp0UbrgXwAGJuvb0oyrAYkU CyGheSSAuYgjQ76tMbOAmQEjDTr1ZhEIOxHXmr8iqwi2q8rLJmke741x2VDmzj688Gfz YD4g== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=0GnOE3EOiSsS1sBJSxSS3t9vjWYDvztEoyQAy3/VzWA=; b=PGyef/5LO4tsREhUhAWfurHra/p7Xc1yuxdJRZ/PIJCfKkpqecimiF754D+l486dvX +81od4IZZ0Nw/Rtt6KhArarMwAnLbcD362nEe5Ld47JqMkv6OETKfOcXcLNMNYwpYQwG w5GajF4S9cSjLdSreWvYPYHrTBozee7V9gd8uFod0pwfDCjXtmVZ4Nt+NJTPKLDHu/CI CngE1q0EEvov6krMW1IRm+aKY6ymrsYdpGBxLxogkB91uUpK/Cg/AvDLbYnV+uZesu1m j3+urU5khvroPnlBxif0SjiUYqIxrXrp8D7nBgA5nth5+5BFjacr4d7mLiGHYBQe+6sF hGYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ureqv48A; 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 14si5714896qtv.210.2017.10.17.08.41.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:41: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=Ureqv48A; 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]:40104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TzL-0006br-9j for patch@linaro.org; Tue, 17 Oct 2017 11:41:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwI-0004Ef-0y for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwF-0005m5-Vn for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:54 -0400 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]:57257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwF-0005li-MT for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:51 -0400 Received: by mail-pf0-x229.google.com with SMTP id b85so1601919pfj.13 for ; Tue, 17 Oct 2017 08:37:51 -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; bh=0GnOE3EOiSsS1sBJSxSS3t9vjWYDvztEoyQAy3/VzWA=; b=Ureqv48A41dvImI6aAM8OIeVDGWVqfkdjYlOGFd73nuyDRYaMUMeHOh7pLPPibHMkQ LOtCn/ITTsWyAWgPANG5v+mCwe1NZHPOxGrChZBmn8UdKiw3cqf4atLsa8XySQYtWYzq vkGoAuWvG9FlZqoD9NX1sC2dorVUKW5G1RhwU= 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; bh=0GnOE3EOiSsS1sBJSxSS3t9vjWYDvztEoyQAy3/VzWA=; b=taJlDwaJ9nw3P3dHllbLYR8QM8dQBbUGV9Z+y2mcCDQoK7yqNYhpfy3Y/Pf0ktTTYp 7iigWVXR4CKcY6HCxlIKcDurEihEOUWc4oEdLt1yJEq3c7FBf2Pe7VT19Wzv9AL6LkkC GHEMXB83m19nCwhns5nqr4NVi6/+GzkQSjQt9LKRPZgm/K00mZBU8ZBsl1kjctQXX6s3 AOfJfQi3xmYwn1JdA5VDd+cHQl/x1ldqqQ31nEE4QO8IPKYUVTEF61qywpVHIeG+/vaN 1aFKfyOj0Z9C4dWey4jSkTREkNkmme0zP62cmQNFjvUII6KUcG9YsOh4n6K5k72IpwpT h7OA== X-Gm-Message-State: AMCzsaVuqRdj73XbIFFKfiJSsjFI+LFOOLQj5EFW1pXjn5tt1XJN5iqT CEq6/vqVqVbZQrB/BngrXAjiu5UDmdQ= X-Google-Smtp-Source: AOwi7QCICSrcslc60XYd/wmhC/uDZ2gIic0p/+hi8FeqTpmcscxlzLnvTFkV3qfPpfuRfp5Y1M/SoQ== X-Received: by 10.98.33.203 with SMTP id o72mr12015066pfj.41.1508254670224; Tue, 17 Oct 2017 08:37:50 -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.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:37 -0700 Message-Id: <20171017153742.10026-5-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> 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 v5 4/9] disas: Support the Capstone disassembler library 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" If configured, prefer this over our rather dated copy of the GPLv2-only binutils. This will be especially apparent with the proposed vector extensions to TCG, as disas/i386.c does not handle AVX. Signed-off-by: Richard Henderson --- include/disas/bfd.h | 4 + include/disas/capstone.h | 38 ++++++++ disas.c | 219 ++++++++++++++++++++++++++++++++++++++++++++--- configure | 26 ++++++ 4 files changed, 274 insertions(+), 13 deletions(-) create mode 100644 include/disas/capstone.h -- 2.13.6 Reviewed-by: Philippe Mathieu-Daudé diff --git a/include/disas/bfd.h b/include/disas/bfd.h index b01e002b4c..0f4ecdeb88 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -377,6 +377,10 @@ typedef struct disassemble_info { /* Command line options specific to the target disassembler. */ char * disassembler_options; + /* Options for Capstone disassembly. */ + int cap_arch; + int cap_mode; + } disassemble_info; diff --git a/include/disas/capstone.h b/include/disas/capstone.h new file mode 100644 index 0000000000..84e214956d --- /dev/null +++ b/include/disas/capstone.h @@ -0,0 +1,38 @@ +#ifndef QEMU_CAPSTONE_H +#define QEMU_CAPSTONE_H 1 + +#ifdef CONFIG_CAPSTONE + +#include + +#else + +/* Just enough to allow backends to init without ifdefs. */ + +#define CS_ARCH_ARM -1 +#define CS_ARCH_ARM64 -1 +#define CS_ARCH_MIPS -1 +#define CS_ARCH_X86 -1 +#define CS_ARCH_PPC -1 +#define CS_ARCH_SPARC -1 +#define CS_ARCH_SYSZ -1 + +#define CS_MODE_LITTLE_ENDIAN 0 +#define CS_MODE_BIG_ENDIAN 0 +#define CS_MODE_ARM 0 +#define CS_MODE_16 0 +#define CS_MODE_32 0 +#define CS_MODE_64 0 +#define CS_MODE_THUMB 0 +#define CS_MODE_MCLASS 0 +#define CS_MODE_V8 0 +#define CS_MODE_MICRO 0 +#define CS_MODE_MIPS3 0 +#define CS_MODE_MIPS32R6 0 +#define CS_MODE_MIPSGP64 0 +#define CS_MODE_V9 0 +#define CS_MODE_MIPS32 0 +#define CS_MODE_MIPS64 0 + +#endif /* CONFIG_CAPSTONE */ +#endif /* QEMU_CAPSTONE_H */ diff --git a/disas.c b/disas.c index ad675dc361..746d76c07d 100644 --- a/disas.c +++ b/disas.c @@ -6,6 +6,7 @@ #include "cpu.h" #include "disas/disas.h" +#include "disas/capstone.h" typedef struct CPUDebug { struct disassemble_info info; @@ -171,6 +172,192 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } +#ifdef CONFIG_CAPSTONE +/* Temporary storage for the capstone library. This will be alloced via + malloc with a size private to the library; thus there's no reason not + to share this across calls and across host vs target disassembly. */ +static __thread cs_insn *cap_insn; + +/* Initialize the Capstone library. */ +/* ??? It would be nice to cache this. We would need one handle for the + host and one for the target. For most targets we can reset specific + parameters via cs_option(CS_OPT_MODE, new_mode), but we cannot change + CS_ARCH_* in this way. Thus we would need to be able to close and + re-open the target handle with a different arch for the target in order + to handle AArch64 vs AArch32 mode switching. */ +static cs_err cap_disas_start(disassemble_info *info, csh *handle) +{ + cs_mode cap_mode = info->cap_mode; + cs_err err; + + cap_mode += (info->endian == BFD_ENDIAN_BIG ? CS_MODE_BIG_ENDIAN + : CS_MODE_LITTLE_ENDIAN); + + err = cs_open(info->cap_arch, cap_mode, handle); + if (err != CS_ERR_OK) { + return err; + } + + /* ??? There probably ought to be a better place to put this. */ + if (info->cap_arch == CS_ARCH_X86) { + /* We don't care about errors (if for some reason the library + is compiled without AT&T syntax); the user will just have + to deal with the Intel syntax. */ + cs_option(*handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT); + } + + /* "Disassemble" unknown insns as ".byte W,X,Y,Z". */ + cs_option(*handle, CS_OPT_SKIPDATA, CS_OPT_ON); + + /* Allocate temp space for cs_disasm_iter. */ + if (cap_insn == NULL) { + cap_insn = cs_malloc(*handle); + if (cap_insn == NULL) { + cs_close(handle); + return CS_ERR_MEM; + } + } + return CS_ERR_OK; +} + +/* Disassemble SIZE bytes at PC for the target. */ +static bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size) +{ + uint8_t cap_buf[1024]; + csh handle; + cs_insn *insn; + size_t csize = 0; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + while (1) { + size_t tsize = MIN(sizeof(cap_buf) - csize, size); + const uint8_t *cbuf = cap_buf; + + target_read_memory(pc + csize, cap_buf + csize, tsize, info); + csize += tsize; + size -= tsize; + + while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + } + + /* If the target memory is not consumed, go back for more... */ + if (size != 0) { + /* ... taking care to move any remaining fractional insn + to the beginning of the buffer. */ + if (csize != 0) { + memmove(cap_buf, cbuf, csize); + } + continue; + } + + /* Since the target memory is consumed, we should not have + a remaining fractional insn. */ + if (csize != 0) { + (*info->fprintf_func)(info->stream, + "Disassembler disagrees with translator " + "over instruction decoding\n" + "Please report this to qemu-devel@nongnu.org\n"); + } + break; + } + + cs_close(&handle); + return true; +} + +/* Disassemble SIZE bytes at CODE for the host. */ +static bool cap_disas_host(disassemble_info *info, void *code, size_t size) +{ + csh handle; + const uint8_t *cbuf; + cs_insn *insn; + uint64_t pc; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + cbuf = code; + pc = (uintptr_t)code; + + while (cs_disasm_iter(handle, &cbuf, &size, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + } + if (size != 0) { + (*info->fprintf_func)(info->stream, + "Disassembler disagrees with TCG over instruction encoding\n" + "Please report this to qemu-devel@nongnu.org\n"); + } + + cs_close(&handle); + return true; +} + +#if !defined(CONFIG_USER_ONLY) +/* Disassemble COUNT insns at PC for the target. */ +static bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) +{ + uint8_t cap_buf[32]; + csh handle; + cs_insn *insn; + size_t csize = 0; + + if (cap_disas_start(info, &handle) != CS_ERR_OK) { + return false; + } + insn = cap_insn; + + while (1) { + /* We want to read memory for one insn, but generically we do not + know how much memory that is. We have a small buffer which is + known to be sufficient for all supported targets. Try to not + read beyond the page, Just In Case. For even more simplicity, + ignore the actual target page size and use a 1k boundary. If + that turns out to be insufficient, we'll come back around the + loop and read more. */ + uint64_t epc = QEMU_ALIGN_UP(pc + csize + 1, 1024); + size_t tsize = MIN(sizeof(cap_buf) - csize, epc - pc); + const uint8_t *cbuf = cap_buf; + + /* Make certain that we can make progress. */ + assert(tsize != 0); + info->read_memory_func(pc, cap_buf + csize, tsize, info); + csize += tsize; + + if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { + (*info->fprintf_func)(info->stream, + "0x%08" PRIx64 ": %-12s %s\n", + insn->address, insn->mnemonic, + insn->op_str); + if (--count <= 0) { + break; + } + } + memmove(cap_buf, cbuf, csize); + } + + cs_close(&handle); + return true; +} +#endif /* !CONFIG_USER_ONLY */ +#else +# define cap_disas_target(i, p, s) false +# define cap_disas_host(i, p, s) false +# define cap_disas_monitor(i, p, c) false +#endif /* CONFIG_CAPSTONE */ + /* Disassemble this for me please... (debugging). */ void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size) @@ -188,6 +375,8 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, s.info.buffer_vma = code; s.info.buffer_length = size; s.info.print_address_func = generic_print_address; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -199,6 +388,10 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, cc->disas_set_info(cpu, &s.info); } + if (s.info.cap_arch >= 0 && cap_disas_target(&s.info, code, size)) { + return; + } + if (s.info.print_insn == NULL) { s.info.print_insn = print_insn_od_target; } @@ -206,18 +399,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, for (pc = code; size > 0; pc += count, size -= count) { fprintf(out, "0x" TARGET_FMT_lx ": ", pc); count = s.info.print_insn(pc, &s.info); -#if 0 - { - int i; - uint8_t b; - fprintf(out, " {"); - for(i = 0; i < count; i++) { - target_read_memory(pc + i, &b, 1, &s.info); - fprintf(out, " %02x", b); - } - fprintf(out, " }"); - } -#endif fprintf(out, "\n"); if (count < 0) break; @@ -245,6 +426,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.buffer = code; s.info.buffer_vma = (uintptr_t)code; s.info.buffer_length = size; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef HOST_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -282,6 +465,11 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__hppa__) print_insn = print_insn_hppa; #endif + + if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) { + return; + } + if (print_insn == NULL) { print_insn = print_insn_od_host; } @@ -344,8 +532,9 @@ void monitor_disas(Monitor *mon, CPUState *cpu, monitor_disas_is_physical = is_physical; s.info.read_memory_func = monitor_read_memory; s.info.print_address_func = generic_print_address; - s.info.buffer_vma = pc; + s.info.cap_arch = -1; + s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; @@ -357,6 +546,10 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } + if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) { + return; + } + if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); diff --git a/configure b/configure index 663e9081ea..11e3078936 100755 --- a/configure +++ b/configure @@ -375,6 +375,7 @@ opengl_dmabuf="no" cpuid_h="no" avx2_opt="no" zlib="yes" +capstone="" lzo="" snappy="" bzip2="" @@ -1294,6 +1295,10 @@ for opt do error_exit "vhost-user isn't available on win32" fi ;; + --disable-capstone) capstone="no" + ;; + --enable-capstone) capstone="yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1541,6 +1546,7 @@ disabled with --disable-FEATURE, default is enabled if available: vxhs Veritas HyperScale vDisk backend support crypto-afalg Linux AF_ALG crypto backend driver vhost-user vhost-user support + capstone capstone disassembler support NOTE: The object files are built at the place where configure is launched EOF @@ -4403,6 +4409,22 @@ EOF fi ########################################## +# capstone + +if test "$capstone" != no; then + if $pkg_config capstone; then + capstone=yes + QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" + LIBS="$($pkg_config --libs capstone) $LIBS" + else + if test "$capstone" = yes; then + feature_not_found capstone + fi + capstone=no + fi +fi + +########################################## # check if we have fdatasync fdatasync=no @@ -5460,6 +5482,7 @@ echo "jemalloc support $jemalloc" echo "avx2 optimization $avx2_opt" echo "replication support $replication" echo "VxHS block device $vxhs" +echo "capstone $capstone" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6134,6 +6157,9 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi +if test "$capstone" = "yes" ; then + echo "CONFIG_CAPSTONE=y" >> $config_host_mak +fi # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on 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[] = { From patchwork Tue Oct 17 15:37:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116140 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1375465edb; Tue, 17 Oct 2017 08:44:10 -0700 (PDT) X-Received: by 10.55.122.135 with SMTP id v129mr17588594qkc.171.1508255050363; Tue, 17 Oct 2017 08:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508255050; cv=none; d=google.com; s=arc-20160816; b=eH0BrhNnJ1dvJ40jDBB0CYOgB/WOaT4wSQAzlfLJzsSexAI37ni22J78OrnTgXW4Zi 8M4Qsmydx0ZGDBYpnVM+7ALCRzATlkv+5mk8BpYETIYMRpN90QGCD54UbTSNqqjA2AJv Y8MImIW38gEAlLuTVHJpgQVd1qy1q4ShuIFEDS5Fmcdzhc9ZPtvj7cxqUMuTOMlT+qyj iWmIUbP7DIW7QkX7poqasX85fyDYfh/EFzAoxICY0Yh0VnD5slI9w4bljXndMrr+OWC1 ucwXEglfuTmVl7mrpfOrMjj+mIy6mA6Ao8bMaeuE7sVAyTbgFl5VejexH2jwT6JRJ3cS VwqA== 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=3BLOcxnnPg/ZIwB7QEQ1fWCFx1Q2/Js7qiibntMGJnE=; b=NeKPsMCOMDwiuip0TKgoGKBcUEWiwPsJf7kXf2ttl8Q6yutDgoJT5nPVmpJY3JjEEC uTCYstUcauMQN/AE0YhabXQ/Mnn2yNY4xihsTPX7ziU5KhjzSMBXftadcX/nUEKoERNg nqN5YjW/NcyVw5XlCh5vuH7cQYmV3vpY3jA2YQAAMRu8Rgt6a2aWdEgpqXRMLzagZ3K5 JbQcq2b1pqrDfpjUwOxdjysqkNQkxGHD+j1xn1Gk0Rw8kVpC57cfIsiEe5yROXHBBFCU krPaof7LIH6M927FHp3qhNKVv3XUnfU5EzKWS1ubHGNfRt01G+4kDpAcOYXvRLT5Jtu3 /iig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PphiX9/g; 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 s2si728473qtj.322.2017.10.17.08.44.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:44:10 -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=PphiX9/g; 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]:40113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4U2K-0000XX-6f for patch@linaro.org; Tue, 17 Oct 2017 11:44:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwJ-0004Gx-DQ 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 1e4TwI-0005oh-Dp for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:55 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:52275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwI-0005nj-88 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:54 -0400 Received: by mail-pf0-x22d.google.com with SMTP id e64so1605147pfk.9 for ; Tue, 17 Oct 2017 08:37:54 -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=3BLOcxnnPg/ZIwB7QEQ1fWCFx1Q2/Js7qiibntMGJnE=; b=PphiX9/gXClcSzdvDqmoSHtqa0U9T26ynFoaWLn4+Z4IidD3/9U5xtGF1gKlcw6Q2C SZvdduXQx4ced+Dj4a4mYVpzLDp0H+Ex0Y8mxdYck+X1D43eR8rS+XYgi4PclClO73IS l+O5/5+aaT3cGPNWP6aN1LMUxK17wzjIj233g= 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=3BLOcxnnPg/ZIwB7QEQ1fWCFx1Q2/Js7qiibntMGJnE=; b=Kf6s3WwSIY2ov+SSSy9+lC4ZhkaO1FR8LAA0XKVHOaANphyXTLt1sJokrBpY9guzCj 42UUvXV1iffluXVzIsLQ4llEd1Kjmh34+UOl12CCnleYMFwWjvsOCpshleu8dw7QI3bK KevJQSl2CMKGAm9Ns+vlR3ohSS1Lc3IQv7N2y0ZrJVBK9gTjd/LsQKt4O9OqF56Az8Q+ qSJa1w9zCs3ZkwMWcoURcJzaq1DBd9UHiF6KgNxxlz24Dtgc3lFRGlp9ZGJNdmyva/mf UZ2XBr1ct6xNC5cKAvoYLxzNCh912MPYeR0KZqw/KGsEeybLuxvQd41LyNOhsix6NIuk foXA== X-Gm-Message-State: AMCzsaVN+Ch5kMOo4TeHbAdiTnfo/ErMon/iQWZG+keVYCp81M6I5J6q uBQ2WvS/nPjhglW97GQy5cLrq+Od0ww= X-Google-Smtp-Source: AOwi7QCvLBaLlhBfA2fkEdGQKEkBF3IwVIvxcgcoHC4hCPOObJlwxxtoHrw6xJt/Qj0bK+Ny4oUPZQ== X-Received: by 10.98.137.156 with SMTP id n28mr12193826pfk.93.1508254672979; Tue, 17 Oct 2017 08:37:52 -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.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:39 -0700 Message-Id: <20171017153742.10026-7-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::22d Subject: [Qemu-devel] [PATCH v5 6/9] arm: 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: Alex Bennée Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 3 +++ target/arm/cpu.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 1c44514254..23c4742f8d 100644 --- a/disas.c +++ b/disas.c @@ -451,6 +451,7 @@ void disas(FILE *out, void *code, unsigned long size) print_insn = print_insn_ppc; #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; + s.info.cap_arch = CS_ARCH_ARM64; #elif defined(__alpha__) print_insn = print_insn_alpha; #elif defined(__sparc__) @@ -458,6 +459,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.mach = bfd_mach_sparc_v9b; #elif defined(__arm__) print_insn = print_insn_arm; + s.info.cap_arch = CS_ARCH_ARM; + /* TCG only generates code for arm mode. */ #elif defined(__MIPSEB__) print_insn = print_insn_big_mips; #elif defined(__MIPSEL__) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 88578f360e..1576a6d372 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -33,6 +33,7 @@ #include "sysemu/sysemu.h" #include "sysemu/hw_accel.h" #include "kvm_arm.h" +#include "disas/capstone.h" static void arm_cpu_set_pc(CPUState *cs, vaddr value) { @@ -501,10 +502,24 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) #if defined(CONFIG_ARM_A64_DIS) info->print_insn = print_insn_arm_a64; #endif - } else if (env->thumb) { - info->print_insn = print_insn_thumb1; + info->cap_arch = CS_ARCH_ARM64; } else { - info->print_insn = print_insn_arm; + int cap_mode; + if (env->thumb) { + info->print_insn = print_insn_thumb1; + cap_mode = CS_MODE_THUMB; + } else { + info->print_insn = print_insn_arm; + cap_mode = CS_MODE_ARM; + } + if (arm_feature(env, ARM_FEATURE_V8)) { + cap_mode |= CS_MODE_V8; + } + if (arm_feature(env, ARM_FEATURE_M)) { + cap_mode |= CS_MODE_MCLASS; + } + info->cap_arch = CS_ARCH_ARM; + info->cap_mode = cap_mode; } if (bswap_code(arm_sctlr_b(env))) { #ifdef TARGET_WORDS_BIGENDIAN From patchwork Tue Oct 17 15:37:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116135 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1372039edb; Tue, 17 Oct 2017 08:40:30 -0700 (PDT) X-Received: by 10.237.37.132 with SMTP id x4mr18416250qtc.224.1508254830089; Tue, 17 Oct 2017 08:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254830; cv=none; d=google.com; s=arc-20160816; b=I3cEqAlJPDj25esRU8n9Oesm7cEYJEh9e7/Di7HBf3XYFnIgElp8N3nPumMytPgm4m GWANmJ6/gzY74yOd71PgwU4AqchcGmqFLBG9F7+CBsth+fEoDfH1+Pmd4Jagy7/zb1FO 1Umdf2nxDp4H95BQjJzvDw/SKsF4EJ7Ltn0mZmom/UalQuOF5KNciwCSJ2xN4Z7Vcjwb oIwodOJs7os8sL1rH7205u7vzsT0P8zwSB+7eD9R8vfLhNUjUzmiqdnGx3FGQGB8pxPu 51kfpkWd1Q3hVzeI8aQQEsx9C4YZqLh3MD+gxIi8UWi5u4Ex3waxotoSMHc3ZOovxdUL g0oA== 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=chfoJBU+nyqcgO2t4lckPD6aYSbxk/BhHT57ZCjJXKc=; b=f/bd9yT4IL3ok6YYngeNTbjNyWWWxinUeo4A0bxTizVlE4O4RPYmsfbNJutsyej4Az mGQaSa06MGMTwPeXgn4SIiQ8r4f/FTNHLFS9XdCzK+5IL53yn2soTMOukohK2e5AsG5W kTVCYDK6Hc/iaLR5DLq7aiKB+s1k+q2FrgVyMif57BmQF/aLJzKcv5M5FPycM9ZCJJ6t UVFfqL1Ig15Sm8YnVHz91oEu11Zr9PKqJbk79TPo36Ku66NVMOU8Jb8mlPdUyYs/f3W0 rDMwWyAlFS6EyawToDkspv9QFBoVP8OTrCNBtlz/jBQ8NWqp7o7FAfp4z9DsWyLegJIV ZA5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FPm1df68; 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 q190si494922qke.70.2017.10.17.08.40.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:40:30 -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=FPm1df68; 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]:40098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Tyl-0005mG-KZ for patch@linaro.org; Tue, 17 Oct 2017 11:40:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwM-0004Jr-Nc for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwJ-0005rX-Rb for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:58 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:55843) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwJ-0005pZ-Kz for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:55 -0400 Received: by mail-pg0-x231.google.com with SMTP id y184so508981pgd.12 for ; Tue, 17 Oct 2017 08:37:55 -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=chfoJBU+nyqcgO2t4lckPD6aYSbxk/BhHT57ZCjJXKc=; b=FPm1df68pbXeSw0DdSErvoKQB4gRSG5TZwaiv9CbeoyYjY7rep4Uk0cuhtNky3NiDk BnnNGYu1CnFQkfDNDshBmrqEsQphml4zrQii1i1d8AFko0MrT0mMe5+dhPIxvtBLNnzq LPOjl9WjOzM+V5eNKA8fYmpNLvFB/VmA5G9kA= 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=chfoJBU+nyqcgO2t4lckPD6aYSbxk/BhHT57ZCjJXKc=; b=FQP3Cdg5ONf+u9J9xap+YxTBNhICITFW4tumC+XoJYidmNHiISPmXovljQTSibsJDp CeHJ2sFVhrNA2DXTqs4EzAsNDlatm5F3Ta09O1SBaWScsGBAB7MEyFh99x2K9LHz60yr vRM49erEAXWn+ca5CQ4vlhe22qr2P7X7zM+WgIFDy24GwpJSy19t+iAecVUpoCF/G5lu EYze1MTJR9GVIHjzEP0ozNkpP55LCKlLUgX0TpBbUQX4WarybSK1h/oSDUJHMfybKmE3 KKL5QvIT5vw+yf1qePIg27tycvuJqA9mEEzpklfiOzGLwfmDwdw4zQJwHUL0ArWX31Un JqJw== X-Gm-Message-State: AMCzsaW2+Ah0DhYt8l6QJkRrQTetZUwXR7dSzC4bBxs+Lft7SPfAGJdh 4mDDRnhEhGdJLEHgpoOPjO9a+ck/cfk= X-Google-Smtp-Source: ABhQp+Q7zLrhaTrsTK+UsvekYMxEmAvVBAoDuHWtWu7HQVa6c0yXDx0YA3JAymv+5CRoCmBlb7kDag== X-Received: by 10.98.93.136 with SMTP id n8mr4549736pfj.215.1508254674288; Tue, 17 Oct 2017 08:37:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:40 -0700 Message-Id: <20171017153742.10026-8-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:c05::231 Subject: [Qemu-devel] [PATCH v5 7/9] ppc: 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: qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-ppc@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/ppc/translate_init.c | 6 ++++++ 2 files changed, 10 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index 23c4742f8d..0d212f2ac5 100644 --- a/disas.c +++ b/disas.c @@ -449,6 +449,10 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; + s.info.cap_arch = CS_ARCH_PPC; +# ifdef _ARCH_PPC64 + s.info.cap_mode = CS_MODE_64; +# endif #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; s.info.cap_arch = CS_ARCH_ARM64; diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c index 2863e2c0b0..69a9485f66 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -35,6 +35,7 @@ #include "mmu-book3s-v3.h" #include "sysemu/qtest.h" #include "qemu/cutils.h" +#include "disas/capstone.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -10699,6 +10700,11 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) } info->disassembler_options = (char *)"any"; info->print_insn = print_insn_ppc; + + info->cap_arch = CS_ARCH_PPC; +#ifdef TARGET_PPC64 + info->cap_mode = CS_MODE_64; +#endif } static Property ppc_cpu_properties[] = { From patchwork Tue Oct 17 15:37:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116137 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1373654edb; Tue, 17 Oct 2017 08:42:12 -0700 (PDT) X-Received: by 10.55.95.67 with SMTP id t64mr19514801qkb.249.1508254932302; Tue, 17 Oct 2017 08:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508254932; cv=none; d=google.com; s=arc-20160816; b=KSzM0u6UFvAYtKg0l8nMcaUPzVATkao9NeJUL+hp9UHo5N2K+8gkjUNP4wlW2h0FC5 yoeKAxs8IpPd5XfFadZ1Ppz+leJd8wWsj/+JU1X0Jd/OAzJUftM07CZcapcJxqvbc8n6 JxFlu8gG99+tc9FExKgNN2FyMvcwmnHRKCJJnXu8pYTrhR6IkVPSq5I87F2w1yp4oSgC uO0YbOcLNECEiPZNHQnspqL4efbSIDTElVllRckOHgvRo+CpnqgV3YxELv5x7qlD49OG lQK6nv5+LVbAV0m8h29iIjbmNmQyItXiWDrOJy1v5TPonPeFO3IMi9UUcDpLsaAVlGae mG8w== 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=hka4OKpB1sEXWyM0u9lG2fdZe8a2ld1bOBH1qwvYLsg=; b=P6z1hw08iVUg7yYg5cOVa6MTMFm9L6qMsG6W5qWHGunoVfwE0mxDoHaNEVYWq+PU6F u5vl9mKiCd5bfghPWNdkKQEW4yfnza4G2inJ3+y7mw1Dy+K+AXmbqTSZHX8PWKWiWk4z UtgoifXEsrAXJIh+HM7Q3jP9+DIDhyCo9jyEr3tSbe1H4pM87yUIP6VhSCnN+Kf+RSvN 65lR48WWG6A04jRgcWfcvgK27fg/w/23oxK2QBUonTY0D2kx1uJBTQNNLE4LJkJAckGR LOpu3y5En8QDkI1dDlkKzyk+qvXC81ydQu2SRaqOshToE0QNp9V55mZ34yvtKjkdJnZ5 4meg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QnUjzmiW; 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 m4si195148qtb.194.2017.10.17.08.42.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:42:12 -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=QnUjzmiW; 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]:40106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4U0Q-0007Oo-1C for patch@linaro.org; Tue, 17 Oct 2017 11:42:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwQ-0004NG-9Y for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:38:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwP-00062L-8V for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:38:02 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:57257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwP-000602-2H for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:38:01 -0400 Received: by mail-pf0-x233.google.com with SMTP id b85so1602227pfj.13 for ; Tue, 17 Oct 2017 08:38:00 -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=hka4OKpB1sEXWyM0u9lG2fdZe8a2ld1bOBH1qwvYLsg=; b=QnUjzmiWI0dBlEbxfQxCN/04dHg1smwyFHDkMMzCkTqn/y9Ip71aZe1GxehlwYQlGZ 0DaTpgMX/4TBFaOnXpBtl3tUxJbu6mvIC+neJ3AJXMAPtAyTH62AuqHacmpZdOF5lozf ACOdG+7ffMSe3PANl3+9LtUaNKMuKj1vGunQM= 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=hka4OKpB1sEXWyM0u9lG2fdZe8a2ld1bOBH1qwvYLsg=; b=Q0+CfxOS9kLpZUMHvK0eJ7poFk5GzTkj358+q1J6llLuBoETiYQWhss2sfWiwcp90A YvjPGreJOA6/Uovsp9rI8vmdk4JeqoOc7Wg2UT2SBNREHgyqCQOh8ahX0B0HF0AmUCS+ yTIedy25A2z1AZ7KDXr02Q6zWYEIk2T8m/3KCgIrrtZd8sdS3puvzg+/17koxmDj81VX UCg89giOmeMXd4lNIzgYUXPIji/h7Dpk6uRQLcoKRKk097/mx7PihJuOyMUw5co70yBn zJAnN1ZxY9d3PJvlqnILPjyg4NDYlDTIYRGkK96PQSX051qUHMXRNtok05YWWZS6j0Xm oBpA== X-Gm-Message-State: AMCzsaWzyoAEZG8TPSxEYSxN4ZnqU00V4WNMZBH/ZfNHf6IuffRWLaqj JjVpM84YFeK+7XXCvot+oSDMNEQaOCY= X-Google-Smtp-Source: AOwi7QBMxHL0lgAOGvekyTQxumGk3q3ycovCDCgN/gvTi5Dk3y5fvEWWaVmFKPdRqx03b0HsBcWTYA== X-Received: by 10.99.3.21 with SMTP id 21mr11058460pgd.77.1508254675771; Tue, 17 Oct 2017 08:37:55 -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.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:41 -0700 Message-Id: <20171017153742.10026-9-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::233 Subject: [Qemu-devel] [PATCH v5 8/9] disas: Remove monitor_disas_is_physical 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" Even though there is only one monitor, and thus no race on this global data object, there is also no point in having it. We can just as well record the decision in the read_memory_function that we select. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.13.6 diff --git a/disas.c b/disas.c index 0d212f2ac5..194c523885 100644 --- a/disas.c +++ b/disas.c @@ -513,19 +513,11 @@ const char *lookup_symbol(target_ulong orig_addr) #include "monitor/monitor.h" -static int monitor_disas_is_physical; - static int -monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length, +physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) { - CPUDebug *s = container_of(info, CPUDebug, info); - - if (monitor_disas_is_physical) { - cpu_physical_memory_read(memaddr, myaddr, length); - } else { - cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0); - } + cpu_physical_memory_read(memaddr, myaddr, length); return 0; } @@ -540,8 +532,8 @@ void monitor_disas(Monitor *mon, CPUState *cpu, INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); s.cpu = cpu; - monitor_disas_is_physical = is_physical; - s.info.read_memory_func = monitor_read_memory; + s.info.read_memory_func + = (is_physical ? physical_read_memory : target_read_memory); s.info.print_address_func = generic_print_address; s.info.buffer_vma = pc; s.info.cap_arch = -1; From patchwork Tue Oct 17 15:37:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116141 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1376975edb; Tue, 17 Oct 2017 08:45:49 -0700 (PDT) X-Received: by 10.55.76.85 with SMTP id z82mr10664429qka.183.1508255149283; Tue, 17 Oct 2017 08:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508255149; cv=none; d=google.com; s=arc-20160816; b=arG2oANySHUV+lDnKYrRZyftnPKNeePzdO8LP/1c46LkgC6vdLZjIld4aNEtL1h8c9 /7znrBZV11iOSyq39eU6AZCF2dmBY37K6bZV4dsuY6YrkYi7ymVujJX0XGWdv6V6E+pj j+X8mwHUvrhc1Hl3F0Bh0TkrjfdYe+cTTkx1+GzSTvj6y/g9aULPDNqg68RG3Cn6CpJr JLtgI6m5VEHAl1pSjjVBGIp3IP1niRxZELqMi3na/thbl4z0xCIS66b28HC6FH/c55Ve kIKvnJCDgWL5Gfke1E9eEvy2jul9ar7GQedHQUqvM3fuK+3i3AHQJ0kSEqlxrg32RLg4 H4gA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=IhrehGFXNdn1g4MNkKTsmaTJS+p2x52QVd3uxxOAr/A=; b=sXUqTluS/gBwPL5pQdsUd8RqN4I00jjd6fNVwEBnN4ZhqyE7IvI07p1ESzr4xr7aqw nJBs+aTEaNBkpoMtg9TiWctCJPJaqMVEwssDT6m2Ku/6qMC0GlYKmuC+6LaYtpwQhYwD QJ6K8ePpRwBamqOt0YMHZ5vBU+kMWGSxCUZxJIdTHKabJ4CqxkPPHEaJjWUy3shO/iJp GV9v/+CSvyNCdjFRk9LYIO8+ZJf6fGuPdv0nnFYlvjHlgNvasfiRSkIQr+umbOev7DGX jCQMH0Kx60iTSmXjzVh+VJkGVAbaWka/RakuLhAJ0xU6srOggHo5EEBaUsc3a6cy1d0I SOvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Geryctda; 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 z21si747923qkg.294.2017.10.17.08.45.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Oct 2017 08:45:49 -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=Geryctda; 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]:40121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4U3v-0001lD-0o for patch@linaro.org; Tue, 17 Oct 2017 11:45:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4TwN-0004L4-Vl for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:38:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4TwM-0005wx-Tx for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:59 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:46979) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4TwM-0005vK-O3 for qemu-devel@nongnu.org; Tue, 17 Oct 2017 11:37:58 -0400 Received: by mail-pf0-x232.google.com with SMTP id p87so1615909pfj.3 for ; Tue, 17 Oct 2017 08:37:58 -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; bh=IhrehGFXNdn1g4MNkKTsmaTJS+p2x52QVd3uxxOAr/A=; b=GeryctdaIeQjtYrnoEAGYAetUoCe2D4gdtTneWQP2RxIwJa5LU0pOeqrkzr4nYEsH2 QW7DG1s5mY5CX9cU2xYoe0/JHkPHFAvovHqT86qrmRWJQVoa1C79GJW1XtP3LgRQR6hC G2PX3qmXvq0e1a9Tti6+vulK/5dziOAYxM1gA= 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; bh=IhrehGFXNdn1g4MNkKTsmaTJS+p2x52QVd3uxxOAr/A=; b=tIBEbWKTGqWIlH4yk/zkNs5Fe0Z3aJAajIBkOQuQc6ZWN9R3RvNxnkPHd31W/awQPF TBG1JgncDJsQcVQLRAlVuTcwAqEWV2FehDpbzwn6hLZqDHJ9HUtzAEkNxIqxU7iAUEue jsiAu5eLW1rCV4ONrvRL+fjYACzEEvptw/b7eKa4JTdZnLVHaOgz6fEJmaiB5rB4V+Nd bUlf0JPtM4Wxpf4I9Aw+gQnUYCqMx2rHtiO9H5zt6UgK4FzMvpoksrdoieHUwqkie38j IluJtykJbSFx5BEXkwHkYpHQqMk1q7pty/SVLxFSEUbT+xGxuhwxCYUawZCz/K5j/UvX QO8A== X-Gm-Message-State: AMCzsaWmyA2RKOq6kH30V4IivNJwRVxZIj/XpCwMjxZrdVP0wSyeLXfv k3iIzYn1lxK3nFxT3D6nIdAqfN2dswY= X-Google-Smtp-Source: AOwi7QDEcyvkA3RhdVqLze5qC5NXmCGbPzyNlYv/yDg/mEIMkRCasmCLEUbPyLgy9I8LLN3t4X6ExA== X-Received: by 10.99.95.203 with SMTP id t194mr9406426pgb.318.1508254677247; Tue, 17 Oct 2017 08:37:57 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2017 08:37:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 08:37:42 -0700 Message-Id: <20171017153742.10026-10-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::232 Subject: [Qemu-devel] [PATCH v5 9/9] disas: Add capstone as submodule 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not require the submodule, but use it if present (in preference even to a system copy). This will allow us to easily use capstone in older systems for which a package is not available, and also easily track bug fixes from upstream. Cc: Gerd Hoffmann Signed-off-by: Richard Henderson --- Makefile | 13 +++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 13 ++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 160000 capstone -- 2.13.6 diff --git a/Makefile b/Makefile index 90f91e54eb..ca5eb489b0 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,19 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests dtc/%: mkdir -p $@ +# Overriding CFLAGS causes us to lose defines added in the sub-makefile. +# Not overriding CFLAGS leads to mis-matches between compilation modes. +# Therefore we replicate some of the logic in the sub-makefile. +CAP_CFLAGS = $(subst -Werror,,$(CFLAGS) $(QEMU_CFLAGS)) +CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM +CAP_CFLAGS += -DCAPSTONE_HAS_ARM +CAP_CFLAGS += -DCAPSTONE_HAS_ARM64 +CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC +CAP_CFLAGS += -DCAPSTONE_HAS_X86 + +subdir-capstone: .git-submodule-status + $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/libcapstone.a) + $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) diff --git a/.gitmodules b/.gitmodules index 7c981a42b6..1500579638 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "ui/keycodemapdb"] path = ui/keycodemapdb url = git://git.qemu.org/keycodemapdb.git +[submodule "capstone"] + path = capstone + url = git://git.qemu.org/capstone.git diff --git a/capstone b/capstone new file mode 160000 index 0000000000..a279481dbf --- /dev/null +++ b/capstone @@ -0,0 +1 @@ +Subproject commit a279481dbfd54bb1e2336d771e89978cc6d43176 diff --git a/configure b/configure index 11e3078936..5a305c0a69 100755 --- a/configure +++ b/configure @@ -4412,7 +4412,15 @@ fi # capstone if test "$capstone" != no; then - if $pkg_config capstone; then + # have GIT checkout, so activate capstone submodule + if test -e "${source_path}/.git" ; then + git_submodules="${git_submodules} capstone" + capstone=yes + capstone_internal=yes + mkdir -p capstone + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + LIBS="\$(BUILD_DIR)/capstone/libcapstone.a $LIBS" + elif $pkg_config capstone; then capstone=yes QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)" LIBS="$($pkg_config --libs capstone) $LIBS" @@ -6642,6 +6650,9 @@ done # for target in $targets if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi +if [ "$capstone_internal" = "yes" ]; then + echo "config-host.h: subdir-capstone" >> $config_host_mak +fi if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak