From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508935091986162.8275917826204; Wed, 25 Oct 2017 05:38:11 -0700 (PDT) Received: from localhost ([::1]:48107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kwa-0004AK-JH for importer@patchew.org; Wed, 25 Oct 2017 08:38:00 -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) 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) 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-Google-Smtp-Source: ABhQp+RzPMdxbag30vp80ugnV+OnhQUEOO6OmiCVgDsXmvG6J8CrOlwIajfj1EnhdPispsHFY/Cn6Q== X-Received: by 10.28.22.2 with SMTP id 2mr1651464wmw.47.1508934661618; Wed, 25 Oct 2017 05:31:01 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e 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(-) 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_ulo= ng code, cc->disas_set_info(cpu, &s.info); } =20 -#if defined(TARGET_I386) - if (flags =3D=3D 2) { - s.info.mach =3D bfd_mach_x86_64; - } else if (flags =3D=3D 1) { - s.info.mach =3D bfd_mach_i386_i8086; - } else { - s.info.mach =3D bfd_mach_i386_i386; - } - s.info.print_insn =3D print_insn_i386; -#elif defined(TARGET_PPC) +#if defined(TARGET_PPC) if ((flags >> 16) & 1) { s.info.endian =3D BFD_ENDIAN_LITTLE; } @@ -389,16 +380,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } =20 -#if defined(TARGET_I386) - if (flags =3D=3D 2) { - s.info.mach =3D bfd_mach_x86_64; - } else if (flags =3D=3D 1) { - s.info.mach =3D bfd_mach_i386_i8086; - } else { - s.info.mach =3D bfd_mach_i386_i386; - } - s.info.print_insn =3D 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 =3D 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, =20 if (format =3D=3D 'i') { int flags =3D 0; -#ifdef TARGET_I386 - CPUArchState *env =3D mon_get_cpu_env(); - if (wsize =3D=3D 2) { - flags =3D 1; - } else if (wsize =3D=3D 4) { - flags =3D 0; - } else { - /* as default we use the current CS size */ - flags =3D 0; - if (env) { -#ifdef TARGET_X86_64 - if ((env->efer & MSR_EFER_LMA) && - (env->segs[R_CS].flags & DESC_L_MASK)) - flags =3D 2; - else -#endif - if (!(env->segs[R_CS].flags & DESC_B_MASK)) - flags =3D 1; - } - } -#endif #ifdef TARGET_PPC CPUArchState *env =3D mon_get_cpu_env(); flags =3D 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)); } =20 +static void x86_disas_set_info(CPUState *cs, disassemble_info *info) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + + info->mach =3D (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 =3D print_insn_i386; +} + static Property x86_cpu_properties[] =3D { #ifdef CONFIG_USER_ONLY /* apic_id =3D 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 =3D x86_cpu_exec_enter; cc->cpu_exec_exit =3D x86_cpu_exec_exit; + cc->disas_set_info =3D x86_disas_set_info; =20 dc->user_creatable =3D 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 =3D container_of(dcbase, DisasContext, base); - int disas_flags =3D !dc->code32; =20 qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); -#ifdef TARGET_X86_64 - if (dc->code64) { - disas_flags =3D 2; - } -#endif - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, disas_flag= s); + log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, 0); } =20 static const TranslatorOps i386_tr_ops =3D { --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508934956966686.5238288220482; Wed, 25 Oct 2017 05:35:56 -0700 (PDT) Received: from localhost ([::1]:48102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KuS-0002U6-UI for importer@patchew.org; Wed, 25 Oct 2017 08:35:48 -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) 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) 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-Google-Smtp-Source: ABhQp+RcjUAYy0kMn412Dn2/GSsQqMmydDU6w+Z4vwoDkiI+75ZZ53it0bp/wOVltoD4V+1Qr9TUig== X-Received: by 10.28.125.206 with SMTP id y197mr1790352wmc.85.1508934663190; Wed, 25 Oct 2017 05:31:03 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e 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(-) 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_ulo= ng code, cc->disas_set_info(cpu, &s.info); } =20 -#if defined(TARGET_PPC) - if ((flags >> 16) & 1) { - s.info.endian =3D BFD_ENDIAN_LITTLE; - } - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it.= */ - s.info.mach =3D flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach =3D bfd_mach_ppc64; -#else - s.info.mach =3D bfd_mach_ppc; -#endif - } - s.info.disassembler_options =3D (char *)"any"; - s.info.print_insn =3D print_insn_ppc; -#endif if (s.info.print_insn =3D=3D NULL) { s.info.print_insn =3D print_insn_od_target; } @@ -380,22 +363,6 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } =20 -#if defined(TARGET_PPC) - if (flags & 0xFFFF) { - /* If we have a precise definition of the instruction set, use it.= */ - s.info.mach =3D flags & 0xFFFF; - } else { -#ifdef TARGET_PPC64 - s.info.mach =3D bfd_mach_ppc64; -#else - s.info.mach =3D bfd_mach_ppc; -#endif - } - if ((flags >> 16) & 1) { - s.info.endian =3D BFD_ENDIAN_LITTLE; - } - s.info.print_insn =3D 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, =20 if (format =3D=3D 'i') { int flags =3D 0; -#ifdef TARGET_PPC - CPUArchState *env =3D mon_get_cpu_env(); - flags =3D msr_le << 16; - flags |=3D 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 Tran= slationBlock *tb) #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(pc_start)) { - int flags; - flags =3D env->bfd_mach; - flags |=3D 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 } =20 +static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) +{ + PowerPCCPU *cpu =3D POWERPC_CPU(cs); + CPUPPCState *env =3D &cpu->env; + + if ((env->hflags >> MSR_LE) & 1) { + info->endian =3D BFD_ENDIAN_LITTLE; + } + info->mach =3D env->bfd_mach; + if (!env->bfd_mach) { +#ifdef TARGET_PPC64 + info->mach =3D bfd_mach_ppc64; +#else + info->mach =3D bfd_mach_ppc; +#endif + } + info->disassembler_options =3D (char *)"any"; + info->print_insn =3D print_insn_ppc; +} + static Property ppc_cpu_properties[] =3D { DEFINE_PROP_BOOL("pre-2.8-migration", PowerPCCPU, pre_2_8_migration, f= alse), DEFINE_PROP_BOOL("pre-2.10-migration", PowerPCCPU, pre_2_10_migration, @@ -10582,6 +10602,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) #ifndef CONFIG_USER_ONLY cc->virtio_is_big_endian =3D ppc_cpu_is_big_endian; #endif + cc->disas_set_info =3D ppc_disas_set_info; =20 dc->fw_name =3D "PowerPC,UNKNOWN"; } --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 150893480855215.924328771734167; Wed, 25 Oct 2017 05:33:28 -0700 (PDT) Received: from localhost ([::1]:48089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Ks0-0000PR-US for importer@patchew.org; Wed, 25 Oct 2017 08:33:17 -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) 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) 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-Google-Smtp-Source: ABhQp+Tk1T7e+dVtdUJ2hXpCEzH9t1yHmb3uxaIKJ0k3GjrlGZDlOrW/1RchG/rRfQMotHj+PCHu4A== X-Received: by 10.28.141.194 with SMTP id p185mr1718637wmd.149.1508934667147; Wed, 25 Oct 2017 05:31:07 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9 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(-) 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); =20 - /* 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 disassemb= le_info *); (INFO).buffer_vma =3D 0, \ (INFO).buffer_length =3D 0, \ (INFO).read_memory_func =3D buffer_read_memory, \ - (INFO).read_memory_inner_func =3D NULL, \ (INFO).memory_error_func =3D perror_memory, \ (INFO).print_address_func =3D generic_print_address, \ (INFO).print_insn =3D 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 =3D u.f; } =20 +static int arm_read_memory(bfd_vma memaddr, bfd_byte *b, int length, + struct disassemble_info *info) +{ + assert((info->flags & INSN_ARM_BE32) =3D=3D 0 || length =3D=3D 2 || le= ngth =3D=3D 4); + + if ((info->flags & INSN_ARM_BE32) !=3D 0 && length =3D=3D 2) { + memaddr ^=3D 2; + } + return info->read_memory_func(memaddr, b, length, info); +} + /* End of qemu specific additions. */ =20 struct opcode32 @@ -3810,7 +3821,7 @@ find_ifthen_state (bfd_vma pc, struct disassemble_inf= o *info, return; } addr -=3D 2; - status =3D info->read_memory_func (addr, (bfd_byte *)b, 2, info); + status =3D arm_read_memory (addr, (bfd_byte *)b, 2, info); if (status) return; =20 @@ -3882,7 +3893,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *= info) info->bytes_per_chunk =3D size; printer =3D print_insn_data; =20 - status =3D info->read_memory_func (pc, (bfd_byte *)b, size, info); + status =3D arm_read_memory (pc, (bfd_byte *)b, size, info); given =3D 0; if (little) for (i =3D size - 1; i >=3D 0; i--) @@ -3899,7 +3910,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *= info) info->bytes_per_chunk =3D 4; size =3D 4; =20 - status =3D info->read_memory_func (pc, (bfd_byte *)b, 4, info); + status =3D arm_read_memory (pc, (bfd_byte *)b, 4, info); if (little) given =3D (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 =3D 2; size =3D 2; =20 - status =3D info->read_memory_func (pc, (bfd_byte *)b, 2, info); + status =3D arm_read_memory (pc, (bfd_byte *)b, 2, info); if (little) given =3D (b[0]) | (b[1] << 8); else @@ -3929,7 +3940,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *= info) || (given & 0xF800) =3D=3D 0xF000 || (given & 0xF800) =3D=3D 0xE800) { - status =3D info->read_memory_func (pc + 2, (bfd_byte *)b, 2, info); + status =3D arm_read_memory (pc + 2, (bfd_byte *)b, 2, info); if (little) given =3D (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); } =20 -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) =3D=3D 0 || length =3D=3D 2 || le= ngth =3D=3D 4); - - if ((info->flags & INSN_ARM_BE32) !=3D 0 && length =3D=3D 2) { - assert(info->endian =3D=3D 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 =3D ARM_CPU(cpu); @@ -513,10 +498,6 @@ static void arm_disas_set_info(CPUState *cpu, disassem= ble_info *info) info->endian =3D BFD_ENDIAN_BIG; #endif } - if (info->read_memory_inner_func =3D=3D NULL) { - info->read_memory_inner_func =3D info->read_memory_func; - info->read_memory_func =3D arm_read_memory_func; - } info->flags &=3D ~INSN_ARM_BE32; if (arm_sctlr_b(env)) { info->flags |=3D INSN_ARM_BE32; --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15089349520601016.636814903305; Wed, 25 Oct 2017 05:35:52 -0700 (PDT) Received: from localhost ([::1]:48100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KuO-0002OO-9S for importer@patchew.org; Wed, 25 Oct 2017 08:35:44 -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) 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) 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-Google-Smtp-Source: ABhQp+SFzGF+VSSLyZJ5eqT+KcdBJ94IBZSde+LEfn0ttEdR5e2oUOtnh8nadjZp7dLgF+oATLYLgg== X-Received: by 10.223.143.54 with SMTP id p51mr2004890wrb.138.1508934668774; Wed, 25 Oct 2017 05:31:08 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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, disassemb= le_info *info) { ARMCPU *ac =3D ARM_CPU(cpu); CPUARMState *env =3D &ac->env; + bool sctlr_b; =20 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, disassemb= le_info *info) } else { info->print_insn =3D print_insn_arm; } - if (bswap_code(arm_sctlr_b(env))) { + + sctlr_b =3D arm_sctlr_b(env); + if (bswap_code(sctlr_b)) { #ifdef TARGET_WORDS_BIGENDIAN info->endian =3D BFD_ENDIAN_LITTLE; #else @@ -499,9 +502,11 @@ static void arm_disas_set_info(CPUState *cpu, disassem= ble_info *info) #endif } info->flags &=3D ~INSN_ARM_BE32; - if (arm_sctlr_b(env)) { +#ifndef CONFIG_USER_ONLY + if (sctlr_b) { info->flags |=3D INSN_ARM_BE32; } +#endif } =20 uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 150893521453750.49084709379849; Wed, 25 Oct 2017 05:40:14 -0700 (PDT) Received: from localhost ([::1]:48118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KyZ-0005f4-E8 for importer@patchew.org; Wed, 25 Oct 2017 08:40:03 -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) 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) 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-Google-Smtp-Source: ABhQp+TZIPlWpk25fe2SgiLzCMEjfUGgIe+fCe/QCkfFcaQMBh9d1gWylNymdUWJf3QAS4I2U7We8g== X-Received: by 10.28.69.210 with SMTP id l79mr1684402wmi.117.1508934670018; Wed, 25 Oct 2017 05:31:10 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Now that every target is using the disas_set_info hook, the flags argument is unused. Remove it. Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e 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(-) 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); =20 void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical, int flag= s); + target_ulong pc, int nb_insn, int is_physical); =20 /* 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); } =20 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, disassembl= e_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } =20 -/* 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 =3D CPU_GET_CLASS(cpu); target_ulong pc; @@ -335,10 +329,9 @@ monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr= , int length, return 0; } =20 -/* 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 flag= s) + target_ulong pc, int nb_insn, int is_physical) { CPUClass *cc =3D 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, } =20 if (format =3D=3D 'i') { - int flags =3D 0; - monitor_disas(mon, cs, addr, count, is_physical, flags); + monitor_disas(mon, cs, addr, count, is_physical); return; } =20 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 *c= pu) { 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); } =20 static const TranslatorOps alpha_tr_ops =3D { 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 DisasContext= Base *dcbase, DisasContext *dc =3D container_of(dcbase, DisasContext, base); =20 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); } =20 const TranslatorOps aarch64_translator_ops =3D { 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 =3D container_of(dcbase, DisasContext, base); =20 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); } =20 static const TranslatorOps arm_translator_ops =3D { 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 Trans= lationBlock *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=3D%d osize=3D%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 =3D container_of(dcbase, DisasContext, base); =20 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); } =20 static const TranslatorOps i386_tr_ops =3D { 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 Trans= lationBlock *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=3D%d osize=3D%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, TranslationB= lock *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 Trans= lationBlock *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=3D%d osize=3D%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, TranslationBlo= ck *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 Trans= lationBlock *tb) =20 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 Trans= lationBlock *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 Trans= lationBlock *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 Trans= lationBlock *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, TranslationB= lock * 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 Trans= lationBlock *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(); } --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508934813103854.1684234075033; Wed, 25 Oct 2017 05:33:33 -0700 (PDT) Received: from localhost ([::1]:48090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Ks5-0000Wd-E6 for importer@patchew.org; Wed, 25 Oct 2017 08:33:21 -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) 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) 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-Google-Smtp-Source: ABhQp+TMjHsMEXl88CJpuerLpL8RW8aYtOj1QwUz6GNK54oO+zzDu73AwES/4SghSa+sC3wACYYv+g== X-Received: by 10.223.189.148 with SMTP id l20mr2109248wrh.188.1508934671205; Wed, 25 Oct 2017 05:31:11 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 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=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 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; =20 + /* Options for Capstone disassembly. */ + int cap_arch; + int cap_mode; + } disassemble_info; =20 =0C 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 @@ =20 #include "cpu.h" #include "disas/disas.h" +#include "disas/capstone.h" =20 typedef struct CPUDebug { struct disassemble_info info; @@ -171,6 +172,192 @@ static int print_insn_od_target(bfd_vma pc, disassemb= le_info *info) return print_insn_objdump(pc, info, "OBJD-T"); } =20 +#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 =3D info->cap_mode; + cs_err err; + + cap_mode +=3D (info->endian =3D=3D BFD_ENDIAN_BIG ? CS_MODE_BIG_ENDIAN + : CS_MODE_LITTLE_ENDIAN); + + err =3D cs_open(info->cap_arch, cap_mode, handle); + if (err !=3D CS_ERR_OK) { + return err; + } + + /* ??? There probably ought to be a better place to put this. */ + if (info->cap_arch =3D=3D 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 =3D=3D NULL) { + cap_insn =3D cs_malloc(*handle); + if (cap_insn =3D=3D 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 s= ize) +{ + uint8_t cap_buf[1024]; + csh handle; + cs_insn *insn; + size_t csize =3D 0; + + if (cap_disas_start(info, &handle) !=3D CS_ERR_OK) { + return false; + } + insn =3D cap_insn; + + while (1) { + size_t tsize =3D MIN(sizeof(cap_buf) - csize, size); + const uint8_t *cbuf =3D cap_buf; + + target_read_memory(pc + csize, cap_buf + csize, tsize, info); + csize +=3D tsize; + size -=3D 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 !=3D 0) { + /* ... taking care to move any remaining fractional insn + to the beginning of the buffer. */ + if (csize !=3D 0) { + memmove(cap_buf, cbuf, csize); + } + continue; + } + + /* Since the target memory is consumed, we should not have + a remaining fractional insn. */ + if (csize !=3D 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) !=3D CS_ERR_OK) { + return false; + } + insn =3D cap_insn; + + cbuf =3D code; + pc =3D (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 !=3D 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 cou= nt) +{ + uint8_t cap_buf[32]; + csh handle; + cs_insn *insn; + size_t csize =3D 0; + + if (cap_disas_start(info, &handle) !=3D CS_ERR_OK) { + return false; + } + insn =3D 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 =3D QEMU_ALIGN_UP(pc + csize + 1, 1024); + size_t tsize =3D MIN(sizeof(cap_buf) - csize, epc - pc); + const uint8_t *cbuf =3D cap_buf; + + /* Make certain that we can make progress. */ + assert(tsize !=3D 0); + info->read_memory_func(pc, cap_buf + csize, tsize, info); + csize +=3D 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 <=3D 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_ulon= g code, s.info.buffer_vma =3D code; s.info.buffer_length =3D size; s.info.print_address_func =3D generic_print_address; + s.info.cap_arch =3D -1; + s.info.cap_mode =3D 0; =20 #ifdef TARGET_WORDS_BIGENDIAN s.info.endian =3D BFD_ENDIAN_BIG; @@ -198,6 +387,10 @@ void target_disas(FILE *out, CPUState *cpu, target_ulo= ng code, cc->disas_set_info(cpu, &s.info); } =20 + if (s.info.cap_arch >=3D 0 && cap_disas_target(&s.info, code, size)) { + return; + } + if (s.info.print_insn =3D=3D NULL) { s.info.print_insn =3D print_insn_od_target; } @@ -205,18 +398,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulo= ng code, for (pc =3D code; size > 0; pc +=3D count, size -=3D count) { fprintf(out, "0x" TARGET_FMT_lx ": ", pc); count =3D s.info.print_insn(pc, &s.info); -#if 0 - { - int i; - uint8_t b; - fprintf(out, " {"); - for(i =3D 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 =3D code; s.info.buffer_vma =3D (uintptr_t)code; s.info.buffer_length =3D size; + s.info.cap_arch =3D -1; + s.info.cap_mode =3D 0; =20 #ifdef HOST_WORDS_BIGENDIAN s.info.endian =3D BFD_ENDIAN_BIG; @@ -281,6 +464,11 @@ void disas(FILE *out, void *code, unsigned long size) #elif defined(__hppa__) print_insn =3D print_insn_hppa; #endif + + if (s.info.cap_arch >=3D 0 && cap_disas_host(&s.info, code, size)) { + return; + } + if (print_insn =3D=3D NULL) { print_insn =3D print_insn_od_host; } @@ -343,8 +531,9 @@ void monitor_disas(Monitor *mon, CPUState *cpu, monitor_disas_is_physical =3D is_physical; s.info.read_memory_func =3D monitor_read_memory; s.info.print_address_func =3D generic_print_address; - s.info.buffer_vma =3D pc; + s.info.cap_arch =3D -1; + s.info.cap_mode =3D 0; =20 #ifdef TARGET_WORDS_BIGENDIAN s.info.endian =3D BFD_ENDIAN_BIG; @@ -356,6 +545,10 @@ void monitor_disas(Monitor *mon, CPUState *cpu, cc->disas_set_info(cpu, &s.info); } =20 + if (s.info.cap_arch >=3D 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=3D"no" cpuid_h=3D"no" avx2_opt=3D"no" zlib=3D"yes" +capstone=3D"" lzo=3D"" snappy=3D"" bzip2=3D"" @@ -1294,6 +1295,10 @@ for opt do error_exit "vhost-user isn't available on win32" fi ;; + --disable-capstone) capstone=3D"no" + ;; + --enable-capstone) capstone=3D"yes" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1541,6 +1546,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: vxhs Veritas HyperScale vDisk backend support crypto-afalg Linux AF_ALG crypto backend driver vhost-user vhost-user support + capstone capstone disassembler support =20 NOTE: The object files are built at the place where configure is launched EOF @@ -4411,6 +4417,22 @@ EOF fi =20 ########################################## +# capstone + +if test "$capstone" !=3D no; then + if $pkg_config capstone; then + capstone=3Dyes + QEMU_CFLAGS=3D"$QEMU_CFLAGS $($pkg_config --cflags capstone)" + LIBS=3D"$($pkg_config --libs capstone) $LIBS" + else + if test "$capstone" =3D yes; then + feature_not_found capstone + fi + capstone=3Dno + fi +fi + +########################################## # check if we have fdatasync =20 fdatasync=3Dno @@ -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" =20 if test "$sdl_too_old" =3D "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6142,6 +6165,9 @@ fi if test "$ivshmem" =3D "yes" ; then echo "CONFIG_IVSHMEM=3Dy" >> $config_host_mak fi +if test "$capstone" =3D "yes" ; then + echo "CONFIG_CAPSTONE=3Dy" >> $config_host_mak +fi =20 # Hold two types of flag: # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name = on --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150893509129041.001667563059186; Wed, 25 Oct 2017 05:38:11 -0700 (PDT) Received: from localhost ([::1]:48108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kwf-0004FI-Ee for importer@patchew.org; Wed, 25 Oct 2017 08:38:05 -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) 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) 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-Google-Smtp-Source: ABhQp+T9hZ8pDm0euagDd9qOEwwVjjyliac+RFES3nyhuPWYQi+DLRHPOeM2QU3I2v0ec3I3tmAYIQ== X-Received: by 10.28.55.2 with SMTP id e2mr1774896wma.60.1508934672832; Wed, 25 Oct 2017 05:31:12 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/i386/cpu.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/disas.c b/disas.c index 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 =3D bfd_mach_i386_i386; print_insn =3D print_insn_i386; + s.info.cap_arch =3D CS_ARCH_X86; + s.info.cap_mode =3D CS_MODE_32; #elif defined(__x86_64__) s.info.mach =3D bfd_mach_x86_64; print_insn =3D print_insn_i386; + s.info.cap_arch =3D CS_ARCH_X86; + s.info.cap_mode =3D CS_MODE_64; #elif defined(_ARCH_PPC) s.info.disassembler_options =3D (char *)"any"; print_insn =3D 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 =20 +#include "disas/capstone.h" + =20 /* Cache topology CPUID constants: */ =20 @@ -4106,6 +4108,11 @@ static void x86_disas_set_info(CPUState *cs, disasse= mble_info *info) : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386 : bfd_mach_i386_i8086); info->print_insn =3D print_insn_i386; + + info->cap_arch =3D CS_ARCH_X86; + info->cap_mode =3D (env->hflags & HF_CS64_MASK ? CS_MODE_64 + : env->hflags & HF_CS32_MASK ? CS_MODE_32 + : CS_MODE_16); } =20 static Property x86_cpu_properties[] =3D { --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508935108412988.7767882944142; Wed, 25 Oct 2017 05:38:28 -0700 (PDT) Received: from localhost ([::1]:48109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Kwm-0004IV-EC for importer@patchew.org; Wed, 25 Oct 2017 08:38:12 -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) 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) 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-Google-Smtp-Source: ABhQp+TJlIMUwDraDtP/ile52DsEDdGIGZ+e+jhT4NwoNPJwYtyf8G1AMRq89imIrV6uwaC2zknU2Q== X-Received: by 10.28.22.2 with SMTP id 2mr1652072wmw.47.1508934673958; 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Tested-by: Alex Benn=C3=A9e Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- disas.c | 3 +++ target/arm/cpu.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) 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 =3D print_insn_ppc; #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn =3D print_insn_arm_a64; + s.info.cap_arch =3D CS_ARCH_ARM64; #elif defined(__alpha__) print_insn =3D print_insn_alpha; #elif defined(__sparc__) @@ -457,6 +458,8 @@ void disas(FILE *out, void *code, unsigned long size) s.info.mach =3D bfd_mach_sparc_v9b; #elif defined(__arm__) print_insn =3D print_insn_arm; + s.info.cap_arch =3D CS_ARCH_ARM; + /* TCG only generates code for arm mode. */ #elif defined(__MIPSEB__) print_insn =3D 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" =20 static void arm_cpu_set_pc(CPUState *cs, vaddr value) { @@ -487,10 +488,24 @@ static void arm_disas_set_info(CPUState *cpu, disasse= mble_info *info) #if defined(CONFIG_ARM_A64_DIS) info->print_insn =3D print_insn_arm_a64; #endif - } else if (env->thumb) { - info->print_insn =3D print_insn_thumb1; + info->cap_arch =3D CS_ARCH_ARM64; } else { - info->print_insn =3D print_insn_arm; + int cap_mode; + if (env->thumb) { + info->print_insn =3D print_insn_thumb1; + cap_mode =3D CS_MODE_THUMB; + } else { + info->print_insn =3D print_insn_arm; + cap_mode =3D CS_MODE_ARM; + } + if (arm_feature(env, ARM_FEATURE_V8)) { + cap_mode |=3D CS_MODE_V8; + } + if (arm_feature(env, ARM_FEATURE_M)) { + cap_mode |=3D CS_MODE_MCLASS; + } + info->cap_arch =3D CS_ARCH_ARM; + info->cap_mode =3D cap_mode; } =20 sctlr_b =3D arm_sctlr_b(env); --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 150893481304737.425719321396514; Wed, 25 Oct 2017 05:33:33 -0700 (PDT) Received: from localhost ([::1]:48091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Ks7-0000XF-0c for importer@patchew.org; Wed, 25 Oct 2017 08:33:23 -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) 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) 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-Google-Smtp-Source: ABhQp+SwG2alMuN2V9iruvDAZ3/l0LA6DW8KysyXgD2Sy3tOZn0TPOGRmjPlXyMCZgkgwZoe/Il39A== X-Received: by 10.28.17.7 with SMTP id 7mr1605034wmr.66.1508934675125; Wed, 25 Oct 2017 05:31:15 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_6 Z_629925259 SPT_0 Cc: qemu-ppc@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- disas.c | 4 ++++ target/ppc/translate_init.c | 6 ++++++ 2 files changed, 10 insertions(+) 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 =3D (char *)"any"; print_insn =3D print_insn_ppc; + s.info.cap_arch =3D CS_ARCH_PPC; +# ifdef _ARCH_PPC64 + s.info.cap_mode =3D CS_MODE_64; +# endif #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn =3D print_insn_arm_a64; s.info.cap_arch =3D 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" =20 //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -10537,6 +10538,11 @@ static void ppc_disas_set_info(CPUState *cs, disas= semble_info *info) } info->disassembler_options =3D (char *)"any"; info->print_insn =3D print_insn_ppc; + + info->cap_arch =3D CS_ARCH_PPC; +#ifdef TARGET_PPC64 + info->cap_mode =3D CS_MODE_64; +#endif } =20 static Property ppc_cpu_properties[] =3D { --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508935265630880.0569116015231; Wed, 25 Oct 2017 05:41:05 -0700 (PDT) Received: from localhost ([::1]:48125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KzO-0006Qh-MQ for importer@patchew.org; Wed, 25 Oct 2017 08:40:54 -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) 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) 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-Google-Smtp-Source: ABhQp+SKlCTXDNqQSK68aXtnx1xgAhzKSDoqFsik/yW+saB246gibdhXe81sJBts1HlUzC91fkyuAA== X-Received: by 10.28.73.9 with SMTP id w9mr1643852wma.3.1508934676250; Wed, 25 Oct 2017 05:31:16 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- disas.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) 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) =20 #include "monitor/monitor.h" =20 -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 =3D 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; } =20 @@ -539,8 +531,8 @@ void monitor_disas(Monitor *mon, CPUState *cpu, INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); =20 s.cpu =3D cpu; - monitor_disas_is_physical =3D is_physical; - s.info.read_memory_func =3D monitor_read_memory; + s.info.read_memory_func + =3D (is_physical ? physical_read_memory : target_read_memory); s.info.print_address_func =3D generic_print_address; s.info.buffer_vma =3D pc; s.info.cap_arch =3D -1; --=20 2.13.6 From nobody Tue May 7 23:08:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508934962447211.0128731894696; Wed, 25 Oct 2017 05:36:02 -0700 (PDT) Received: from localhost ([::1]:48103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7KuY-0002X4-Gb for importer@patchew.org; Wed, 25 Oct 2017 08:35:54 -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) 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) 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-Google-Smtp-Source: ABhQp+TkElPXx868tHt1Gv572+aVvgvNz7+dN3UQP0ZumxNMh6Kj3Lhltr9fd4OXZo6qg3ul6lYEgQ== X-Received: by 10.28.165.4 with SMTP id o4mr1723084wme.68.1508934677323; Wed, 25 Oct 2017 05:31:17 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- Makefile | 15 +++++++++++++++ .gitmodules | 3 +++ capstone | 1 + configure | 60 +++++++++++++++++++++++++++++++++++++++++++++++++--------= --- 4 files changed, 68 insertions(+), 11 deletions(-) create mode 160000 capstone 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 $@ =20 +# 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 =3D $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS)) +CAP_CFLAGS +=3D -DCAPSTONE_USE_SYS_DYN_MEM +CAP_CFLAGS +=3D -DCAPSTONE_HAS_ARM +CAP_CFLAGS +=3D -DCAPSTONE_HAS_ARM64 +CAP_CFLAGS +=3D -DCAPSTONE_HAS_POWERPC +CAP_CFLAGS +=3D -DCAPSTONE_HAS_X86 + +subdir-capstone: .git-submodule-status + $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=3Dno= BUILDDIR=3D"$(BUILD_DIR)/capstone" CC=3D"$(CC)" AR=3D"$(AR)" LD=3D"$(LD)" = CFLAGS=3D"$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/libcapst= one.a) + $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) =20 diff --git a/.gitmodules b/.gitmodules index 7c981a42b6..1500579638 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "ui/keycodemapdb"] path =3D ui/keycodemapdb url =3D git://git.qemu.org/keycodemapdb.git +[submodule "capstone"] + path =3D capstone + url =3D 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=3D"yes" ;; + --enable-capstone=3Dgit) capstone=3D"git" + ;; + --enable-capstone=3Dsystem) capstone=3D"system" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -4419,18 +4423,49 @@ fi ########################################## # capstone =20 -if test "$capstone" !=3D no; then - if $pkg_config capstone; then - capstone=3Dyes +case "$capstone" in + "" | yes) + if $pkg_config capstone; then + capstone=3Dsystem + elif test -e "${source_path}/.git" ; then + capstone=3Dgit + elif test -e "${source_path}/capstone/Makefile" ; then + capstone=3Dinternal + elif test -z "$capstone" ; then + capstone=3Dno + else + feature_not_found "capstone" "Install capstone devel or git submodul= e" + fi + ;; + + system) + if ! $pkg_config capstone; then + feature_not_found "capstone" "Install capstone devel" + fi + ;; +esac + +case "$capstone" in + git | internal) + if test "$capstone" =3D git; then + git_submodules=3D"${git_submodules} capstone" + fi + mkdir -p capstone + QEMU_CFLAGS=3D"$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include" + LIBS=3D"\$(BUILD_DIR)/capstone/libcapstone.a $LIBS" + ;; + + system) QEMU_CFLAGS=3D"$QEMU_CFLAGS $($pkg_config --cflags capstone)" LIBS=3D"$($pkg_config --libs capstone) $LIBS" - else - if test "$capstone" =3D yes; then - feature_not_found capstone - fi - capstone=3Dno - fi -fi + ;; + + no) + ;; + *) + error_exit "Unknown state for capstone: $capstone" + ;; +esac =20 ########################################## # check if we have fdatasync @@ -6165,7 +6200,7 @@ fi if test "$ivshmem" =3D "yes" ; then echo "CONFIG_IVSHMEM=3Dy" >> $config_host_mak fi -if test "$capstone" =3D "yes" ; then +if test "$capstone" !=3D "no" ; then echo "CONFIG_CAPSTONE=3Dy" >> $config_host_mak fi =20 @@ -6650,6 +6685,9 @@ done # for target in $targets if [ "$dtc_internal" =3D "yes" ]; then echo "config-host.h: subdir-dtc" >> $config_host_mak fi +if [ "$capstone" =3D "git" -o "$capstone" =3D "internal" ]; then + echo "config-host.h: subdir-capstone" >> $config_host_mak +fi =20 if test "$numa" =3D "yes"; then echo "CONFIG_NUMA=3Dy" >> $config_host_mak --=20 2.13.6