From: Philippe Bergheaud <felix@linux.vnet.ibm.com>
Subject: powerpc: Fix offset of FPRs in VSX registers in little endian builds
Git-commit: e156bd8ad76939a9bcd66d85cf06f8cde1fb8030
Patch-mainline: v3.13-rc1
References: bnc#856774 fate#315275, LTC#92305

Summary:     powerpc: add little-endian support
Description: Add little-endian support for POWER8.

Upstream-Description:

    powerpc: Fix offset of FPRs in VSX registers in little
     endian builds

    The FPRs overlap the high doublewords of the first 32 VSX registers.
    Fix TS_FPROFFSET and TS_VSRLOWOFFSET so we access the correct fields
    in little endian mode.

    If VSX is disabled the FPRs are only one doubleword in length so
    TS_FPROFFSET needs adjusting in little endian.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Signed-off-by: Philippe Bergheaud <felix@linux.vnet.ibm.com>
Acked-by: Torsten Duwe <duwe@suse.de>
---
 arch/powerpc/include/asm/processor.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Index: linux-3.12-SLE12/arch/powerpc/include/asm/processor.h
===================================================================
--- linux-3.12-SLE12.orig/arch/powerpc/include/asm/processor.h
+++ linux-3.12-SLE12/arch/powerpc/include/asm/processor.h
@@ -14,8 +14,18 @@
 
 #ifdef CONFIG_VSX
 #define TS_FPRWIDTH 2
+
+#ifdef __BIG_ENDIAN__
+#define TS_FPROFFSET 0
+#define TS_VSRLOWOFFSET 1
+#else
+#define TS_FPROFFSET 1
+#define TS_VSRLOWOFFSET 0
+#endif
+
 #else
 #define TS_FPRWIDTH 1
+#define TS_FPROFFSET 0
 #endif
 
 #ifdef CONFIG_PPC64
@@ -142,8 +152,6 @@ typedef struct {
 	unsigned long seg;
 } mm_segment_t;
 
-#define TS_FPROFFSET 0
-#define TS_VSRLOWOFFSET 1
 #define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET]
 #define TS_TRANS_FPR(i) transact_fp.fpr[i][TS_FPROFFSET]
 
