From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5rt-0002ux-Ro for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:00:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK5rq-0001uS-KL for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:00:49 -0500 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:45251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5rq-0001uA-BK for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:00:46 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Jan 2016 15:00:44 -0000 From: Greg Kurz Date: Fri, 15 Jan 2016 16:00:38 +0100 Message-ID: <20160115150038.17358.21849.stgit@bahia.huguette.org> In-Reply-To: <20160115150005.17358.43294.stgit@bahia.huguette.org> References: <20160115150005.17358.43294.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 5/7] target-ppc: gdbstub: fix altivec registers for little-endian guests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf , David Gibson Cc: Paolo Bonzini , qemu-ppc@nongnu.org, Anton Blanchard , qemu-devel@nongnu.org Altivec registers are 128-bit wide. They are stored in memory as two 64-bit values that must be byteswapped when the guest is little-endian. Let's reuse the ppc_maybe_bswap_register() helper for this. We also need to fix the ordering of the 64-bit elements according to the target endianness, for both system and user mode. Signed-off-by: Greg Kurz --- target-ppc/translate_init.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 18e9e561561f..80d53e4dcf5a 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -8754,9 +8754,9 @@ static void dump_ppc_insns (CPUPPCState *env) static bool avr_need_swap(CPUPPCState *env) { #ifdef HOST_WORDS_BIGENDIAN - return false; + return msr_le; #else - return true; + return !msr_le; #endif } @@ -8800,14 +8800,18 @@ static int gdb_get_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) stq_p(mem_buf, env->avr[n].u64[1]); stq_p(mem_buf+8, env->avr[n].u64[0]); } + ppc_maybe_bswap_register(env, mem_buf, 8); + ppc_maybe_bswap_register(env, mem_buf + 8, 8); return 16; } if (n == 32) { stl_p(mem_buf, env->vscr); + ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } if (n == 33) { stl_p(mem_buf, (uint32_t)env->spr[SPR_VRSAVE]); + ppc_maybe_bswap_register(env, mem_buf, 4); return 4; } return 0; @@ -8816,6 +8820,8 @@ static int gdb_get_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) { if (n < 32) { + ppc_maybe_bswap_register(env, mem_buf, 8); + ppc_maybe_bswap_register(env, mem_buf + 8, 8); if (!avr_need_swap(env)) { env->avr[n].u64[0] = ldq_p(mem_buf); env->avr[n].u64[1] = ldq_p(mem_buf+8); @@ -8826,10 +8832,12 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n) return 16; } if (n == 32) { + ppc_maybe_bswap_register(env, mem_buf, 4); env->vscr = ldl_p(mem_buf); return 4; } if (n == 33) { + ppc_maybe_bswap_register(env, mem_buf, 4); env->spr[SPR_VRSAVE] = (target_ulong)ldl_p(mem_buf); return 4; }