From patchwork Wed Oct 25 12:30:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117121 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1695676edm; Wed, 25 Oct 2017 05:36:47 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RqnuuKJ2CiG7/ANwAaeDg8B65sZwbkERgSHSwVVzlQuYY75ANysa6TfEHt5G0ebsELzmA0 X-Received: by 10.37.88.2 with SMTP id m2mr1228658ybb.162.1508935007003; Wed, 25 Oct 2017 05:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508935006; cv=none; d=google.com; s=arc-20160816; b=VKhJRSpUTQfe+K+G2mvsvCTcDNCaUKkxbITkOAQKgbNU8CSSA04DECviD9B9a78YOv 683u52wCRv4W5rveHXiATTRLAGFAlkUMKJsGiKwV2U7wu0ir494zWFovxoTNtYO4r8aM +G6zF0AQy9XDbJSpiCLMe4JqD7xQc7VFQ/+xjlZzzI4Ml017+O6Uy7kSdztok97RFTo2 T4EYuVNkm5EDQmVXLlSiGakEDbTCzU+hCg+A4Qv8vFRO4tMssSVx3ZWRTMroJJBYZKd4 Q1fA92iC4vYXaY+TKTimSLpZs534gKBjnQmwGqjXdvX47cimVjamCMGjJf9mrE1ljKA8 5AhQ== 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=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=r7fSy+OB9fB71vOdzYBor0y0hu/WcVDe9vS4ifg7o2CqVGQPFVa/Cw0/XEusqdHcsi WYdGVzj6v6qEdklqIqXk00e30ryWMz7xc5sqws/qzaEB6F2z/XFk/sjNPNiNqocaqJyw 2rxRH9eu0b7TIcCVZ/zRaoLPBEa2IfkuZVjMEcolOvJm4OEAF+QiNfkb2SO95X8uadhg qv1U7AwjLjCqJwPu7XJK0WoyJ3MWkkfMP/gWRuk9szkblWhfC7UXSxxcnR2xeKr2BwIW /bg4fkOe5nxx9hl5n+Ia1Jv4Hjcv+emDNx8w9r3+8BX2u8mgfkhvLK1gDAseHg+M9lJl IfXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MY9eBz7r; 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 m39si432025ywh.292.2017.10.25.05.36.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:36:46 -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=MY9eBz7r; 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]:48104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KvO-0003Er-Db for patch@linaro.org; Wed, 25 Oct 2017 08:36:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq1-0007Vt-4t for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kpr-0007yV-8V for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:13 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:56906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kpq-0007yD-W2 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:03 -0400 Received: by mail-wm0-x241.google.com with SMTP id z3so1590291wme.5 for ; Wed, 25 Oct 2017 05:31:02 -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=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=MY9eBz7rY1DF+khKlF55UzCqFFEshEzuVrpgT56C7GeStLc/qf5XV2YKtiLXQumV2P yApt8l+NZCDzob4mFp9QVCFOO1qfpX16+QJVJNxCae7y7X0zpxmRkkzNFRNlg9gWHxsM AtAdEXBrMx97bCKryNqB+tdI4+eHZoqNKGdDY= 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=NYOFWOWemQRN4J6eKraXGc5rW1vmFeGZ2VDO7BWbC4w=; b=NCQqaSuujHXAHbW6iTkdNuxT4v+f+ruGo026v/ORP3bU4zq/C9oCMvdRL+Ix8gU6qP aZQ/7G+ZMwSbGXmNAOyrRR35tMqSuq2K81ElR/nnwRyyz/NHExPGATb4RPC+iGGBAe9x tjzMYfbrMakBBFvTpUvgMCDBQSyR9U3Y4ZbX5vFN6erT7muKF05vBcYJo/j1LgUbB5SI jqyOEhMGyHVAmG+KPNP0On0FytyZoeI9acD5+pEDNiFyH8C6wogKBIK1T8JUbvSyvIMi 5XVFXObf9HjXk3E0pQ3n/V5rYsOa1zorKRGZ2IYEtStO7lmkqAVgq2xwP04u7/BNj3jA pLKw== X-Gm-Message-State: AMCzsaVCjOYhXJxBnYrXeipYaFGIzmfZqpbBwPWFuaS9tIoM7ZVdmqm0 NegAtSVvwD+xGrsvUgAyVs0Ba6clVMQ= X-Received: by 10.28.22.2 with SMTP id 2mr1651464wmw.47.1508934661618; Wed, 25 Oct 2017 05:31:01 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:46 +0200 Message-Id: <20171025123056.3165-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 01/11] 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: , Cc: peter.maydell@linaro.org 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 54eea3f9c9..7e22a80da6 100644 --- a/disas.c +++ b/disas.c @@ -204,16 +204,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; } @@ -389,16 +380,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 5f24a2de3c..69a87de83b 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8557,15 +8557,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 Wed Oct 25 12:30:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117118 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1693481edm; Wed, 25 Oct 2017 05:34:31 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TrBYc3FNeTbiIKpdl0yfPXdS3PQuYE19BrULyl4TkIPx8NO37vdmCC1bGSQZgq8p1yvk/L X-Received: by 10.37.217.86 with SMTP id q83mr1133084ybg.137.1508934871472; Wed, 25 Oct 2017 05:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934871; cv=none; d=google.com; s=arc-20160816; b=iIGAyRuwc5TjTJ0WgQPbyqT5ToK50bN3867bI9OnXBWFH9q6cXQ4s2vD0Q9dTJ/dk5 VrkLhFERLSX4r9UIJn1yJVztdZgSp/iFpVQUBEdJ89AlSg1h953infwlreW07Me63y8H 5dEnHqsvqnSCjc0FQ7b/qKYFXKBqPLcYwvi7joclgxBnMU9qPYppE2pA7TCAiockhXzh I026IxgL8Q2QSqtETO6PL97rHgZHGrTttuMdp5LkhFxAUcQ3sbFX2f/KyAT5SmlyDhpS IHY7tzCx3FxDfG7b1MuGXznirkhYJGivoNOWZ0TOCyuO3fzG7xM2uFwXMjk12uH4ZKYQ eOUQ== 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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=bwreQLHLk8c+wmnFr1sZgJ0UZ+SyzjsIv6gtBwUKCziQSpuEvm5v6W+bklb3vdLMEG MtMxbhgVcHreMuOviKrPZL6WnfuOZK8FLzed5h5/V7B3Cp6WLEFumjXkxxfAHC8+S/F4 /vmKGQyXee4f2n+c7x3+gnlhMbTkwVDGmWClo9mm4ch+SCh6fpoezKudcx6UQW5CovC4 t7BACLCUvT+mO1yOa46QqZYOscLdePQIXIDxWyn+sUUfPb5R8loXW8IKym5q8eLJ3GSA CRxGbDsbaB+Nfdoeq0fJc8Y0XrXPE957EIjAIwkm//WJNbfd+aeQxnPdSA8cDSXoXVQb TZyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kLgTtqgX; 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 c191si425714ywh.619.2017.10.25.05.34.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:34:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kLgTtqgX; 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]:48093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KtC-0001YL-QM for patch@linaro.org; Wed, 25 Oct 2017 08:34:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq0-0007Vo-CJ for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kpv-0007zY-K4 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:12 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:52865) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kpv-0007zG-AO for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:07 -0400 Received: by mail-wm0-x244.google.com with SMTP id t139so1626414wmt.1 for ; Wed, 25 Oct 2017 05:31:07 -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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=kLgTtqgXRbkS8y3oxJB6ZpjoZVnIuPt13vYd8DzwHSj7oRBdcOhj6F1d8xuCQCNTBb gdGDJWfQsCHe4dqUkPoXUJIvj/s3zZ/s1uv+yk3/Fh0GsxXkwECJyJAlbaXcrewqxltU 5I2iQVOxGsU9l7nGXS21da//Ik/Jz+rvrqrVE= 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=/LpK6D7McN6vBLyZwhejQizFGQYb6MJuJmPPhtR5cyw=; b=dI24DRBiBJ874nE7MOor1d9poIqbfGT2QYy2tt+UAUiK5JOoCk1FNbljsU1PrFWdnH 4w4udaKdxJ2qPuBlmUaI9SSt49jA+BY0CKE8h2KyzKMgLlrV6EIRfQgVrQqMKSRvV6UF wedb1wrOZBloqlB0Xa6asPylc7/7yo2U7TGan2F9FR4rvBy/bRXxSNZ8r0WUBZLdqNaQ ZNlKZJLt3WlbjcXkMe6EDAVrxBpLtyxLVmZiOMwkrFyKPaAYtOfCkpXp5Z0/DKBukYuV TYhBfrUa0jv8TgICPIubI3SkWXocfwHsXKjlzvN5BOc4qLlwn0sQUm+nAk2RL3svySEK 9dDg== X-Gm-Message-State: AMCzsaUjLrs+Pbv2NNb+C9+zJfIsZomWEVaB0Fj0Pmdg2wT2ymy+Wdlp k5o5we6UmhquXcG2A7eywy7E7m4PLGQ= X-Received: by 10.28.125.206 with SMTP id y197mr1790352wmc.85.1508934663190; Wed, 25 Oct 2017 05:31:03 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:47 +0200 Message-Id: <20171025123056.3165-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 02/11] 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: , Cc: peter.maydell@linaro.org 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 7e22a80da6..88d16fbd57 100644 --- a/disas.c +++ b/disas.c @@ -204,23 +204,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; } @@ -380,22 +363,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 a81ff69d75..cddbf92564 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7407,12 +7407,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 7b9bf6a773..9b4353437a 100644 --- a/target/ppc/translate_init.c +++ b/target/ppc/translate_init.c @@ -10519,6 +10519,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, @@ -10582,6 +10602,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 Wed Oct 25 12:30:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117117 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1692526edm; Wed, 25 Oct 2017 05:33:31 -0700 (PDT) X-Google-Smtp-Source: ABhQp+S4mD5pNj05GoPDt3ziG77aQ6BRC9Ng8KtYlnZ46JOnKwFjQ3ry23pRlH2ghoHR1hZrlac5 X-Received: by 10.129.131.135 with SMTP id t129mr12735482ywf.33.1508934811061; Wed, 25 Oct 2017 05:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934811; cv=none; d=google.com; s=arc-20160816; b=QarXDriubPgVRcHT7ksSV5RikaH8iTa5TO2YmAG3pwk6m+SgXm6sTvV/jvOsfGTmDq 2/qw3Av5eatAZf4SFz7YZrV0Z3E++3f5ki5Gn/R1lwI0QvkjHvbWDJNXkVV3x/yE1Emn Fdl+WteECK9ldLxceA3ST9Qc42d766mbSCiU87GphtB+SqShLqy5p8wIMKXskr27z2bs cv8RPGsC0xAUSvf1Ei3zxnfKXZAwTjVci/Y6W8EQ082OVwAXU/gDYC1S7AnldOldGuDk FlKlT/Y9AhLgXxZHuPbQapvnmWnpTl2TjbXuOwV8GqUotSD1SOhD+rSeYC85KqRB34xS kgZQ== 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=FPw5KVv+Tsf7CBiTC6hfJzOj5/5ZiPY8tXYLV5ut1kM=; b=iT1KarwpHdUpmUJfvXg9Qx8C6wqHecq+2z3+P74T75yQk3Qhm0ucD2bE1UFY6kN+1f nwXv3wFeemEkX02UnPvLYH6xzm8a4KlCzVvR82rZzQMCq5UG8s/GNdNmL+rnB4iq7vw/ q0d8TlIzvxg4VlanOe0n9BGr8mc3p8ba1lGG3I6iaoXYNkHLWCcBMdVzLnC9g9gvxaGK NybJ23CKL6L/beUEBvhmfgMne23hOGRKqB/6JXyLAeodzWaB4dbEdGfBxvb6UAPFoLSD YQrJFKqJTx+0m9vqufcggn328971ZuwxFp0EelCpbf0ngqRpuMGerD7TxE+TCHEbQwZU uvqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ax6dlokO; 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 h24si412321ybj.340.2017.10.25.05.33.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ax6dlokO; 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]:48089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KsE-0000PR-D9 for patch@linaro.org; Wed, 25 Oct 2017 08:33:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq1-0007Vu-72 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kpw-00080n-QG for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:13 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:51742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kpw-0007zn-F6 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:08 -0400 Received: by mail-wm0-x244.google.com with SMTP id b9so1634896wmh.0 for ; Wed, 25 Oct 2017 05:31:08 -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=FPw5KVv+Tsf7CBiTC6hfJzOj5/5ZiPY8tXYLV5ut1kM=; b=Ax6dlokO2Z1fHmWe9EwrBgUJVX84eJOyshA080kFBTQITAaQ85NqLv0/HYFvrKo+Xa eXCmXWoIHT2kPihUvBBcselJft1dZm9eEFHRr90fP8NSuynisncrh0y08FH24lSNv420 OFIguk9l7WDHs2ZePUCvpRmIkdonU81vNe97k= 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=FPw5KVv+Tsf7CBiTC6hfJzOj5/5ZiPY8tXYLV5ut1kM=; b=jyCd+kVHNyU+GdUFKdhP3lZGzYxUE4oUtatorCqNX2zBm9OmHLVhbvTxVYnC1hGu0c Ll2Fu4RzDCckXHcQyYXCqXoDsznKQdtm+n/uSyhI8bw0KieTIC4c/aRgm5KpHZfT01RW HDdNhXyhsuQbrjIwP52MRqD5BJw6iUjJBxrmeJs9by0k0u8bR1A6jpbqYcL6+SWvEb93 A/2VkosF3uKKVKvJMzRd0ipngTiQfZirnvXElmNa9fk4UYG+0ZvCfwZEI20oxGTcCU4X aahgd4VKgW2wtl56mPPEG2nm3zz6wmZ6h14F4m7yKnNvOEhIvnvRZJV5DzgbXyBH56pD Hu2w== X-Gm-Message-State: AMCzsaWY6psyEuE6rjsvOA/lplnB7CdW2Iqf1bDoiU7FTsgLG/UIvnON Gs8/NUvn3WwMDNklnPgn52Sn9xRnu5k= X-Received: by 10.28.141.194 with SMTP id p185mr1718637wmd.149.1508934667147; Wed, 25 Oct 2017 05:31:07 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:48 +0200 Message-Id: <20171025123056.3165-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 03/11] target/arm: Move BE32 disassembler fixup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Capstone disassembler has its own big-endian fixup. Doing this twice does not work, of course. Move our current fixup from target/arm/cpu.c to disas/arm.c. This makes read_memory_inner_func unused and can be removed. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/disas/bfd.h | 7 ------- disas/arm.c | 21 ++++++++++++++++----- target/arm/cpu.c | 19 ------------------- 3 files changed, 16 insertions(+), 31 deletions(-) -- 2.13.6 diff --git a/include/disas/bfd.h b/include/disas/bfd.h index d99da68267..2852f80ed6 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -307,12 +307,6 @@ typedef struct disassemble_info { (bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info); - /* A place to stash the real read_memory_func if read_memory_func wants to - do some funky address arithmetic or similar (e.g. for ARM BE32 mode). */ - int (*read_memory_inner_func) - (bfd_vma memaddr, bfd_byte *myaddr, int length, - struct disassemble_info *info); - /* Function which should be called if we get an error that we can't recover from. STATUS is the errno value from read_memory_func and MEMADDR is the address that we were trying to read. INFO is a @@ -479,7 +473,6 @@ int generic_symbol_at_address(bfd_vma, struct disassemble_info *); (INFO).buffer_vma = 0, \ (INFO).buffer_length = 0, \ (INFO).read_memory_func = buffer_read_memory, \ - (INFO).read_memory_inner_func = NULL, \ (INFO).memory_error_func = perror_memory, \ (INFO).print_address_func = generic_print_address, \ (INFO).print_insn = NULL, \ diff --git a/disas/arm.c b/disas/arm.c index 27396dd3e1..9967c45990 100644 --- a/disas/arm.c +++ b/disas/arm.c @@ -70,6 +70,17 @@ static void floatformat_to_double (unsigned char *data, double *dest) *dest = u.f; } +static int arm_read_memory(bfd_vma memaddr, bfd_byte *b, int length, + struct disassemble_info *info) +{ + assert((info->flags & INSN_ARM_BE32) == 0 || length == 2 || length == 4); + + if ((info->flags & INSN_ARM_BE32) != 0 && length == 2) { + memaddr ^= 2; + } + return info->read_memory_func(memaddr, b, length, info); +} + /* End of qemu specific additions. */ struct opcode32 @@ -3810,7 +3821,7 @@ find_ifthen_state (bfd_vma pc, struct disassemble_info *info, return; } addr -= 2; - status = info->read_memory_func (addr, (bfd_byte *)b, 2, info); + status = arm_read_memory (addr, (bfd_byte *)b, 2, info); if (status) return; @@ -3882,7 +3893,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) info->bytes_per_chunk = size; printer = print_insn_data; - status = info->read_memory_func (pc, (bfd_byte *)b, size, info); + status = arm_read_memory (pc, (bfd_byte *)b, size, info); given = 0; if (little) for (i = size - 1; i >= 0; i--) @@ -3899,7 +3910,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) info->bytes_per_chunk = 4; size = 4; - status = info->read_memory_func (pc, (bfd_byte *)b, 4, info); + status = arm_read_memory (pc, (bfd_byte *)b, 4, info); if (little) given = (b[0]) | (b[1] << 8) | (b[2] << 16) | ((unsigned)b[3] << 24); else @@ -3915,7 +3926,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) info->bytes_per_chunk = 2; size = 2; - status = info->read_memory_func (pc, (bfd_byte *)b, 2, info); + status = arm_read_memory (pc, (bfd_byte *)b, 2, info); if (little) given = (b[0]) | (b[1] << 8); else @@ -3929,7 +3940,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info) || (given & 0xF800) == 0xF000 || (given & 0xF800) == 0xE800) { - status = info->read_memory_func (pc + 2, (bfd_byte *)b, 2, info); + status = arm_read_memory (pc + 2, (bfd_byte *)b, 2, info); if (little) given = (b[0]) | (b[1] << 8) | (given << 16); else diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 88578f360e..82dad0b721 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -473,21 +473,6 @@ print_insn_thumb1(bfd_vma pc, disassemble_info *info) return print_insn_arm(pc | 1, info); } -static int arm_read_memory_func(bfd_vma memaddr, bfd_byte *b, - int length, struct disassemble_info *info) -{ - assert(info->read_memory_inner_func); - assert((info->flags & INSN_ARM_BE32) == 0 || length == 2 || length == 4); - - if ((info->flags & INSN_ARM_BE32) != 0 && length == 2) { - assert(info->endian == BFD_ENDIAN_LITTLE); - return info->read_memory_inner_func(memaddr ^ 2, (bfd_byte *)b, 2, - info); - } else { - return info->read_memory_inner_func(memaddr, b, length, info); - } -} - static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) { ARMCPU *ac = ARM_CPU(cpu); @@ -513,10 +498,6 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) info->endian = BFD_ENDIAN_BIG; #endif } - if (info->read_memory_inner_func == NULL) { - info->read_memory_inner_func = info->read_memory_func; - info->read_memory_func = arm_read_memory_func; - } info->flags &= ~INSN_ARM_BE32; if (arm_sctlr_b(env)) { info->flags |= INSN_ARM_BE32; From patchwork Wed Oct 25 12:30:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117120 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1694910edm; Wed, 25 Oct 2017 05:35:56 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R/lumRmbN5Sk7vMsNOdh7hHO8AXOgETi1aULzoLbwnneuLWJNfqzqDI+ijnL/YLPIuo+QB X-Received: by 10.37.22.65 with SMTP id 62mr401835ybw.410.1508934956222; Wed, 25 Oct 2017 05:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934956; cv=none; d=google.com; s=arc-20160816; b=KGK3Odj9g/VR0MegDtStNVJLnmcgnIYz+pvEmaQ9TCx9IDXsV+XUqopiLKGy/GBKaR dK8khSDoQPNBwtd4FpQakwMOY7LDL4MDOCv+CgGVerotEuI4AXxgXTn+zyzTbWAKqf1W umWJLPG39lr3yxNGoaHzS1Wzh4uqkMzqCK9NIPdZaNB3QmepTfWEwTDjGxwIOEmxGmvN n3uUKtuvUtoxdAlYbjNx5yAMKnMWXega0976uILf7ttt7IsnUwvO6bzHzVC4CEGg3QoP YDiN0dCkKtH5tqzbwxsGuk7h9d6kQNvJciO97hifnX0zDNuevt5+KFygE2PRWhZYqh9d 7bUQ== 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=qD7w2+caXAbTiodra7apFT8LXQDHNlMyP4XJlt2Yk5g=; b=aHm24bewnGz8MQWJs8d9Rz72BlCidMVJBIC+HmizqFIj/J4RKigksDEIBY4PHBu13c xdpvndwZEiPUKFg2fB/SVHwlRCekTluZaTg53B4PIzqeDOD/Tohmhr+Cd/SwgArm1ib4 PbWjXdRTg+4+lEv759GEVxLpLnUOaohEyHIptwontzr1lEOOpMLBNOvI0nGGbBHNVJXC Q6gCa1/h2/7GB5NqhEZ0++vzeYDL76tmyv4ReMBldv9R2adIBQH6bu1NFM9/Ga5DUvtU 7x3pd7K1c/tnNkTwulqn+QpjZ7Y75exyXQyanNUOPfjMhIgJHyXcdZaHwVbBOzyUox4H O7OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NSZFFfZl; 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 16si405690ybf.42.2017.10.25.05.35.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:35:56 -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=NSZFFfZl; 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]:48100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KuZ-0002OO-Gk for patch@linaro.org; Wed, 25 Oct 2017 08:35:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kpz-0007Vm-9M for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kpy-00081K-5e for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:11 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:43868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kpx-00080x-VK for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:10 -0400 Received: by mail-wr0-x243.google.com with SMTP id w105so14534876wrc.0 for ; Wed, 25 Oct 2017 05:31:09 -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=qD7w2+caXAbTiodra7apFT8LXQDHNlMyP4XJlt2Yk5g=; b=NSZFFfZl/7dBZWvg2HQMLTlFz7KBRd/svZNLhVaGGqz9VHN8zI6BbdnrkEoXHMomLy NUSlyMdtpgzZ+JGoVPJtSqshndBBfqqv3HO8H/41jRL+7RGZ7Cg4ZELqXPGYA6MaaACq 9CpdiUU/6D79l10SRVvE8l4y14UolR7N5E2JE= 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=qD7w2+caXAbTiodra7apFT8LXQDHNlMyP4XJlt2Yk5g=; b=fX6D+fnysCtqhTvrugn6HTC0/nf/TWLe5Q+iqbr+42Qvlwa6iIKuLoqbAaAcc7rhA5 a9I5u+9MqDg+RYG2ZG8P5dGRSEssF5h/QF5FX4c6DOP9PU7zDVEYT1TM7GcacM/ZLw8k RbqwVZk+owvDAvB/VPge3aKFVWrk3rngsNMG0yuPHCOAumgIBXo2t9BLW4gNt+MRhWft DA85iMY8VlciMmm7xd/lPjMN9bFFcgLh086LRztuQb4KxD5hNZdh6nN4SHmFsAjBzNzb yUzBfwlBweRoZPgBUkvJ5xBz3jwk477ZPnHRFudpRWyrfosGmGW/d9AerTbjsyQHpKwd f7iQ== X-Gm-Message-State: AMCzsaXAh9mCWapdTggiE2imI8jt8fOnLw1HUxNKQZbxZRPcOreY+/VP ZD8qXEFKgJNqhoyubYJTDLA0l53OGkM= X-Received: by 10.223.143.54 with SMTP id p51mr2004890wrb.138.1508934668774; Wed, 25 Oct 2017 05:31:08 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:49 +0200 Message-Id: <20171025123056.3165-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 04/11] target/arm: Don't set INSN_ARM_BE32 for CONFIG_USER_ONLY X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This matches translator behaviour in arm_lduw_code. Fixes: https://bugs.launchpad.net/qemu/+bug/1724485 Signed-off-by: Richard Henderson --- target/arm/cpu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 82dad0b721..a92d86faa0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -477,6 +477,7 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) { ARMCPU *ac = ARM_CPU(cpu); CPUARMState *env = &ac->env; + bool sctlr_b; if (is_a64(env)) { /* We might not be compiled with the A64 disassembler @@ -491,7 +492,9 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) } else { info->print_insn = print_insn_arm; } - if (bswap_code(arm_sctlr_b(env))) { + + sctlr_b = arm_sctlr_b(env); + if (bswap_code(sctlr_b)) { #ifdef TARGET_WORDS_BIGENDIAN info->endian = BFD_ENDIAN_LITTLE; #else @@ -499,9 +502,11 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) #endif } info->flags &= ~INSN_ARM_BE32; - if (arm_sctlr_b(env)) { +#ifndef CONFIG_USER_ONLY + if (sctlr_b) { info->flags |= INSN_ARM_BE32; } +#endif } uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) From patchwork Wed Oct 25 12:30:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117124 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1697755edm; Wed, 25 Oct 2017 05:39:01 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Sl/eGwRyI5VOegO1JONORFhWaWR7u3cCJ2QP0oAZjUAFq+POyZOAtiMH/82Xx4d/us5apj X-Received: by 10.37.12.68 with SMTP id 65mr1132175ybm.48.1508935141177; Wed, 25 Oct 2017 05:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508935141; cv=none; d=google.com; s=arc-20160816; b=DAbnAy1J6c0Snj7tQbMS65f35LG39GzNuc8+9DI/gPuzFKuPsYWddHBxXc+ceg2359 XwhlCoDmfTVo8PWSkud/jeCQ789xUltF8fFwhPhvgqi3Uckn/x2dqTdJctTX8Pb05/P8 WOvFGy5n0TC90Y8SZO8YIgkqTy3NmXbQ1H84kS8n+pfmKRnbUXslHStbyrvGJ/QqY3xI K06DDos0TnaSNAaseSEMg5vMaQ+uRoN2D+baP6KgfwzhoJ9v1ljfKL3usyhKnCJj23DA d2Vdk5XxGpe476Tkc9riQ4oxtP1I9/Gx0Xrc6U7OQAWt/GRjaWx3TtSP6dWDqe91eyEW g1qw== 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=zFsdqAbF93xXjZ/MZuq1lSQULhSBp09dXZ8KmQhthVo=; b=KOWKeJnc/LJCDoVXGKi/KnRHBrAOM9X995mVk6RjB0SC4hJgoaWOOTPhRuNIQsnbQ6 nHp3/DTj+hPSIUt23Mlbd/lrKB/iCkhUHCV6aw8eBATNas5xGR2/TJptUeaj1tOtbiDE qy6qPJjJOULa5lu4D2cimJDzOaG35sbx/qj0Rd4kB5J1YPnPcvGNFTlxIFvDpOp81zod dgeSONk+UMs3ezqjSrLxQhs2zaST+Pa4xlhcQ6SKar9IVqolbgQx3AXtT1u40tESwJMt F/ys1GiyEGLDQh58cOEsrHy5SzVuLFD6oCyXDgdrysjRwAhRwhRX8n6sqabhob1ijaPH nLPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dkddfN8Z; 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 o128si402765ybc.285.2017.10.25.05.39.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:39:01 -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=dkddfN8Z; 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]:48110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KxY-00053k-KF for patch@linaro.org; Wed, 25 Oct 2017 08:39:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq6-0007ZL-E8 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kpz-00081m-Nd for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:18 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:51744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kpz-00081X-DU for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:11 -0400 Received: by mail-wm0-x243.google.com with SMTP id b9so1635190wmh.0 for ; Wed, 25 Oct 2017 05:31:11 -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=zFsdqAbF93xXjZ/MZuq1lSQULhSBp09dXZ8KmQhthVo=; b=dkddfN8ZeyWwa+9wkaR4NUTQQJPrXaK/yUv6s3kvwXEw2+2qyLcr6mnlD2NDaWkkZX W/oplxMwxV6Gd/LTaxNGciZMkrAjAdQ9A6ZMzitwiN7oPxI98oOFATfXdOCRRmnq3CEo gl7IdWTIX8OO9/mlWWTuJK1oc7HF4hdiwaN1M= 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=zFsdqAbF93xXjZ/MZuq1lSQULhSBp09dXZ8KmQhthVo=; b=FUQv50DKaonK7lgzqdI7o74fTF3PBdbLr+41/H009zfOuQ0Nh7vEe1Nrwf2GHZdchq inNmkvIRfhlqMxqcNiNtb8N4JlCFyDLrDZDXIR85FSatmmSfjl9eOXuyWZzhqpqg124d 31+8oQYW5DQ0d8yQDLW7STJ7rERLBHGkxHISr10Gk5IHNDPrtykLFa9smAizxQ0D9FzR ygmt/70G2HcLJWpZa+8170VGrgRCYRwmIk44WvtR86/ZiqZryyap7JipgeTaVtOybYZI CFke3TF6zbZ2Cu1ANU6cUDNhmXOuVnIs2ilTR/m6QRcZKe8Y76C2xJZDN6wajsMiLjWm MV4A== X-Gm-Message-State: AMCzsaU0j4FebLqxP38SzK9ftxr66iHbS9BRN25DXdtbLUkteO9f+zxP +yj2peFJaBWJLuxMZ+7BFgUePjb9LcA= X-Received: by 10.28.69.210 with SMTP id l79mr1684402wmi.117.1508934670018; Wed, 25 Oct 2017 05:31:10 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:50 +0200 Message-Id: <20171025123056.3165-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 05/11] 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: , Cc: peter.maydell@linaro.org 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 88d16fbd57..2b26466b61 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; @@ -335,10 +329,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 69a87de83b..e81479a50c 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8559,7 +8559,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 54fbe898df..0d2d03d2d0 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 cddbf92564..469ebeb446 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7409,7 +7409,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 6ecf764a98..1ccdb35df2 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -5972,7 +5972,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 Wed Oct 25 12:30:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117115 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1690817edm; Wed, 25 Oct 2017 05:31:45 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rt5raSU/JYbGFelvtGlSBMR/ZuE3mqfjG+qDm0ptTCj3eGLugJ44U0ascAEwYlEA/gDx06 X-Received: by 10.129.105.198 with SMTP id e189mr12972208ywc.394.1508934705767; Wed, 25 Oct 2017 05:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934705; cv=none; d=google.com; s=arc-20160816; b=jgQvZYx5/Txc4xN1xTw3e51MWHiuAcneFIeFMp24iZfkCJfqs913I+9rxDSbKx/D/n 5eIsX232N2crf6Utt1ZiQUXKCSp3oiRQIdBCuM3WsTDYH70XucxGjoJRbR61ZNf2TN7G HHpEiqchEPzaEB1lUPx1DfM3cf4vCfGqRwRUPwqbnKR5SrGqKdSu8CqchKwBiNI+QXXH o6blIsk5Sc92bbWSKbSGXPYpFBdC8/lqpTpmu0JhWsEOpgbEaziP0nEAtOCfOJ1pfF7q i830mxwpa7VTvFA7MRvduHy6LFvjqGVPbse0Dn5tdPrCMmjzcPgPuP/5IhGBFI2M+8RT MYsQ== 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=tJEywJ+CW4l0qPNVl3lJcjRnYBouRnECsjHaD/WUiZM=; b=ZUWD5pDA3GYDKx19801rQdwZYmMCkFcY7xQi062g3Xe12a4vTnieBY6Kk6aizw8y7v wdMpjXUTHggmr0c3aRaYwJD6QO52/XpbGBbEVOZDme83cSRmvem6FX8MzdIafuVOrk6c wL6+Kt9aT2VxMSAmOB21oERg7vrzGxxfxKKxu/FCyJpafUZ+1d1l+i4p/a0npjmvT/a3 zDWNxCenkya/hEPMa2EWHDA/rS91oZspqBwzIHqD+BVZWkObuZSFEwfGW3Xqntlod1jP VmvvheTfQMKNbzCdr7YKARuwpX8Dmqj0/2UnwlSTpYCnsyfRFE0JmqetermH4BU1JWIW j1WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=CQmtQ/p+; 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 d9si416026ybn.118.2017.10.25.05.31.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:31:45 -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=CQmtQ/p+; 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]:48086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KqX-0007ZA-4h for patch@linaro.org; Wed, 25 Oct 2017 08:31:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq3-0007WP-2f for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq0-00082Q-Ur for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:15 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:53354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq0-00081s-Kp for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:12 -0400 Received: by mail-wr0-x243.google.com with SMTP id u40so17982987wrf.10 for ; Wed, 25 Oct 2017 05:31:12 -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=tJEywJ+CW4l0qPNVl3lJcjRnYBouRnECsjHaD/WUiZM=; b=CQmtQ/p+lvWjGh5hUOl+D2nHEgQor9MzWkKEVk3U0aF4WUqQZMYMbJnI+U38p4YWg2 jqs3zxR8FPEpvsg2GY+K/ysSKt/+4dUc/w9sGn8cIdiYgWFwIJnLYzh1w+dLL+CUMjYW tbl6QDtP7STXCyiVzE/r2VTRoJeWPmdIXAenE= 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=tJEywJ+CW4l0qPNVl3lJcjRnYBouRnECsjHaD/WUiZM=; b=qUY/diOwMZ0PCY9SZrmM/tOfmsWpwbQM3jDgcCqT/GF4YfKsG16ZOUNLgR0VySW+h7 hNeVMZz39YB2OXeZ+UTOSt8e/002qONRS53ln5uxdO2VsB5QubhdzMMPXiaakvjekn5b JP16KWbakV44ryJQqQx3lTsN/SIlWhWd4knflmeVi+Giq785KQnilOpWJkZG1qv/smnL UZoPc9xEjBxehYsLjg8KulqiG98K5rOWoh+z+yVuTkLdNhIDSdzdJJcB1EHt4HTIFbA8 IB1ZsD0R78z8uznnCbYbHuheSL8cXZMehkpXMFMIOh4qbiiXoG6gVn4K+ZSpz6KOhIvu zZIA== X-Gm-Message-State: AMCzsaVB6gKHoPRf8B7lPnZJxbu9g4smw8t2OrIcuj1J24Eciqd/iI8q PJd6tCubcVtlT6XG1q57mj9ch2eRMME= X-Received: by 10.223.189.148 with SMTP id l20mr2109248wrh.188.1508934671205; Wed, 25 Oct 2017 05:31:11 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:51 +0200 Message-Id: <20171025123056.3165-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 06/11] 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: , Cc: peter.maydell@linaro.org 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. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé 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 diff --git a/include/disas/bfd.h b/include/disas/bfd.h index 2852f80ed6..1f88c9e9d5 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -371,6 +371,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 2b26466b61..e392a2926e 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) @@ -187,6 +374,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; @@ -198,6 +387,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; } @@ -205,18 +398,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; @@ -244,6 +425,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; @@ -281,6 +464,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; } @@ -343,8 +531,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; @@ -356,6 +545,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 03547cea6a..d06ad64058 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 @@ -4411,6 +4417,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 @@ -5468,6 +5490,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" @@ -6142,6 +6165,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 Wed Oct 25 12:30:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117122 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1695713edm; Wed, 25 Oct 2017 05:36:50 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RJpoDHHbbsJa0U2XmD3HJnJdGNbiDSUnlyltnQfY9rI2Hp9fnGtPlc+P2fZEoLo6di84JJ X-Received: by 10.37.135.76 with SMTP id e12mr1144585ybn.279.1508935010378; Wed, 25 Oct 2017 05:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508935010; cv=none; d=google.com; s=arc-20160816; b=lHze/LXfufj3WT1HvIesgV0lkVS+nQlvV7iZSbGr5RttDE83wPTApq+6NGoCt7G81n r+sHX9Xnlv5WeaYpG4S2qBb4PIOPLSVP7s3HqhdvDM2UdGcjgPL21qk242eM3z/8nHbM 1C7+GiL9ZBteHtq7wU99cR8Gmk4xsD9vcXj8eiulecFQLXlle6pGqrk2Qd9bZbehOU9S 7/AodwTJhLdZT6NeTybTH05MGST9S+wuTZ0Oe+111ZNs0w6G+nPMnqZS01wc9B8RN93F n02/cXtCtenL2UdL51huFYNIbRWVP/XB6O+8odLurdNU7gOp4755qiwZ/R3YU4bIDOQT uq3g== 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=xJrcRhjTjS8woKo8cUxQgDWgKyEKvRsoQ02n7LfkoEpg/sw1LqMYoVlJsIomrkWe8z aCkNT9lxOZfBnEZPEjbEyqVa8O63EtPLkUgJupOrsoZ/oc0NwfBLMgaEilCs0RbgtTZ1 m+rVzHNK22tIG/uUIhiDSRrx2zPiWVNL/iB9BXcOS7SSKj3VDFjDACiyYtyBXoZux+/Z ffZi+y/yyeLji6hPhmyyteCSASD8HJsrl0Z3ezNS0CjlLRX7uDaVU1EPe+CxEERhyRzN mROTNBdJ69Mc+4GRXfADGvDd3GI3U778M/ddAwX9SAVu8gn6yPmrw3Mj/7BsTIzjbR/j S01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Gi9JZfbo; 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 c85si410693ybf.647.2017.10.25.05.36.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:36:50 -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=Gi9JZfbo; 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]:48105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KvR-0003IH-Ow for patch@linaro.org; Wed, 25 Oct 2017 08:36:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq3-0007WX-AT for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq2-00083R-7x for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:15 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:54239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq2-00082r-15 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:14 -0400 Received: by mail-wm0-x244.google.com with SMTP id r196so1625100wmf.2 for ; Wed, 25 Oct 2017 05:31:13 -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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=Gi9JZfboic5UNxlfFtai6qzCa52j4vdTKGy0aZ9xeP8nk/SAVE8Zo2B41B96UhtzEC jb41aLo2CVdV96Y3wzhej+ZZ2JDY39FTyRYS3J8a86gls6wcxn494uVuP2ckfdJM/Aut eEazcof43oTUM5oSJFEcd1kJ/SQ9ohGsFvWns= 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=2iMMn6n97w6gqxrsVza5ry/hdw0ZDWk0Pu8fMUSHJVI=; b=H5esWvuHARWVMYph1b540JeDUPUeppwc7Rsr94KoTNjgZw3gXs5Iqo5krawHsrU3Oz MjVJ3X+tFDkC5A4teLwf1BNKsKc4NSg+0LKF+SwKIxpdYaXeKtfbZMg3W+1pMQENq3p1 knAtKPPTg0TS0dLWHXmqeLpDlaH9klKK+k4i/SuQdQf8alHLYzEQBJXqUen0rhdqRqtm kB1+xRwqTikkLgCi5E32TJlKzIBKq+Zyxwm+9hAC2XHLnUXhlPnau/vkAGZcv6VulYae cec5iEXndhkqCGy6VKSnTmtzm7iFIidLr28wf4JmmeiborXGVLPSljh0fL+YgXtcXHye Ed7A== X-Gm-Message-State: AMCzsaWUYm3hf5KMuCH2UILeuW74PnAn7nYiuZSToLUFke8iNNvtJk9s Ra6ZVOSTJmF0IDc1hR0nHEUdLndRPhk= X-Received: by 10.28.55.2 with SMTP id e2mr1774896wma.60.1508934672832; Wed, 25 Oct 2017 05:31:12 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:52 +0200 Message-Id: <20171025123056.3165-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 07/11] i386: Support Capstone in disas_set_info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 11 insertions(+) -- 2.13.6 diff --git a/disas.c b/disas.c index e392a2926e..63dc573e9f 100644 --- a/disas.c +++ b/disas.c @@ -438,9 +438,13 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__i386__) s.info.mach = bfd_mach_i386_i386; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_32; #elif defined(__x86_64__) s.info.mach = bfd_mach_x86_64; print_insn = print_insn_i386; + s.info.cap_arch = CS_ARCH_X86; + s.info.cap_mode = CS_MODE_64; #elif defined(_ARCH_PPC) s.info.disassembler_options = (char *)"any"; print_insn = print_insn_ppc; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 13b2f8fbc5..cf890b763b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -51,6 +51,8 @@ #include "hw/i386/apic_internal.h" #endif +#include "disas/capstone.h" + /* Cache topology CPUID constants: */ @@ -4106,6 +4108,11 @@ static void x86_disas_set_info(CPUState *cs, disassemble_info *info) : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 : bfd_mach_i386_i8086); info->print_insn = print_insn_i386; + + info->cap_arch = CS_ARCH_X86; + info->cap_mode = (env->hflags & HF_CS64_MASK ? CS_MODE_64 + : env->hflags & HF_CS32_MASK ? CS_MODE_32 + : CS_MODE_16); } static Property x86_cpu_properties[] = { From patchwork Wed Oct 25 12:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117123 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1695825edm; Wed, 25 Oct 2017 05:36:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RqqsXXsb3inO/IpqROsVwblZVwSkeqdW5jyi2CvZM3pvcQYp1lsoN0t60AqMHYC4KCVo8d X-Received: by 10.37.17.2 with SMTP id 2mr1115352ybr.398.1508935017195; Wed, 25 Oct 2017 05:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508935017; cv=none; d=google.com; s=arc-20160816; b=fae0e6fWzKvqStCLsrElWmD78Hv/sgtWezPjyoA7SxxCYCvXCh8zcY6onVzQ43xtWA 9Evk3axobdFaxpYO57BVP/1fwHkGkB6A4mRrcnTzL4iTU7wvqaXWxtIlk+O9IcMebck7 KVa6lEzhCReGY237wiTH2c5gZpAu4l92N9V8FqkZzQ9NVsKvkv4slgiooneCJDelH9wu w5j66KclZrOvcJ62t3icjJI4ndK4z6gLv7Lrdt+hklRvmJfDseDDw72M3gM2rVV5uokm qEWsZGuWEKqOi8iwCbte2Po1t+rhZqikv/QGCokkgma8Le2Q27FTasx78t7At26bJpT5 kejA== 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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=TCN0xneNfttwKl2xUhyvfIPk2bGtYS+leDsQ70J4miI40k09ZI5x+4IuY8tuM09IdX dS6M864Hi86W6gHefY0XFadlkae+gFQtlNU52EOkhAci8+chOslX/e6/EHFRzvR5dD+5 MG4pIbu3mnQeEIRlMNZXnGEYyQhc/723gOsvp9rvjVt3MOaSo1aCBWkvrDrA/bn84yBL NdpyJTHKNJR3M825Gx16rRmAvvziN43JmO1GT7RWG56zmABbJfd+RuzGCtdvn+AfMg1M qhqpCeGp3NAoUasiZNc7xlkLwtv0F9p1LS2c6sv40km82EdnpvBsb9NJFTIIs89HHw4T 3GWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eA5nym/5; 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 z192si418730ywz.774.2017.10.25.05.36.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:36:57 -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=eA5nym/5; 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]:48106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KvY-0003PL-KG for patch@linaro.org; Wed, 25 Oct 2017 08:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq9-0007cL-Ix for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq3-00083n-AD for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:21 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:47770) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq3-00083Z-3r for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:15 -0400 Received: by mail-wm0-x241.google.com with SMTP id r196so1574862wmf.2 for ; Wed, 25 Oct 2017 05:31:15 -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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=eA5nym/5f2Gvf/+83HohC97diuD287ZglfbhhiJIB5uzbSwuUrxFAToJ79KUGE2/H/ LerBE4U7Hx5rZEQt6F5hL7oXm3hO4Ug0F0iazBMpAVYjQWYj9WJ88KQGEJrUpAkzBLDo IYppQeK7C/Uy7hS+RwfK4Ef2XU3RNoYEifwmU= 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=cPIeDQxRw6/eQEErEgelF2hVJp+W2ZE7jF6N8CBm+3I=; b=WbjDznW0SFi8sehnHy3UEXE49bAeFXTrmknxiMB5DC+guIBamFqE36JuCpZ2yB7hp+ ieXNTwmj3hGakUwTE6hGY9MSzaV1HyR4bKIcN8hJ5rmJPQUP8zAe6iOT3KXZinhh+zjT o4q9G5Nlo7pPvagI7O32p8tXVXB3o30aLYAkpmw+/8YOeBu64RhsdbUYosOUy6gU7spW 7Zb80b9uszE0WoogCKWOx8lus2Z8TaRLxdYUK7GZjYhZtIojZQ/pgpMk5gB5ytA+IBA+ /AcWAmMkPHIAQavjsLwn0jeNAYVMCz5/ED9C+4GsfuZYeuSI+cnzgB2RiPr6krW2uPP2 DCcg== X-Gm-Message-State: AMCzsaWaF95XbBjjKbF7h4q2HbzLF30sAqHzdeSdrUoVKFj6yFQhQ1PF L46BqOUKl3L5Eo7Rc8AefRjZlNJd0ps= X-Received: by 10.28.22.2 with SMTP id 2mr1652072wmw.47.1508934673958; Wed, 25 Oct 2017 05:31:13 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:53 +0200 Message-Id: <20171025123056.3165-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 08/11] 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: , Cc: peter.maydell@linaro.org 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 63dc573e9f..8d9bd4901c 100644 --- a/disas.c +++ b/disas.c @@ -450,6 +450,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__) @@ -457,6 +458,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 a92d86faa0..a0ed11c9a5 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) { @@ -487,10 +488,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; } sctlr_b = arm_sctlr_b(env); From patchwork Wed Oct 25 12:30:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117116 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1690857edm; Wed, 25 Oct 2017 05:31:48 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RbLBNGm058bVFNqVh292LJIrO5w83Sua4jF+SdbsOSQBf8UxnkXfK3z+fdpfOhEIX0fGPK X-Received: by 10.129.157.79 with SMTP id u76mr12881813ywg.382.1508934708245; Wed, 25 Oct 2017 05:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934708; cv=none; d=google.com; s=arc-20160816; b=a4wIH3vQQZ46h/vz715JY53XxddPfPcuvvn5KfzPTiefYTUCe3pyGbxMSxoDGcoOeY nQkliGm9zIuciGOLkxemKH3e4G7y6qyLRXY3mjXUsx4R1soUo0ruYjfeLPl7BUSky49T kBVCgzN2qdA+W1fvvyXxnmjiGPuTRR1V9tth07Mtfeq3fGjx0M5fJ5RZwQ2VLDfNkPup ujIeqHPbGVZoYeBNPmmiD7A7Hqdv6Aczo/oJBn1Khi28zktqbK5FEIANULcpmmsFL6oB YPFRv1sAJjwMF9Xr/7fdh1ZBGWf0JStBy6KxITD+YEWZxcpU1+n/PwXXpgmnppQGYJVS 3LuA== 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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=Q7DMCsCouaJyPSzNRrbKoqCM/lz6aZBZNXhfXGR5FoLjEsHS42gloszlrOCrQFRMMN 1F/WcMa//A9Qq+o1zXjV/tu/z49t/mVJxkCQrlzXCiLF/vw1zvFt3MYSyQgc6mj9tSFp Ne7eYSPgIkWBZFph9qijBQSU7sGC4BikYFkEWG7wAKwtlznXUZLp6TwXea2NXXa+SKj0 WOVkh/NAsSDz2Fi63WC0Ko2GCf8K5BgpPclvgg2ca5a+FOXtBReq2IgO8vhPLnZ4Ijjp S75+b5UqCjzHwy3lzLLS5i7ZVnnKUlBMsHhPZPhrtcqMoMWONTYDd1kCAGc9tylt0j3q tqAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=K8pdeJSq; 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 b3si413603ybi.247.2017.10.25.05.31.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:31:48 -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=K8pdeJSq; 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]:48087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KqZ-0007b9-Jq for patch@linaro.org; Wed, 25 Oct 2017 08:31:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq5-0007YP-C8 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq4-00084D-H7 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:17 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:46932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq4-00083z-BN for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:16 -0400 Received: by mail-wm0-x242.google.com with SMTP id m72so1587507wmc.1 for ; Wed, 25 Oct 2017 05:31:16 -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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=K8pdeJSqUc2Eyxqnlw3bxMchAYOo12PCoDmd04Ui/DtkQ9rCnQh5RtZe7KbUWMqQF8 TOfXRYZp1rLMdWwctMOFxWJhFnhfZQxUVNuJ3qe5VTUEaJDNcKy5QlS88F/+J9s+LVU6 s527ByGpJrhjKSgHo8OCQ8PVvLjaACuiq+bio= 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=J9WMN9zt50J+oUerKnsIhYym35E8jwe6efwCEMhjR7o=; b=Kw/ISXxur1WVEcrb1o6usMgGcrdPmyrd7eMPXL0iS9cR9au8i3TM5J5iA22rlN+VFJ 09+SsAPgD2N1ZQPqUGK0IpE31qzY6Qk4YABy5mEIVmEbvM9owrdr7EAwpB1GYPWa2XEu YwtTiqsIBMv6ATBf8Ky0jc4UNW7xKz+MDRIp9bZyTNM+6Y3mqpdKFFZdZrTTqoNn5jGL FDXLh6t6zlSOzCfZXeww8vwp/heUHt6o5WaMsaHyqO11p5bQkgXf3NmjogSTsczotuWU 7CCkdj7zFKE5/g393YaRp7PdrYN+QkWKs8zVNQqYZvFWsRjMy8mE6hxFGIAEO5IqxWyz Y2og== X-Gm-Message-State: AMCzsaVZVexhb2EGUrFW1I8ircXasTFiMHIlPH3WRWJyd8fc9XaKqV+m y1LJ3+AelQwCPGBRqiCFDGPW1W2jKyg= X-Received: by 10.28.17.7 with SMTP id 7mr1605034wmr.66.1508934675125; Wed, 25 Oct 2017 05:31:15 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:54 +0200 Message-Id: <20171025123056.3165-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 09/11] 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: peter.maydell@linaro.org, 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 8d9bd4901c..e52e776a60 100644 --- a/disas.c +++ b/disas.c @@ -448,6 +448,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 9b4353437a..41f46193a1 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 @@ -10537,6 +10538,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 Wed Oct 25 12:30:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117125 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1698357edm; Wed, 25 Oct 2017 05:39:43 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RNnmZP9yFHXUE8xfixJyaAO2ksPqzSNhdzwMtGDeI1NiXVTw4LBWNvGpr6fYRi9y5Fz+LK X-Received: by 10.37.200.134 with SMTP id y128mr1229000ybf.43.1508935183046; Wed, 25 Oct 2017 05:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508935183; cv=none; d=google.com; s=arc-20160816; b=raK1DcPK+QbhOfpMBciqSvW43zlI40ZANwZY9mOIc7HuAo1Pl8FHpI+aggp/0TK2I6 nK8WxSicRMi619bZuXGJTEei/vZbC+kQCO9kFLFdBxVTBuuJmz6IgT0psJ+W5XKwcsi8 V0AIluw+L6GzmXGzFKxpa8jQ28cRZ2rEjXZAhFXctK7kDz9wXJfTsl8McagTyWWgICja OtVKOGIm/kr5VdfDAG+Dud7jmmalpA0L0+5qBg912JgY9YuUgqiQa3AW+W5M5kdKvgJe If6I8HVxOokfkv9Gn9ny/cUgCYg9scsImLPsu18kpPxUdwb/8KQkNQCnapJ3bjQV6VMt QLVw== 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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=aOJWGi2Pwa8CB86BDvgFrq76U2vszJP+XqAlZxiiw1a8rEMpTjZcBr58/yxAxG1GJz USpsUeBZkAc1mIeVfcjqWgojmr63oGzaQDBlps87uNgdwgrXit7V3Ks++qWdzYw2572P lELlrq3KEG2uQDEjWAoOxcAYts1RrKgD44ngaxVsXPhQVaCzIs9m6tPeM3F8X3X9mjrm xPacCASR0lQSmVY9dgEfX20xGf+mqN6uRP8tK+UGWBDFUqtMwithd/+0fFuuTN4cQQ5A hc1LaVs4IzTO0TYJdXNyapPc9nV2yaYflNJudLcSUqCVWCZNrU65YAmHxY6XfRrtAhyV Ep1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZB03vdqv; 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 q123si431270ywe.122.2017.10.25.05.39.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:39:43 -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=ZB03vdqv; 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]:48117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KyE-0005Xw-Gy for patch@linaro.org; Wed, 25 Oct 2017 08:39:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KqB-0007eM-Ho for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq5-000857-M9 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:23 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:48214) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq5-00084T-Fa for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:17 -0400 Received: by mail-wm0-x243.google.com with SMTP id p75so1567064wmg.3 for ; Wed, 25 Oct 2017 05:31:17 -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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=ZB03vdqvURmLv46r1jFolv8s2py0xTbOMDPfzp2NkcHwTxry74D/fmPr4hX7bznCkU kHB3lp6lhm8qjuKQnF4hSPbhQIWRuAJox2vgRdKCAJZDuOGe/Nfxcu8fPT2wN+QMGmOK OR8GNoHkLVBAPR4wlroXyiG7AuLxP0EWeOmNs= 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=ZPp5mFCuMXXtXXcl4cuF8jT0S6sf5Zb1W02xzDFlJ/4=; b=X7t8mMWhd2RHSdbr3Kts6JYD6mOV2+p2d5Nrwz/n8/nifzK8tEJfOH+CX9cIuMljMI +AYU5H1v/tMOAQEA68LCKe0D059HDEt5JZjnKQ/ikb0jp8A5PxZSgTsPRFjze/HsOp2X 23LZPbeiGOU5WHQyHDtckU2TS/4q9pDAurcDVZDC5HljQRMjR/DxGm8GsiWP+MFOgkS1 FvxGHqf7AtzwbpDtEZ+OPiDcqqL8T0w/Ls41WqigC2wtedrJrcA8uZOi6WzOPFnxDzBQ E4nErrfXt4GvRcTK9eDSadJZFWdOZ6L/PlfZERzSG/pVAoNssLPZXlRWVynF0Yo3mKQB qvBA== X-Gm-Message-State: AMCzsaW/PwUZC8xNXCUZcfu9hEI/FNCPlgGZJ1f15tDrVlTcfRaOrFR1 UE71K60IqG/26pTsJxFjm3Ti+ztg7Iw= X-Received: by 10.28.73.9 with SMTP id w9mr1643852wma.3.1508934676250; Wed, 25 Oct 2017 05:31:16 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:55 +0200 Message-Id: <20171025123056.3165-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 10/11] 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: , Cc: peter.maydell@linaro.org 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 e52e776a60..92b389d25f 100644 --- a/disas.c +++ b/disas.c @@ -512,19 +512,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; } @@ -539,8 +531,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 Wed Oct 25 12:30:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117119 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1693586edm; Wed, 25 Oct 2017 05:34:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TrWSObwCu52dNLOOqezRwFB2x+1hdmvFEoiXmQYzJDmxvpIbLmwsrFRo39KNugPEs1hM6g X-Received: by 10.37.186.7 with SMTP id t7mr1190350ybg.495.1508934878016; Wed, 25 Oct 2017 05:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508934878; cv=none; d=google.com; s=arc-20160816; b=AZbvhXwac/HgTViM/yULmdMceQNaTkMe0DzVC9/aL11WE659GP84u/wYn93URVhRTK mdOLFkOIiFyHkkyWZRRZd0cXXrqQHgFthgNkWEMLTfrJrhspwNP3WZZKc3se7lJWLHxo R19ZE1I7ROgotTU25zSjwOEmN666kws/zG28JCKirvKs9yTJwW3zUx5ONuPmqPmVH7sk nzkQcorpLMGwGbJC9JzxU6+Ke/4+fqYQIwyFaHTUhEk/DfYp047Ix4omyXaczxdD72s5 k+U1COC0nOXYuquZa0zU6iqfiUfG2M/Sv5/wXCrxmUA94iVkG2nBChBZYDIQ7PqXbVg9 9DKA== 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=RminbL6lnTAsUkz7cTvMgitD71VzNFGUX7fWXcW8aws=; b=WCOwK/tZOTjvGDjcSa8ZaDW+Z/KxGSPViNNJ/hkThKsf0C6Tkgz/IrZV58wfukSww2 WNech5LkxNCSOy/He6aeBuKSvWaEwj5WTFPPODL12FB6HLrSe/MiZznyWpOAxs2GW9Sh ys2sB2/wi4TbkWScSJam+ma2F21UZ8IA4/4Ht4IhJAXaxZ80PYx7SsuSSsWtAEzFXRuJ 18aDzM1KI1bHh2h+sms1XihoB1Fb7yC2ZlA22teklCv3NC3B6JzXSDGhhVmtcQi08Lku O3113Z1FSF73pJLVE+v7b3MY2QGPFD3EAddMQCDHpuph/eiVhECfKJl6fZevGvL60kr0 BFrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=a43AGrLB; 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 t31si406874ybt.390.2017.10.25.05.34.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 05:34:38 -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=a43AGrLB; 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]:48094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KtJ-0001cc-EC for patch@linaro.org; Wed, 25 Oct 2017 08:34:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kq8-0007b8-7O for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Kq6-00086e-S0 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:20 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:51746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7Kq6-00085X-HY for qemu-devel@nongnu.org; Wed, 25 Oct 2017 08:31:18 -0400 Received: by mail-wm0-x241.google.com with SMTP id b9so1636048wmh.0 for ; Wed, 25 Oct 2017 05:31:18 -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=RminbL6lnTAsUkz7cTvMgitD71VzNFGUX7fWXcW8aws=; b=a43AGrLBhH33aon6NsKVjTRgfKlEksY+XmOOxVesYF3fHV54zfofITx8UwH5OMyXNL n67nf1ytOT/CD41UQLzSS5mTelTJ9iSFZpNDtaQEcBEvLsH2blyABK12UvXgIuaW2/nC WVhpE85TnV5HtSo/l527gy+FlV+qPjryTLY/o= 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=RminbL6lnTAsUkz7cTvMgitD71VzNFGUX7fWXcW8aws=; b=foF0vLtbt/k4cFNosWmpx2Ea43O0JEqDSmkx/i3mlGoupsutb7PJrASjN5flxJyVnf w5T8mJYo9tAdE070aGSpHIR811/tc+STe9u9Df1jk9AAB4LWUtHQWMTNGFGXPzOk5/Aj doaQ6g+UPuBeRx2QCEgH5ukwKw5CHKwXiXAxOmmROrd3JGYWlBRAllNXnCf1H0wXAk6O 9v3kXf9xpYC+Uo+iQQmvqN3R5nHPxOKmQrRwVQsK2ucA+DByDlI6+kczkf+/0JKqFhxd iaFAfJYXv81H4+lCTIqby9ZN3UKwPBSvKntiCTlZyaOw7O0fS5ABJ3YugVVl95dXl61X i5dg== X-Gm-Message-State: AMCzsaXzjH6cijKEWpL5lQUKUSAPUtSamwIWOVB6ajvOx5dOhaAxeQmw QMokToX1zfIb79rHbcSyOwSW1gDVYEo= X-Received: by 10.28.165.4 with SMTP id o4mr1723084wme.68.1508934677323; Wed, 25 Oct 2017 05:31:17 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.105]) by smtp.gmail.com with ESMTPSA id 61sm2263446wrg.58.2017.10.25.05.31.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 05:31:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 14:30:56 +0200 Message-Id: <20171025123056.3165-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025123056.3165-1-richard.henderson@linaro.org> References: <20171025123056.3165-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: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 11/11] 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not require the submodule, but use it if present. Allow the command-line to override system or git submodule either way. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- Makefile | 15 +++++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 60 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 68 insertions(+), 11 deletions(-) create mode 160000 capstone -- 2.13.6 diff --git a/Makefile b/Makefile index 9372742f86..33b4ce6e6e 100644 --- a/Makefile +++ b/Makefile @@ -383,6 +383,21 @@ subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests dtc/%: .git-submodule-status 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. +# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't; +# no need to annoy QEMU developers with such things. +CAP_CFLAGS = $(patsubst -W%,,$(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..22ead3e0bf --- /dev/null +++ b/capstone @@ -0,0 +1 @@ +Subproject commit 22ead3e0bfdb87516656453336160e0a37b066bf diff --git a/configure b/configure index d06ad64058..9ab10b0261 100755 --- a/configure +++ b/configure @@ -1299,6 +1299,10 @@ for opt do ;; --enable-capstone) capstone="yes" ;; + --enable-capstone=git) capstone="git" + ;; + --enable-capstone=system) capstone="system" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -4419,18 +4423,49 @@ fi ########################################## # capstone -if test "$capstone" != no; then - if $pkg_config capstone; then - capstone=yes +case "$capstone" in + "" | yes) + if $pkg_config capstone; then + capstone=system + elif test -e "${source_path}/.git" ; then + capstone=git + elif test -e "${source_path}/capstone/Makefile" ; then + capstone=internal + elif test -z "$capstone" ; then + capstone=no + else + feature_not_found "capstone" "Install capstone devel or git submodule" + fi + ;; + + system) + if ! $pkg_config capstone; then + feature_not_found "capstone" "Install capstone devel" + fi + ;; +esac + +case "$capstone" in + git | internal) + if test "$capstone" = git; then + git_submodules="${git_submodules} capstone" + fi + mkdir -p capstone + QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + LIBS="\$(BUILD_DIR)/capstone/libcapstone.a $LIBS" + ;; + + system) 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 + ;; + + no) + ;; + *) + error_exit "Unknown state for capstone: $capstone" + ;; +esac ########################################## # check if we have fdatasync @@ -6165,7 +6200,7 @@ fi if test "$ivshmem" = "yes" ; then echo "CONFIG_IVSHMEM=y" >> $config_host_mak fi -if test "$capstone" = "yes" ; then +if test "$capstone" != "no" ; then echo "CONFIG_CAPSTONE=y" >> $config_host_mak fi @@ -6650,6 +6685,9 @@ done # for target in $targets if [ "$dtc_internal" = "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi +if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then + echo "config-host.h: subdir-capstone" >> $config_host_mak +fi if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak