From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKzXN-00061C-0r for qemu-devel@nongnu.org; Sun, 17 Jan 2016 21:27:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKzXJ-0006eO-Pf for qemu-devel@nongnu.org; Sun, 17 Jan 2016 21:27:20 -0500 Date: Mon, 18 Jan 2016 13:25:19 +1100 From: David Gibson Message-ID: <20160118022519.GH9301@voom.fritz.box> References: <20160115150005.17358.43294.stgit@bahia.huguette.org> <20160115150038.17358.21849.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IbA9xpzOQlG26JSn" Content-Disposition: inline In-Reply-To: <20160115150038.17358.21849.stgit@bahia.huguette.org> Subject: Re: [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: Greg Kurz Cc: qemu-devel@nongnu.org, Paolo Bonzini , qemu-ppc@nongnu.org, Alexander Graf , Anton Blanchard --IbA9xpzOQlG26JSn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 15, 2016 at 04:00:38PM +0100, Greg Kurz wrote: > 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. >=20 > We also need to fix the ordering of the 64-bit elements according to > the target endianness, for both system and user mode. >=20 > Signed-off-by: Greg Kurz What bothers me about this is that avr_need_swap() now depends on both host and guest endianness. However the VSCR and VRSAVE swap - like the swaps for GPRs and FPRs - uses ppc_maybe_bswap_register() which depends only on guest endianness. Why does altivec depend on the host endianness? > --- > target-ppc/translate_init.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) >=20 > 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 > } > =20 > @@ -8800,14 +8800,18 @@ static int gdb_get_avr_reg(CPUPPCState *env, uint= 8_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 =3D=3D 32) { > stl_p(mem_buf, env->vscr); > + ppc_maybe_bswap_register(env, mem_buf, 4); > return 4; > } > if (n =3D=3D 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] =3D ldq_p(mem_buf); > env->avr[n].u64[1] =3D ldq_p(mem_buf+8); > @@ -8826,10 +8832,12 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint= 8_t *mem_buf, int n) > return 16; > } > if (n =3D=3D 32) { > + ppc_maybe_bswap_register(env, mem_buf, 4); > env->vscr =3D ldl_p(mem_buf); > return 4; > } > if (n =3D=3D 33) { > + ppc_maybe_bswap_register(env, mem_buf, 4); > env->spr[SPR_VRSAVE] =3D (target_ulong)ldl_p(mem_buf); > return 4; > } >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --IbA9xpzOQlG26JSn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWnE0PAAoJEGw4ysog2bOSltoP+QEE4No1VpxVbdz5/+aIv5Ph LjkKCk/Zxseqo/jNK0eOQg4um8APTSpL4Ja584SlAYzXkLgzIV/Zu0lLOppDHRcP xvendA33DiwzQod1XQaVOl5ru3s5SewnHibxGe9JpZmxupxBjM0Dddn0/2pUr45V o95zlGoZ2Bh1zGAbVpUhhP0RdXbOvyPjOuS+tvmnkWxHEMbkH+9RUvVCUGf5ajih rKBxlTlkFiD1AYKQ7QESpH+O3coPFmfI0cS00mVAH5kAoL9Yx/x7K1iaaHQzPxV5 MHy6EEC3d9CqGU7WbKAmZ/gT1pYhybLd2y0UG0BqbnBkTrdhZgSKxEXaMtqhMIoP 64vQHdE2NPnIsOJSurSvi222JR9bRA3oxXA2sSrBAKEv6dfAUra4NtBbjfm5cPP8 FT0OFuLjmyfQRd+6MTqU9hE513ZxvHamXDPN/E9x7qQ8VYmQZXRi1mMlRxdsBcVz sRFh4Ex3B+mo4kO7wExp26fGnrcbKHIvysaW6NgHBNXl+pnTAiXqr3nT+L6kUtXQ CjAtk3ii8/QLEgsxvAdCGpdG9zLEvH/QRMVxxjbhTMZUXePixQfbys5XUNLDFfuH bZ5SEC6IF9bL4YsGH0AMVA1d5mJx0fUv3UBQzoN8J680fxzf7mzUXZmjDeW2djMf lpr5W6iq0o07aDG8Qf2U =NC6u -----END PGP SIGNATURE----- --IbA9xpzOQlG26JSn--