linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 39/63] powerpc: Little endian builds double word swap VSX state during context save/restore
Date: Wed,  7 Aug 2013 02:01:56 +1000	[thread overview]
Message-ID: <1375804940-22050-40-git-send-email-anton@samba.org> (raw)
In-Reply-To: <1375804940-22050-1-git-send-email-anton@samba.org>

The elements within VSX loads and stores are big endian ordered
regardless of endianness. Our VSX context save/restore code uses
lxvd2x and stxvd2x which is a 2x doubleword operation. This means
the two doublewords will be swapped and we have to perform another
swap to undo it.

We need to do this on save and restore.

Signed-off-by: Anton Blanchard <anton@samba.org>
---
 arch/powerpc/include/asm/ppc-opcode.h |  3 +++
 arch/powerpc/include/asm/ppc_asm.h    | 21 +++++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index eccfc16..247fa1d 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -134,6 +134,7 @@
 #define PPC_INST_TLBIVAX		0x7c000624
 #define PPC_INST_TLBSRX_DOT		0x7c0006a5
 #define PPC_INST_XXLOR			0xf0000510
+#define PPC_INST_XXSWAPD		0xf0000250
 #define PPC_INST_XVCPSGNDP		0xf0000780
 #define PPC_INST_TRECHKPT		0x7c0007dd
 #define PPC_INST_TRECLAIM		0x7c00075d
@@ -297,6 +298,8 @@
 					       VSX_XX1((s), a, b))
 #define XXLOR(t, a, b)		stringify_in_c(.long PPC_INST_XXLOR | \
 					       VSX_XX3((t), a, b))
+#define XXSWAPD(t, a)		stringify_in_c(.long PPC_INST_XXSWAPD | \
+					       VSX_XX3((t), a, a))
 #define XVCPSGNDP(t, a, b)	stringify_in_c(.long (PPC_INST_XVCPSGNDP | \
 					       VSX_XX3((t), (a), (b))))
 
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 4ebb4f8..bc606e4 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -180,9 +180,20 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 #define REST_32VRS_TRANSACT(n,b,base)	REST_16VRS_TRANSACT(n,b,base);	\
 					REST_16VRS_TRANSACT(n+16,b,base)
 
+#ifdef __BIG_ENDIAN__
+#define STXVD2X_ROT(n,b,base)		STXVD2X(n,b,base)
+#define LXVD2X_ROT(n,b,base)		LXVD2X(n,b,base)
+#else
+#define STXVD2X_ROT(n,b,base)		XXSWAPD(n,n);		\
+					STXVD2X(n,b,base);	\
+					XXSWAPD(n,n)
+
+#define LXVD2X_ROT(n,b,base)		LXVD2X(n,b,base);	\
+					XXSWAPD(n,n)
+#endif
 
 #define SAVE_VSR_TRANSACT(n,b,base)	li b,THREAD_TRANSACT_VSR0+(16*(n)); \
-					STXVD2X(n,R##base,R##b)
+					STXVD2X_ROT(n,R##base,R##b)
 #define SAVE_2VSRS_TRANSACT(n,b,base)	SAVE_VSR_TRANSACT(n,b,base);	\
 	                                SAVE_VSR_TRANSACT(n+1,b,base)
 #define SAVE_4VSRS_TRANSACT(n,b,base)	SAVE_2VSRS_TRANSACT(n,b,base);	\
@@ -195,7 +206,7 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 	                                SAVE_16VSRS_TRANSACT(n+16,b,base)
 
 #define REST_VSR_TRANSACT(n,b,base)	li b,THREAD_TRANSACT_VSR0+(16*(n)); \
-					LXVD2X(n,R##base,R##b)
+					LXVD2X_ROT(n,R##base,R##b)
 #define REST_2VSRS_TRANSACT(n,b,base)	REST_VSR_TRANSACT(n,b,base);    \
 	                                REST_VSR_TRANSACT(n+1,b,base)
 #define REST_4VSRS_TRANSACT(n,b,base)	REST_2VSRS_TRANSACT(n,b,base);	\
@@ -208,13 +219,15 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 	                                REST_16VSRS_TRANSACT(n+16,b,base)
 
 /* Save the lower 32 VSRs in the thread VSR region */
-#define SAVE_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n));  STXVD2X(n,R##base,R##b)
+#define SAVE_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n)); \
+				STXVD2X_ROT(n,R##base,R##b)
 #define SAVE_2VSRS(n,b,base)	SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base)
 #define SAVE_4VSRS(n,b,base)	SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base)
 #define SAVE_8VSRS(n,b,base)	SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base)
 #define SAVE_16VSRS(n,b,base)	SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base)
 #define SAVE_32VSRS(n,b,base)	SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base)
-#define REST_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n)); LXVD2X(n,R##base,R##b)
+#define REST_VSR(n,b,base)	li b,THREAD_VSR0+(16*(n)); \
+				LXVD2X_ROT(n,R##base,R##b)
 #define REST_2VSRS(n,b,base)	REST_VSR(n,b,base); REST_VSR(n+1,b,base)
 #define REST_4VSRS(n,b,base)	REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base)
 #define REST_8VSRS(n,b,base)	REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base)
-- 
1.8.1.2

  parent reply	other threads:[~2013-08-06 16:01 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 16:01 [PATCH 00/63] 64bit PowerPC little endian support Anton Blanchard
2013-08-06 16:01 ` [PATCH 01/63] powerpc: Align p_toc Anton Blanchard
2013-08-06 16:01 ` [PATCH 02/63] powerpc: handle unaligned ldbrx/stdbrx Anton Blanchard
2013-08-06 16:01 ` [PATCH 03/63] powerpc: Wrap MSR macros with parentheses Anton Blanchard
2013-08-06 16:01 ` [PATCH 04/63] powerpc: Remove SAVE_VSRU and REST_VSRU macros Anton Blanchard
2013-08-06 16:01 ` [PATCH 05/63] powerpc: Simplify logic in include/uapi/asm/elf.h Anton Blanchard
2013-08-06 16:01 ` [PATCH 06/63] powerpc/pseries: Simplify H_GET_TERM_CHAR Anton Blanchard
2013-08-06 16:01 ` [PATCH 07/63] powerpc: Fix a number of sparse warnings Anton Blanchard
2013-08-06 16:01 ` [PATCH 08/63] powerpc/pci: Don't use bitfield for force_32bit_msi Anton Blanchard
2013-08-06 16:01 ` [PATCH 09/63] powerpc: Stop using non-architected shared_proc field in lppaca Anton Blanchard
2013-08-06 16:01 ` [PATCH 10/63] powerpc: Make prom.c device tree accesses endian safe Anton Blanchard
2013-08-06 16:01 ` [PATCH 11/63] powerpc: More little endian fixes for prom.c Anton Blanchard
2013-08-06 16:01 ` [PATCH 12/63] powerpc: Make RTAS device tree accesses endian safe Anton Blanchard
2013-08-06 16:01 ` [PATCH 13/63] powerpc: Make cache info " Anton Blanchard
2013-08-06 16:01 ` [PATCH 14/63] powerpc: Make RTAS calls " Anton Blanchard
2013-08-06 16:01 ` [PATCH 15/63] powerpc: Make logical to real cpu mapping code " Anton Blanchard
2013-08-06 16:01 ` [PATCH 16/63] powerpc: More little endian fixes for setup-common.c Anton Blanchard
2013-08-06 16:01 ` [PATCH 17/63] powerpc: Add some endian annotations to time and xics code Anton Blanchard
2013-08-06 16:01 ` [PATCH 18/63] powerpc: Fix some endian issues in " Anton Blanchard
2013-08-06 16:01 ` [PATCH 19/63] powerpc: of_parse_dma_window should take a __be32 *dma_window Anton Blanchard
2013-08-06 16:01 ` [PATCH 20/63] powerpc: Make device tree accesses in cache info code endian safe Anton Blanchard
2013-08-06 16:01 ` [PATCH 21/63] powerpc: Make prom_init.c " Anton Blanchard
2013-08-06 16:01 ` [PATCH 22/63] powerpc: Make device tree accesses in HVC VIO console " Anton Blanchard
2013-08-06 16:01 ` [PATCH 23/63] powerpc: Make device tree accesses in VIO subsystem " Anton Blanchard
2013-08-06 16:01 ` [PATCH 24/63] powerpc: Make OF PCI device tree accesses " Anton Blanchard
2013-08-06 16:01 ` [PATCH 25/63] powerpc: Make PCI device node " Anton Blanchard
2013-08-06 16:01 ` [PATCH 26/63] powerpc: Little endian fixes for legacy_serial.c Anton Blanchard
2013-08-06 16:01 ` [PATCH 27/63] powerpc: Make NUMA device node code endian safe Anton Blanchard
2013-08-06 16:01 ` [PATCH 28/63] powerpc: Add endian annotations to lppaca, slb_shadow and dtl_entry Anton Blanchard
2013-08-06 16:01 ` [PATCH 29/63] powerpc: Fix little endian " Anton Blanchard
2013-08-06 16:01 ` [PATCH 30/63] powerpc: Emulate instructions in little endian mode Anton Blanchard
2013-08-06 16:01 ` [PATCH 31/63] powerpc: Little endian SMP IPI demux Anton Blanchard
2013-08-06 16:01 ` [PATCH 32/63] powerpc/pseries: Fix endian issues in H_GET_TERM_CHAR/H_PUT_TERM_CHAR Anton Blanchard
2013-08-06 16:01 ` [PATCH 33/63] powerpc: Fix little endian coredumps Anton Blanchard
2013-08-06 16:01 ` [PATCH 34/63] powerpc: Make rwlocks endian safe Anton Blanchard
2013-08-06 16:01 ` [PATCH 35/63] powerpc: Fix endian issues in VMX copy loops Anton Blanchard
2013-08-06 16:01 ` [PATCH 36/63] powerpc: Book 3S MMU little endian support Anton Blanchard
2013-08-07  4:20   ` Paul Mackerras
2013-08-09  6:08     ` Anton Blanchard
2013-08-06 16:01 ` [PATCH 37/63] powerpc: Fix offset of FPRs in VSX registers in little endian builds Anton Blanchard
2013-08-06 16:01 ` [PATCH 38/63] powerpc: PTRACE_PEEKUSR/PTRACE_POKEUSER of FPR " Anton Blanchard
2013-08-06 16:01 ` Anton Blanchard [this message]
2013-08-06 16:01 ` [PATCH 40/63] powerpc: Support endian agnostic MMIO Anton Blanchard
2013-08-06 16:01 ` [PATCH 41/63] powerpc: Add little endian support for word-at-a-time functions Anton Blanchard
2013-08-06 16:01 ` [PATCH 42/63] powerpc: Set MSR_LE bit on little endian builds Anton Blanchard
2013-08-06 16:02 ` [PATCH 43/63] powerpc: Reset MSR_LE on signal entry Anton Blanchard
2013-08-06 16:02 ` [PATCH 44/63] powerpc: Include the appropriate endianness header Anton Blanchard
2013-08-06 16:02 ` [PATCH 45/63] powerpc: endian safe trampoline Anton Blanchard
2013-08-06 16:02 ` [PATCH 46/63] powerpc: Add endian safe trampoline to pseries secondary thread entry Anton Blanchard
2013-08-06 16:02 ` [PATCH 47/63] pseries: Add H_SET_MODE to change exception endianness Anton Blanchard
2013-08-06 16:02 ` [PATCH 48/63] powerpc/kvm/book3s_hv: Add little endian guest support Anton Blanchard
2013-08-07  4:24   ` Paul Mackerras
2013-08-06 16:02 ` [PATCH 49/63] powerpc: Remove open coded byte swap macro in alignment handler Anton Blanchard
2013-08-06 16:02 ` [PATCH 50/63] powerpc: Remove hard coded FP offsets " Anton Blanchard
2013-08-06 16:02 ` [PATCH 51/63] powerpc: Alignment handler shouldn't access VSX registers with TS_FPR Anton Blanchard
2013-08-06 16:02 ` [PATCH 52/63] powerpc: Add little endian support to alignment handler Anton Blanchard
2013-08-06 16:02 ` [PATCH 53/63] powerpc: Handle VSX alignment faults in little endian mode Anton Blanchard
2013-08-06 16:02 ` [PATCH 54/63] ibmveth: Fix little endian issues Anton Blanchard
2013-08-06 16:02 ` [PATCH 55/63] ibmvscsi: " Anton Blanchard
2013-08-06 16:02 ` [PATCH 56/63] [SCSI] lpfc: Don't force CONFIG_GENERIC_CSUM on Anton Blanchard
2013-08-06 16:02 ` [PATCH 57/63] powerpc: Use generic checksum code in little endian Anton Blanchard
2013-08-06 16:02 ` [PATCH 58/63] powerpc: Use generic memcpy " Anton Blanchard
2013-08-06 16:02 ` [PATCH 59/63] powerpc: uname should return ppc64le/ppcle on little endian builds Anton Blanchard
2013-08-06 16:02 ` [PATCH 60/63] powerpc: Add ability to build little endian kernels Anton Blanchard
2013-08-06 16:02 ` [PATCH 61/63] powerpc: Don't set HAVE_EFFICIENT_UNALIGNED_ACCESS on little endian builds Anton Blanchard
2013-08-06 16:02 ` [PATCH 62/63] powerpc: Work around little endian gcc bug Anton Blanchard
2013-08-06 16:02 ` [PATCH 63/63] powerpc: Add pseries_le_defconfig Anton Blanchard
2013-08-06 23:31   ` Michael Neuling
2013-08-07  5:16     ` Michael Ellerman
2013-08-08 15:32       ` Aneesh Kumar K.V
2013-08-08  7:53     ` Anton Blanchard
2013-08-08 23:12       ` Michael Neuling
2013-08-09  3:23         ` Michael Ellerman
2013-08-08  8:33   ` Madhavan Srinivasan
2013-08-08 10:49     ` Michael Neuling
2013-08-09  3:21       ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1375804940-22050-40-git-send-email-anton@samba.org \
    --to=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).