From nobody Sat May 4 08:20:30 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 1508448255059730.351708324684; Thu, 19 Oct 2017 14:24:15 -0700 (PDT) Received: from localhost ([::1]:51287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5IIV-0001MO-Cb for importer@patchew.org; Thu, 19 Oct 2017 17:24:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5IFh-0007gr-D0 for qemu-devel@nongnu.org; Thu, 19 Oct 2017 17:21:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5IFf-00089k-8a for qemu-devel@nongnu.org; Thu, 19 Oct 2017 17:21:17 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:56412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5IFf-00088q-04 for qemu-devel@nongnu.org; Thu, 19 Oct 2017 17:21:15 -0400 Received: by mail-pf0-x243.google.com with SMTP id b85so7807158pfj.13 for ; Thu, 19 Oct 2017 14:21:14 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id 2sm29839688pfn.185.2017.10.19.14.21.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 14:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/NEIM0B2s4cMjB5LDnTWIKVEaFdJ5/nFzSV3JZkIDck=; b=KZYrEtFfEgYmc0MAugqWPAEykep3bz2DdehLKqtBCIz7qq+JXs3HNY6TL/5vxFYmPS xk89lJPqWR0IR66IcQ9ExPgeE8KPQ7Jclgaz7mEp7aPyjDluayPrUV23s8fAzd0cYC+h K5R1nG9RTbonn9p45wiHM7TLFiYuP6vJOlhgQ= 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=/NEIM0B2s4cMjB5LDnTWIKVEaFdJ5/nFzSV3JZkIDck=; b=dOrCNWmE5q5AZiUwK70+JQcJjzHVMvJwKKTPy2T8Ab8hd3n+RiPD+SBF4Q0sTw8Uo9 Tlp5BMyNQ49PZq7Qi+InSNqCB/v0JGyiaKsj+53WMOJNgSjQde2icrN3I23iwCQnQIFq O2v2vEcDbB7sVBTY56P62GkcBXdT09o9DNIgu/3Nwei3e48X76CnZ0g5uvmx4/QLVuQS 2wKqhLD3DSASQD4X+4nQp+6N8uPZlsFrrNeIgyZff6bm2A3TH5A1q89RXWPpBcyzvFPS KiAjZFlYL4UYGTw0pXm/VkoqvKVKvZE5jbaXiVZ8BMQKON+JhP/1qCtERBFOD0MIyhRf ILxg== X-Gm-Message-State: AMCzsaW/7LaZ39A4iKN/bEyXve5536yDM8IXtk2wfG4cI8s3Mw64tXLu 3hzYd6d8Cm19QfA9CVKuQzCXLJjFv+M= X-Google-Smtp-Source: ABhQp+S/8ft7TZtQod/8msHFyYOHEan/dqjzmh6bIQVNBP69ovQae9ITmF2FGmK8HEVURYUGc3wMAg== X-Received: by 10.84.232.7 with SMTP id h7mr2446820plk.274.1508448073678; Thu, 19 Oct 2017 14:21:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 14:21:08 -0700 Message-Id: <20171019212109.11341-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171019212109.11341-1-richard.henderson@linaro.org> References: <20171019212109.11341-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH 1/2] 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. 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 9b0657cfa9..1f88c9e9d5 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 @@ -483,7 +477,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 1576a6d372..bc9d70df04 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -474,21 +474,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); @@ -528,10 +513,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 Sat May 4 08:20:30 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 150844816875247.02364222393271; Thu, 19 Oct 2017 14:22:48 -0700 (PDT) Received: from localhost ([::1]:51281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5IH4-0000OR-G2 for importer@patchew.org; Thu, 19 Oct 2017 17:22:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5IFh-0007gs-HP for qemu-devel@nongnu.org; Thu, 19 Oct 2017 17:21:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5IFg-0008B9-G5 for qemu-devel@nongnu.org; Thu, 19 Oct 2017 17:21:17 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:52671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5IFg-0008AB-8E for qemu-devel@nongnu.org; Thu, 19 Oct 2017 17:21:16 -0400 Received: by mail-pf0-x243.google.com with SMTP id e64so7813874pfk.9 for ; Thu, 19 Oct 2017 14:21:16 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id 2sm29839688pfn.185.2017.10.19.14.21.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 14:21: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; bh=mdIbGx7d50qzY0wkZYLStkuoS7WKJL5q13KavaEC0Fc=; b=HJD6vChUVSz9altjT9AM6Yx954xTPHDmLnpvvZzTFWUWkwEcyEHOguVYq13yzVvEEm Vdzx6IWfAOu696HMnwBaQNgw5J7zkWI1wtj7fw2u/LMCmx4qFA0Yy9ggHiAqcPI44KT/ 7gJuLjNrxXgoCT0D36U/OlQvokgUsF3J3RAoE= 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=mdIbGx7d50qzY0wkZYLStkuoS7WKJL5q13KavaEC0Fc=; b=SPEQDk/U9SFF246wIzBIfdUaHb5IASIowlSIenzrxFr5mIAogaX5cSDOxUMlPwT/tx XhML2FmOFiUwllpeD8hZLOC/U7e4ntCjfeWmSfSk2Ul+73DwjkIROcEyLZ2dOIldlyTL Q/wD0BEzByAMXTE0KLfz9a/TPSU07uGOt+v71pTVNVepa7dcvtqk2BL2zo6rDlJj3hqh FAEVXrFz2ad8PxG7I6fHaQvQQ2RGFYFFNZsWCo1cJSRRZSK5cgN9c5g0XOxxaYCITM8y dlu4QV1Mp/XBoCuOaC1+SBcfXOuLW171Vph3/EvbY9gIh2WQ4Y9MeZJ5ZtV42PrsFOHl qKtA== X-Gm-Message-State: AMCzsaXXlKFC7nSDQ/QbZS7KUi4QNpCgHNiR4TuY2EkFAUA8KvHqiS85 ZZcpQlfzIMuvemlQIY+dUSlcDfMs8lA= X-Google-Smtp-Source: ABhQp+TNB8YgzL6nlcamdN5JkEJPhLrIWWFahAltFEe+Yf5AelL8i4PHEzAqrjbQDm9GuDojy3ea5A== X-Received: by 10.159.255.66 with SMTP id u2mr2455853pls.25.1508448075086; Thu, 19 Oct 2017 14:21:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 14:21:09 -0700 Message-Id: <20171019212109.11341-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171019212109.11341-1-richard.henderson@linaro.org> References: <20171019212109.11341-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH 2/2] 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_6 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 bc9d70df04..a0ed11c9a5 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -478,6 +478,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 @@ -506,7 +507,9 @@ static void arm_disas_set_info(CPUState *cpu, disassemb= le_info *info) info->cap_arch =3D CS_ARCH_ARM; info->cap_mode =3D cap_mode; } - 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 @@ -514,9 +517,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