ce426f
commit 5cdd1989d1d2f135d02e66250f37ba8e767f9772
ce426f
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
ce426f
Date:   Thu Mar 31 17:37:16 2016 +0200
ce426f
ce426f
    S390: Extend structs La_s390_regs / La_s390_retval with vector-registers.
ce426f
    
ce426f
    Starting with z13, vector registers can also occur as argument registers.
ce426f
    Thus the passed input/output register structs for
ce426f
    la_s390_[32|64]_gnu_plt[enter|exit] functions should reflect those new
ce426f
    registers. This patch extends these structs La_s390_regs and La_s390_retval
ce426f
    and adjusts _dl_runtime_profile() to handle those fields in case of
ce426f
    running on a z13 machine.
ce426f
    
ce426f
    ChangeLog:
ce426f
    
ce426f
    	* sysdeps/s390/bits/link.h: (La_s390_vr) New typedef.
ce426f
    	(La_s390_32_regs): Append vector register lr_v24-lr_v31.
ce426f
    	(La_s390_64_regs): Likewise.
ce426f
    	(La_s390_32_retval): Append vector register lrv_v24.
ce426f
    	(La_s390_64_retval): Likeweise.
ce426f
    	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
ce426f
    	Handle extended structs La_s390_32_regs and La_s390_32_retval.
ce426f
    	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
ce426f
    	Handle extended structs La_s390_64_regs and La_s390_64_retval.
ce426f
ce426f
diff --git a/sysdeps/s390/bits/link.h b/sysdeps/s390/bits/link.h
ce426f
index 2ef7f44..e27ed67 100644
ce426f
--- a/sysdeps/s390/bits/link.h
ce426f
+++ b/sysdeps/s390/bits/link.h
ce426f
@@ -19,6 +19,9 @@
ce426f
 # error "Never include <bits/link.h> directly; use <link.h> instead."
ce426f
 #endif
ce426f
 
ce426f
+#if defined HAVE_S390_VX_ASM_SUPPORT
ce426f
+typedef char La_s390_vr[16];
ce426f
+#endif
ce426f
 
ce426f
 #if __ELF_NATIVE_CLASS == 32
ce426f
 
ce426f
@@ -32,6 +35,16 @@ typedef struct La_s390_32_regs
ce426f
   uint32_t lr_r6;
ce426f
   double lr_fp0;
ce426f
   double lr_fp2;
ce426f
+# if defined HAVE_S390_VX_ASM_SUPPORT
ce426f
+  La_s390_vr lr_v24;
ce426f
+  La_s390_vr lr_v25;
ce426f
+  La_s390_vr lr_v26;
ce426f
+  La_s390_vr lr_v27;
ce426f
+  La_s390_vr lr_v28;
ce426f
+  La_s390_vr lr_v29;
ce426f
+  La_s390_vr lr_v30;
ce426f
+  La_s390_vr lr_v31;
ce426f
+# endif
ce426f
 } La_s390_32_regs;
ce426f
 
ce426f
 /* Return values for calls from PLT on s390-32.  */
ce426f
@@ -40,6 +53,9 @@ typedef struct La_s390_32_retval
ce426f
   uint32_t lrv_r2;
ce426f
   uint32_t lrv_r3;
ce426f
   double lrv_fp0;
ce426f
+# if defined HAVE_S390_VX_ASM_SUPPORT
ce426f
+  La_s390_vr lrv_v24;
ce426f
+# endif
ce426f
 } La_s390_32_retval;
ce426f
 
ce426f
 
ce426f
@@ -77,6 +93,16 @@ typedef struct La_s390_64_regs
ce426f
   double lr_fp2;
ce426f
   double lr_fp4;
ce426f
   double lr_fp6;
ce426f
+# if defined HAVE_S390_VX_ASM_SUPPORT
ce426f
+  La_s390_vr lr_v24;
ce426f
+  La_s390_vr lr_v25;
ce426f
+  La_s390_vr lr_v26;
ce426f
+  La_s390_vr lr_v27;
ce426f
+  La_s390_vr lr_v28;
ce426f
+  La_s390_vr lr_v29;
ce426f
+  La_s390_vr lr_v30;
ce426f
+  La_s390_vr lr_v31;
ce426f
+# endif
ce426f
 } La_s390_64_regs;
ce426f
 
ce426f
 /* Return values for calls from PLT on s390-64.  */
ce426f
@@ -84,6 +110,9 @@ typedef struct La_s390_64_retval
ce426f
 {
ce426f
   uint64_t lrv_r2;
ce426f
   double lrv_fp0;
ce426f
+# if defined HAVE_S390_VX_ASM_SUPPORT
ce426f
+  La_s390_vr lrv_v24;
ce426f
+# endif
ce426f
 } La_s390_64_retval;
ce426f
 
ce426f
 
ce426f
diff --git a/sysdeps/s390/s390-32/dl-trampoline.h b/sysdeps/s390/s390-32/dl-trampoline.h
ce426f
index a152a7b..bb74d27 100644
ce426f
--- a/sysdeps/s390/s390-32/dl-trampoline.h
ce426f
+++ b/sysdeps/s390/s390-32/dl-trampoline.h
ce426f
@@ -112,28 +112,31 @@ _dl_runtime_resolve:
ce426f
 	cfi_startproc
ce426f
 	.align 16
ce426f
 _dl_runtime_profile:
ce426f
-	stm    %r2,%r6,32(%r15)		# save registers
ce426f
-	cfi_offset (r2, -64)		# + r6 needed as arg for
ce426f
-	cfi_offset (r3, -60)		#  _dl_profile_fixup
ce426f
-	cfi_offset (r4, -56)
ce426f
-	cfi_offset (r5, -52)
ce426f
-	cfi_offset (r6, -48)
ce426f
-	std    %f0,56(%r15)
ce426f
-	cfi_offset (f0, -40)
ce426f
-	std    %f2,64(%r15)
ce426f
-	cfi_offset (f2, -32)
ce426f
 	st     %r12,12(%r15)		# r12 is used as backup of r15
ce426f
 	cfi_offset (r12, -84)
ce426f
 	st     %r14,16(%r15)
ce426f
 	cfi_offset (r14, -80)
ce426f
 	lr     %r12,%r15		# backup stack pointer
ce426f
 	cfi_def_cfa_register (12)
ce426f
+	ahi    %r15,-264		# create stack frame:
ce426f
+					# 96 + sizeof(La_s390_32_regs)
ce426f
+	st     %r12,0(%r15)		# save backchain
ce426f
+
ce426f
+	stm    %r2,%r6,96(%r15)		# save registers
ce426f
+	cfi_offset (r2, -264)		# + r6 needed as arg for
ce426f
+	cfi_offset (r3, -260)		#  _dl_profile_fixup
ce426f
+	cfi_offset (r4, -256)
ce426f
+	cfi_offset (r5, -252)
ce426f
+	cfi_offset (r6, -248)
ce426f
+	std    %f0,120(%r15)
ce426f
+	cfi_offset (f0, -240)
ce426f
+	std    %f2,128(%r15)
ce426f
+	cfi_offset (f2, -232)
ce426f
 #ifdef RESTORE_VRS
ce426f
-	ahi    %r15,-224		# create stack frame
ce426f
 	.machine push
ce426f
 	.machine "z13"
ce426f
 	.machinemode "zarch_nohighgprs"
ce426f
-	vstm   %v24,%v31,96(%r15)	# store call-clobbered vr arguments
ce426f
+	vstm   %v24,%v31,136(%r15)	# store call-clobbered vr arguments
ce426f
 	cfi_offset (v24, -224)
ce426f
 	cfi_offset (v25, -208)
ce426f
 	cfi_offset (v26, -192)
ce426f
@@ -143,31 +146,31 @@ _dl_runtime_profile:
ce426f
 	cfi_offset (v30, -128)
ce426f
 	cfi_offset (v31, -112)
ce426f
 	.machine pop
ce426f
-#else
ce426f
-	ahi    %r15,-96			# create stack frame
ce426f
 #endif
ce426f
-	st     %r12,0(%r15)		# save backchain
ce426f
+
ce426f
 	lm     %r2,%r3,24(%r12)		# load arguments saved by PLT
ce426f
 	lr     %r4,%r14			# return address as third parameter
ce426f
 	basr   %r1,0
ce426f
 0:	l      %r14,6f-0b(%r1)
ce426f
-	la     %r5,32(%r12)		# pointer to struct La_s390_32_regs
ce426f
+	la     %r5,96(%r15)		# pointer to struct La_s390_32_regs
ce426f
 	la     %r6,20(%r12)		# long int * framesize
ce426f
 	bas    %r14,0(%r14,%r1)		# call resolver
ce426f
 	lr     %r1,%r2			# function addr returned in r2
ce426f
-	ld     %f0,56(%r12)		# restore call-clobbered arg fprs
ce426f
-	ld     %f2,64(%r12)
ce426f
+	ld     %f0,120(%r15)		# restore call-clobbered arg fprs
ce426f
+	ld     %f2,128(%r15)
ce426f
 #ifdef RESTORE_VRS
ce426f
 	.machine push
ce426f
 	.machine "z13"
ce426f
 	.machinemode "zarch_nohighgprs"
ce426f
-	vlm    %v24,%v31,96(%r15)	# restore call-clobbered arg vrs
ce426f
+	vlm    %v24,%v31,136(%r15)	# restore call-clobbered arg vrs
ce426f
 	.machine pop
ce426f
 #endif
ce426f
 	icm    %r0,15,20(%r12)		# load & test framesize
ce426f
 	jnm    2f
ce426f
 
ce426f
-	lm     %r2,%r6,32(%r12)
ce426f
+	lm     %r2,%r6,96(%r15)		# framesize < 0 means no pltexit call
ce426f
+					# so we can do a tail call without
ce426f
+					# copying the arg overflow area
ce426f
 	lr     %r15,%r12		# remove stack frame
ce426f
 	cfi_def_cfa_register (15)
ce426f
 	l      %r14,16(%r15)		# restore registers
ce426f
@@ -175,7 +178,9 @@ _dl_runtime_profile:
ce426f
 	br     %r1			# tail-call to the resolved function
ce426f
 
ce426f
 	cfi_def_cfa_register (12)
ce426f
-2:	jz     4f			# framesize == 0 ?
ce426f
+2:	la     %r4,96(%r15)		# pointer to struct La_s390_32_regs
ce426f
+	st     %r4,32(%r12)
ce426f
+	jz     4f			# framesize == 0 ?
ce426f
 	ahi    %r0,7			# align framesize to 8
ce426f
 	lhi    %r2,-8
ce426f
 	nr     %r0,%r2
ce426f
@@ -188,24 +193,35 @@ _dl_runtime_profile:
ce426f
 	la     %r2,8(%r2)
ce426f
 	la     %r3,8(%r3)
ce426f
 	brct   %r0,3b
ce426f
-4:	lm     %r2,%r6,32(%r12)		# load register parameters
ce426f
+4:	lm     %r2,%r6,0(%r4)		# load register parameters
ce426f
 	basr   %r14,%r1			# call resolved function
ce426f
-	stm    %r2,%r3,72(%r12)		# store return values r2, r3, f0
ce426f
-	std    %f0,80(%r12)		# to struct La_s390_32_retval
ce426f
-	lm     %r2,%r3,24(%r12)		# load arguments saved by PLT
ce426f
+	stm    %r2,%r3,40(%r12)		# store return values r2, r3, f0
ce426f
+	std    %f0,48(%r12)		# to struct La_s390_32_retval
ce426f
+#ifdef RESTORE_VRS
ce426f
+	.machine push
ce426f
+	.machine "z13"
ce426f
+	vst    %v24,56(%r12)		# store return value v24
ce426f
+	.machine pop
ce426f
+#endif
ce426f
+	lm     %r2,%r4,24(%r12)		# r2, r3: load arguments saved by PLT
ce426f
+					# r4: pointer to struct La_s390_32_regs
ce426f
 	basr   %r1,0
ce426f
 5:	l      %r14,7f-5b(%r1)
ce426f
-	la     %r4,32(%r12)		# pointer to struct La_s390_32_regs
ce426f
-	la     %r5,72(%r12)		# pointer to struct La_s390_32_retval
ce426f
+	la     %r5,40(%r12)		# pointer to struct La_s390_32_retval
ce426f
 	bas    %r14,0(%r14,%r1)		# call _dl_call_pltexit
ce426f
 
ce426f
 	lr     %r15,%r12		# remove stack frame
ce426f
 	cfi_def_cfa_register (15)
ce426f
 	l      %r14,16(%r15)		# restore registers
ce426f
 	l      %r12,12(%r15)
ce426f
-	l      %r2,72(%r15)		# restore return values
ce426f
-	l      %r3,76(%r15)
ce426f
-	ld     %f0,80(%r15)
ce426f
+	lm     %r2,%r3,40(%r15)		# restore return values
ce426f
+	ld     %f0,48(%r15)
ce426f
+#ifdef RESTORE_VRS
ce426f
+	.machine push
ce426f
+	.machine "z13"
ce426f
+	vl    %v24,56(%r15)		# restore return value v24
ce426f
+	.machine pop
ce426f
+#endif
ce426f
 	br     %r14
ce426f
 
ce426f
 6:	.long  _dl_profile_fixup - 0b
ce426f
diff --git a/sysdeps/s390/s390-64/dl-trampoline.h b/sysdeps/s390/s390-64/dl-trampoline.h
ce426f
index 658e3a3..33ea3de 100644
ce426f
--- a/sysdeps/s390/s390-64/dl-trampoline.h
ce426f
+++ b/sysdeps/s390/s390-64/dl-trampoline.h
ce426f
@@ -109,31 +109,34 @@ _dl_runtime_resolve:
ce426f
 	cfi_startproc
ce426f
 	.align 16
ce426f
 _dl_runtime_profile:
ce426f
-	stmg   %r2,%r6,64(%r15)		# save call-clobbered arg regs
ce426f
-	cfi_offset (r2, -96)		# + r6 needed as arg for
ce426f
-	cfi_offset (r3, -88)		#  _dl_profile_fixup
ce426f
-	cfi_offset (r4, -80)
ce426f
-	cfi_offset (r5, -72)
ce426f
-	cfi_offset (r6, -64)
ce426f
-	std    %f0,104(%r15)
ce426f
-	cfi_offset (f0, -56)
ce426f
-	std    %f2,112(%r15)
ce426f
-	cfi_offset (f2, -48)
ce426f
-	std    %f4,120(%r15)
ce426f
-	cfi_offset (f4, -40)
ce426f
-	std    %f6,128(%r15)
ce426f
-	cfi_offset (f6, -32)
ce426f
 	stg    %r12,24(%r15)		# r12 is used as backup of r15
ce426f
 	cfi_offset (r12, -136)
ce426f
 	stg    %r14,32(%r15)
ce426f
 	cfi_offset (r14, -128)
ce426f
 	lgr    %r12,%r15		# backup stack pointer
ce426f
 	cfi_def_cfa_register (12)
ce426f
+	aghi   %r15,-360		# create stack frame:
ce426f
+					# 160 + sizeof(La_s390_64_regs)
ce426f
+	stg    %r12,0(%r15)		# save backchain
ce426f
+
ce426f
+	stmg   %r2,%r6,160(%r15)	# save call-clobbered arg regs
ce426f
+	cfi_offset (r2, -360)		# + r6 needed as arg for
ce426f
+	cfi_offset (r3, -352)		#  _dl_profile_fixup
ce426f
+	cfi_offset (r4, -344)
ce426f
+	cfi_offset (r5, -336)
ce426f
+	cfi_offset (r6, -328)
ce426f
+	std    %f0,200(%r15)
ce426f
+	cfi_offset (f0, -320)
ce426f
+	std    %f2,208(%r15)
ce426f
+	cfi_offset (f2, -312)
ce426f
+	std    %f4,216(%r15)
ce426f
+	cfi_offset (f4, -304)
ce426f
+	std    %f6,224(%r15)
ce426f
+	cfi_offset (f6, -296)
ce426f
 #ifdef RESTORE_VRS
ce426f
-	aghi   %r15,-288		# create stack frame
ce426f
 	.machine push
ce426f
 	.machine "z13"
ce426f
-	vstm   %v24,%v31,160(%r15)# store call-clobbered vector argument registers
ce426f
+	vstm   %v24,%v31,232(%r15)      # store call-clobbered vector arguments
ce426f
 	cfi_offset (v24, -288)
ce426f
 	cfi_offset (v25, -272)
ce426f
 	cfi_offset (v26, -256)
ce426f
@@ -143,31 +146,28 @@ _dl_runtime_profile:
ce426f
 	cfi_offset (v30, -192)
ce426f
 	cfi_offset (v31, -176)
ce426f
 	.machine pop
ce426f
-#else
ce426f
-	aghi   %r15,-160		# create stack frame
ce426f
 #endif
ce426f
-	stg    %r12,0(%r15)		# save backchain
ce426f
 	lmg    %r2,%r3,48(%r12)		# load arguments saved by PLT
ce426f
 	lgr    %r4,%r14			# return address as third parameter
ce426f
-	la     %r5,64(%r12)		# pointer to struct La_s390_64_regs
ce426f
+	la     %r5,160(%r15)		# pointer to struct La_s390_64_regs
ce426f
 	la     %r6,40(%r12)		# long int * framesize
ce426f
 	brasl  %r14,_dl_profile_fixup	# call resolver
ce426f
 	lgr    %r1,%r2			# function addr returned in r2
ce426f
-	ld     %f0,104(%r12)		# restore call-clobbered arg fprs
ce426f
-	ld     %f2,112(%r12)
ce426f
-	ld     %f4,120(%r12)
ce426f
-	ld     %f6,128(%r12)
ce426f
+	ld     %f0,200(%r15)		# restore call-clobbered arg fprs
ce426f
+	ld     %f2,208(%r15)
ce426f
+	ld     %f4,216(%r15)
ce426f
+	ld     %f6,224(%r15)
ce426f
 #ifdef RESTORE_VRS
ce426f
 	.machine push
ce426f
 	.machine "z13"
ce426f
-	vlm    %v24,%v31,160(%r15)	# restore call-clobbered arg vrs
ce426f
+	vlm    %v24,%v31,232(%r15)	# restore call-clobbered arg vrs
ce426f
 	.machine pop
ce426f
 #endif
ce426f
 	lg     %r0,40(%r12)		# load framesize
ce426f
 	ltgr   %r0,%r0
ce426f
 	jnm    1f
ce426f
 
ce426f
-	lmg    %r2,%r6,64(%r12)		# framesize < 0 means no pltexit call
ce426f
+	lmg    %r2,%r6,160(%r15)	# framesize < 0 means no pltexit call
ce426f
 					# so we can do a tail call without
ce426f
 					# copying the arg overflow area
ce426f
 	lgr    %r15,%r12		# remove stack frame
ce426f
@@ -177,7 +177,9 @@ _dl_runtime_profile:
ce426f
 	br     %r1			# tail-call to resolved function
ce426f
 
ce426f
 	cfi_def_cfa_register (12)
ce426f
-1:	jz     4f			# framesize == 0 ?
ce426f
+1:	la     %r4,160(%r15)		# pointer to struct La_s390_64_regs
ce426f
+	stg    %r4,64(%r12)
ce426f
+	jz     4f			# framesize == 0 ?
ce426f
 	aghi   %r0,7			# align framesize to 8
ce426f
 	nill   %r0,0xfff8
ce426f
 	slgr   %r15,%r0			# make room for framesize bytes
ce426f
@@ -189,21 +191,33 @@ _dl_runtime_profile:
ce426f
 	la     %r2,8(%r2)		# depending on framesize
ce426f
 	la     %r3,8(%r3)
ce426f
 	brctg  %r0,3b
ce426f
-4:	lmg    %r2,%r6,64(%r12)		# restore call-clobbered arg gprs
ce426f
+4:	lmg    %r2,%r6,0(%r4)		# restore call-clobbered arg gprs
ce426f
 	basr   %r14,%r1			# call resolved function
ce426f
-	stg    %r2,136(%r12)		# store return values r2, f0
ce426f
-	std    %f0,144(%r12)		# to struct La_s390_64_retval
ce426f
-	lmg    %r2,%r3,48(%r12)		# load arguments saved by PLT
ce426f
-	la     %r4,64(%r12)		# pointer to struct La_s390_64_regs
ce426f
-	la     %r5,136(%r12)		# pointer to struct La_s390_64_retval
ce426f
+	stg    %r2,72(%r12)		# store return values r2, f0
ce426f
+	std    %f0,80(%r12)		# to struct La_s390_64_retval
ce426f
+#ifdef RESTORE_VRS
ce426f
+	.machine push
ce426f
+	.machine "z13"
ce426f
+	vst    %v24,88(%r12)		# store return value v24
ce426f
+	.machine pop
ce426f
+#endif
ce426f
+	lmg    %r2,%r4,48(%r12)		# r2, r3: load arguments saved by PLT
ce426f
+					# r4: pointer to struct La_s390_64_regs
ce426f
+	la     %r5,72(%r12)		# pointer to struct La_s390_64_retval
ce426f
 	brasl  %r14,_dl_call_pltexit
ce426f
 
ce426f
 	lgr    %r15,%r12		# remove stack frame
ce426f
 	cfi_def_cfa_register (15)
ce426f
 	lg     %r14,32(%r15)		# restore registers
ce426f
 	lg     %r12,24(%r15)
ce426f
-	lg     %r2,136(%r15)		# restore return values
ce426f
-	ld     %f0,144(%r15)
ce426f
+	lg     %r2,72(%r15)		# restore return values
ce426f
+	ld     %f0,80(%r15)
ce426f
+#ifdef RESTORE_VRS
ce426f
+	.machine push
ce426f
+	.machine "z13"
ce426f
+	vl    %v24,88(%r15)		# restore return value v24
ce426f
+	.machine pop
ce426f
+#endif
ce426f
 	br     %r14			# Jump back to caller
ce426f
 
ce426f
 	cfi_endproc