Blame SOURCES/glibc-ppc64le-21.patch

147e83
# commit be1e5d311342e08ae1f8013342df27b7ded2c156
147e83
# Author: Anton Blanchard <anton@au1.ibm.com>
147e83
# Date:   Sat Aug 17 18:34:40 2013 +0930
147e83
# 
147e83
#     PowerPC LE setjmp/longjmp
147e83
#     http://sourceware.org/ml/libc-alpha/2013-08/msg00089.html
147e83
#     
147e83
#     Little-endian fixes for setjmp/longjmp.  When writing these I noticed
147e83
#     the setjmp code corrupts the non volatile VMX registers when using an
147e83
#     unaligned buffer.  Anton fixed this, and also simplified it quite a
147e83
#     bit.
147e83
#     
147e83
#     The current code uses boilerplate for the case where we want to store
147e83
#     16 bytes to an unaligned address.  For that we have to do a
147e83
#     read/modify/write of two aligned 16 byte quantities.  In our case we
147e83
#     are storing a bunch of back to back data (consective VMX registers),
147e83
#     and only the start and end of the region need the read/modify/write.
147e83
#     
147e83
#         [BZ #15723]
147e83
#         * sysdeps/powerpc/jmpbuf-offsets.h: Comment fix.
147e83
#         * sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S: Correct
147e83
#         _dl_hwcap access for little-endian.
147e83
#         * sysdeps/powerpc/powerpc32/fpu/setjmp-common.S: Likewise.  Don't
147e83
#         destroy vmx regs when saving unaligned.
147e83
#         * sysdeps/powerpc/powerpc64/__longjmp-common.S: Correct CR load.
147e83
#         * sysdeps/powerpc/powerpc64/setjmp-common.S: Likewise CR save.  Don't
147e83
#         destroy vmx regs when saving unaligned.
147e83
# 
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/jmpbuf-offsets.h glibc-2.17-c758a686/sysdeps/powerpc/jmpbuf-offsets.h
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/jmpbuf-offsets.h	2014-05-27 22:55:23.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/jmpbuf-offsets.h	2014-05-27 22:55:27.000000000 -0500
147e83
@@ -21,12 +21,10 @@
147e83
 #define JB_LR     2  /* The address we will return to */
147e83
 #if __WORDSIZE == 64
147e83
 # define JB_GPRS   3  /* GPRs 14 through 31 are saved, 18*2 words total.  */
147e83
-# define JB_CR     21 /* Condition code registers with the VRSAVE at */
147e83
-                       /* offset 172 (low half of the double word.  */
147e83
+# define JB_CR     21 /* Shared dword with VRSAVE.  CR word at offset 172.  */
147e83
 # define JB_FPRS   22 /* FPRs 14 through 31 are saved, 18*2 words total.  */
147e83
 # define JB_SIZE   (64 * 8) /* As per PPC64-VMX ABI.  */
147e83
-# define JB_VRSAVE 21 /* VRSAVE shares a double word with the CR at offset */
147e83
-                       /* 168 (high half of the double word).  */
147e83
+# define JB_VRSAVE 21 /* Shared dword with CR.  VRSAVE word at offset 168.  */
147e83
 # define JB_VRS    40 /* VRs 20 through 31 are saved, 12*4 words total.  */
147e83
 #else
147e83
 # define JB_GPRS   3  /* GPRs 14 through 31 are saved, 18 in total.  */
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S	2014-05-27 22:55:23.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S	2014-05-27 22:55:27.000000000 -0500
147e83
@@ -46,16 +46,16 @@
147e83
 #   endif
147e83
 	mtlr    r6
147e83
 	cfi_same_value (lr)
147e83
-	lwz     r5,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET+4(r5)
147e83
+	lwz     r5,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET+LOWORD(r5)
147e83
 #  else
147e83
 	lwz     r5,_dl_hwcap@got(r5)
147e83
 	mtlr    r6
147e83
 	cfi_same_value (lr)
147e83
-	lwz     r5,4(r5)
147e83
+	lwz     r5,LOWORD(r5)
147e83
 #  endif
147e83
 # else
147e83
-	lis	r5,(_dl_hwcap+4)@ha
147e83
-	lwz     r5,(_dl_hwcap+4)@l(r5)
147e83
+	lis	r5,(_dl_hwcap+LOWORD)@ha
147e83
+	lwz     r5,(_dl_hwcap+LOWORD)@l(r5)
147e83
 # endif
147e83
 	andis.	r5,r5,(PPC_FEATURE_HAS_ALTIVEC >> 16)
147e83
 	beq	L(no_vmx)
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S	2014-05-27 22:55:23.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/fpu/setjmp-common.S	2014-05-27 22:55:27.000000000 -0500
147e83
@@ -97,14 +97,14 @@
147e83
 #   else
147e83
 	lwz     r5,_rtld_global_ro@got(r5)
147e83
 #   endif
147e83
-	lwz     r5,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET+4(r5)
147e83
+	lwz     r5,RTLD_GLOBAL_RO_DL_HWCAP_OFFSET+LOWORD(r5)
147e83
 #  else
147e83
 	lwz     r5,_dl_hwcap@got(r5)
147e83
-	lwz     r5,4(r5)
147e83
+	lwz     r5,LOWORD(r5)
147e83
 #  endif
147e83
 # else
147e83
-	lis	r6,(_dl_hwcap+4)@ha
147e83
-	lwz     r5,(_dl_hwcap+4)@l(r6)
147e83
+	lis	r6,(_dl_hwcap+LOWORD)@ha
147e83
+	lwz     r5,(_dl_hwcap+LOWORD)@l(r6)
147e83
 # endif
147e83
 	andis.	r5,r5,(PPC_FEATURE_HAS_ALTIVEC >> 16)
147e83
 	beq	L(no_vmx)
147e83
@@ -114,44 +114,43 @@
147e83
 	stw	r0,((JB_VRSAVE)*4)(3)
147e83
 	addi	r6,r5,16
147e83
 	beq+	L(aligned_save_vmx)
147e83
+
147e83
 	lvsr	v0,0,r5
147e83
-	vspltisb v1,-1         /* set v1 to all 1's */
147e83
-	vspltisb v2,0          /* set v2 to all 0's */
147e83
-	vperm   v3,v2,v1,v0   /* v3 contains shift mask with num all 1 bytes on left = misalignment  */
147e83
-
147e83
-
147e83
-	/* Special case for v20 we need to preserve what is in save area below v20 before obliterating it */
147e83
-	lvx     v5,0,r5
147e83
-	vperm   v20,v20,v20,v0
147e83
-	vsel    v5,v5,v20,v3
147e83
-	vsel    v20,v20,v2,v3
147e83
-	stvx    v5,0,r5
147e83
-
147e83
-#define save_2vmx_partial(savevr,prev_savevr,hivr,shiftvr,maskvr,savegpr,addgpr) \
147e83
-	addi    addgpr,addgpr,32; \
147e83
-	vperm   savevr,savevr,savevr,shiftvr; \
147e83
-	vsel    hivr,prev_savevr,savevr,maskvr; \
147e83
-	stvx    hivr,0,savegpr;
147e83
-
147e83
-	save_2vmx_partial(v21,v20,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v22,v21,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v23,v22,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v24,v23,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v25,v24,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v26,v25,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v27,v26,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v28,v27,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v29,v28,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v30,v29,v5,v0,v3,r5,r6)
147e83
-
147e83
-	/* Special case for r31 we need to preserve what is in save area above v31 before obliterating it */
147e83
-	addi    r5,r5,32
147e83
-	vperm   v31,v31,v31,v0
147e83
-	lvx     v4,0,r5
147e83
-	vsel    v5,v30,v31,v3
147e83
-	stvx    v5,0,r6
147e83
-	vsel    v4,v31,v4,v3
147e83
-	stvx    v4,0,r5
147e83
+	lvsl	v1,0,r5
147e83
+	addi	r6,r5,-16
147e83
+
147e83
+# define save_misaligned_vmx(savevr,prevvr,shiftvr,tmpvr,savegpr,addgpr) \
147e83
+	addi	addgpr,addgpr,32;					 \
147e83
+	vperm	tmpvr,prevvr,savevr,shiftvr;				 \
147e83
+	stvx	tmpvr,0,savegpr
147e83
+
147e83
+	/*
147e83
+	 * We have to be careful not to corrupt the data below v20 and
147e83
+	 * above v31. To keep things simple we just rotate both ends in
147e83
+	 * the opposite direction to our main permute so we can use
147e83
+	 * the common macro.
147e83
+	 */
147e83
+
147e83
+	/* load and rotate data below v20 */
147e83
+	lvx	v2,0,r5
147e83
+	vperm	v2,v2,v2,v1
147e83
+	save_misaligned_vmx(v20,v2,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v21,v20,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v22,v21,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v23,v22,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v24,v23,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v25,v24,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v26,v25,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v27,v26,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v28,v27,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v29,v28,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v30,v29,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v31,v30,v0,v3,r6,r5)
147e83
+	/* load and rotate data above v31 */
147e83
+	lvx	v2,0,r6
147e83
+	vperm	v2,v2,v2,v1
147e83
+	save_misaligned_vmx(v2,v31,v0,v3,r5,r6)
147e83
+
147e83
 	b	L(no_vmx)
147e83
 
147e83
 L(aligned_save_vmx):
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S	2014-05-27 22:55:23.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/__longjmp-common.S	2014-05-27 22:55:27.000000000 -0500
147e83
@@ -60,7 +60,7 @@
147e83
 	beq	L(no_vmx)
147e83
 	la	r5,((JB_VRS)*8)(3)
147e83
 	andi.	r6,r5,0xf
147e83
-	lwz	r0,((JB_VRSAVE)*8)(3)
147e83
+	lwz	r0,((JB_VRSAVE)*8)(3)	/* 32-bit VRSAVE.  */
147e83
 	mtspr	VRSAVE,r0
147e83
 	beq+	L(aligned_restore_vmx)
147e83
 	addi    r6,r5,16
147e83
@@ -156,7 +156,7 @@
147e83
 	lfd fp21,((JB_FPRS+7)*8)(r3)
147e83
 	ld r22,((JB_GPRS+8)*8)(r3)
147e83
 	lfd fp22,((JB_FPRS+8)*8)(r3)
147e83
-	ld r0,(JB_CR*8)(r3)
147e83
+	lwz r0,((JB_CR*8)+4)(r3)	/* 32-bit CR.  */
147e83
 	ld r23,((JB_GPRS+9)*8)(r3)
147e83
 	lfd fp23,((JB_FPRS+9)*8)(r3)
147e83
 	ld r24,((JB_GPRS+10)*8)(r3)
147e83
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S	2014-05-27 22:55:23.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/setjmp-common.S	2014-05-27 22:55:27.000000000 -0500
147e83
@@ -98,7 +98,7 @@
147e83
 	mfcr r0
147e83
 	std  r16,((JB_GPRS+2)*8)(3)
147e83
 	stfd fp16,((JB_FPRS+2)*8)(3)
147e83
-	std  r0,(JB_CR*8)(3)
147e83
+	stw  r0,((JB_CR*8)+4)(3)	/* 32-bit CR.  */
147e83
 	std  r17,((JB_GPRS+3)*8)(3)
147e83
 	stfd fp17,((JB_FPRS+3)*8)(3)
147e83
 	std  r18,((JB_GPRS+4)*8)(3)
147e83
@@ -142,50 +142,46 @@
147e83
 	la	r5,((JB_VRS)*8)(3)
147e83
 	andi.	r6,r5,0xf
147e83
 	mfspr	r0,VRSAVE
147e83
-	stw	r0,((JB_VRSAVE)*8)(3)
147e83
+	stw	r0,((JB_VRSAVE)*8)(3)	/* 32-bit VRSAVE.  */
147e83
 	addi	r6,r5,16
147e83
 	beq+	L(aligned_save_vmx)
147e83
+
147e83
 	lvsr	v0,0,r5
147e83
-	vspltisb v1,-1         /* set v1 to all 1's */
147e83
-	vspltisb v2,0          /* set v2 to all 0's */
147e83
-	vperm   v3,v2,v1,v0   /* v3 contains shift mask with num all 1 bytes
147e83
-				 on left = misalignment  */
147e83
-
147e83
-
147e83
-	/* Special case for v20 we need to preserve what is in save area
147e83
-	   below v20 before obliterating it */
147e83
-	lvx     v5,0,r5
147e83
-	vperm   v20,v20,v20,v0
147e83
-	vsel    v5,v5,v20,v3
147e83
-	vsel    v20,v20,v2,v3
147e83
-	stvx    v5,0,r5
147e83
-
147e83
-# define save_2vmx_partial(savevr,prev_savevr,hivr,shiftvr,maskvr,savegpr,addgpr) \
147e83
-	addi    addgpr,addgpr,32; \
147e83
-	vperm   savevr,savevr,savevr,shiftvr; \
147e83
-	vsel    hivr,prev_savevr,savevr,maskvr; \
147e83
-	stvx    hivr,0,savegpr;
147e83
-
147e83
-	save_2vmx_partial(v21,v20,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v22,v21,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v23,v22,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v24,v23,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v25,v24,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v26,v25,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v27,v26,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v28,v27,v5,v0,v3,r5,r6)
147e83
-	save_2vmx_partial(v29,v28,v5,v0,v3,r6,r5)
147e83
-	save_2vmx_partial(v30,v29,v5,v0,v3,r5,r6)
147e83
-
147e83
-	/* Special case for r31 we need to preserve what is in save area
147e83
-	   above v31 before obliterating it */
147e83
-	addi    r5,r5,32
147e83
-	vperm   v31,v31,v31,v0
147e83
-	lvx     v4,0,r5
147e83
-	vsel    v5,v30,v31,v3
147e83
-	stvx    v5,0,r6
147e83
-	vsel    v4,v31,v4,v3
147e83
-	stvx    v4,0,r5
147e83
+	lvsl	v1,0,r5
147e83
+	addi	r6,r5,-16
147e83
+
147e83
+# define save_misaligned_vmx(savevr,prevvr,shiftvr,tmpvr,savegpr,addgpr) \
147e83
+	addi	addgpr,addgpr,32;					 \
147e83
+	vperm	tmpvr,prevvr,savevr,shiftvr;				 \
147e83
+	stvx	tmpvr,0,savegpr
147e83
+
147e83
+	/*
147e83
+	 * We have to be careful not to corrupt the data below v20 and
147e83
+	 * above v31. To keep things simple we just rotate both ends in
147e83
+	 * the opposite direction to our main permute so we can use
147e83
+	 * the common macro.
147e83
+	 */
147e83
+
147e83
+	/* load and rotate data below v20 */
147e83
+	lvx	v2,0,r5
147e83
+	vperm	v2,v2,v2,v1
147e83
+	save_misaligned_vmx(v20,v2,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v21,v20,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v22,v21,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v23,v22,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v24,v23,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v25,v24,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v26,v25,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v27,v26,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v28,v27,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v29,v28,v0,v3,r6,r5)
147e83
+	save_misaligned_vmx(v30,v29,v0,v3,r5,r6)
147e83
+	save_misaligned_vmx(v31,v30,v0,v3,r6,r5)
147e83
+	/* load and rotate data above v31 */
147e83
+	lvx	v2,0,r6
147e83
+	vperm	v2,v2,v2,v1
147e83
+	save_misaligned_vmx(v2,v31,v0,v3,r5,r6)
147e83
+
147e83
 	b	L(no_vmx)
147e83
 
147e83
 L(aligned_save_vmx):