From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOjkQ-0000tg-6U for qemu-devel@nongnu.org; Wed, 25 Sep 2013 03:43:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOjkE-0001RX-T3 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 03:42:58 -0400 Received: from ozlabs.org ([2402:b800:7003:1:1::1]:42417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOjkE-0001RH-G5 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 03:42:46 -0400 Date: Wed, 25 Sep 2013 17:42:46 +1000 From: Anton Blanchard Message-ID: <20130925174246.0b740e73@kryten> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] target-ppc: Little Endian Correction to Load/Store Vector Element List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: agraf@suse.de Cc: tommusta@gmail.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org From: Tom Musta The Load Vector Element (lve*x) and Store Vector Element (stve*x) instructions not only byte-swap in Little Endian mode, they also invert the element that is accessed. For example, the RTL for lvehx contains this: eb <-- EA[60:63] if Big-Endian byte ordering then VRT[8*eb:8*eb+15] <-- MEM(EA,2) else VRT[112-(8*eb):127-(8*eb)] <-- MEM(EA,2) This patch adds the element inversion, as described in the last line of the RTL. Signed-off-by: Tom Musta Reviewed-by: Anton Blanchard --- Index: b/target-ppc/mem_helper.c =================================================================== --- a/target-ppc/mem_helper.c +++ b/target-ppc/mem_helper.c @@ -212,6 +212,7 @@ target_ulong helper_lscbx(CPUPPCState *e int index = (addr & 0xf) >> sh; \ \ if (msr_le) { \ + index = n_elems - index - 1; \ r->element[LO_IDX ? index : (adjust - index)] = \ swap(access(env, addr)); \ } else { \ @@ -236,6 +237,7 @@ LVE(lvewx, cpu_ldl_data, bswap32, u32) int index = (addr & 0xf) >> sh; \ \ if (msr_le) { \ + index = n_elems - index - 1; \ access(env, addr, swap(r->element[LO_IDX ? index : \ (adjust - index)])); \ } else { \