076f82
commit 4c92a1041257c0155c6aa7a182fe5f78e477b0e6
076f82
Author: Matheus Castanho <msc@linux.ibm.com>
076f82
Date:   Tue Jun 7 10:27:26 2022 -0300
076f82
076f82
    powerpc: Fix VSX register number on __strncpy_power9 [BZ #29197]
076f82
    
076f82
    __strncpy_power9 initializes VR 18 with zeroes to be used throughout the
076f82
    code, including when zero-padding the destination string. However, the
076f82
    v18 reference was mistakenly being used for stxv and stxvl, which take a
076f82
    VSX vector as operand. The code ended up using the uninitialized VSR 18
076f82
    register by mistake.
076f82
    
076f82
    Both occurrences have been changed to use the proper VSX number for VR 18
076f82
    (i.e. VSR 50).
076f82
    
076f82
    Tested on powerpc, powerpc64 and powerpc64le.
076f82
    
076f82
    Signed-off-by: Kewen Lin <linkw@gcc.gnu.org>
076f82
    (cherry picked from commit 0218463dd8265ed937622f88ac68c7d984fe0cfc)
076f82
076f82
diff --git a/sysdeps/powerpc/powerpc64/le/power9/strncpy.S b/sysdeps/powerpc/powerpc64/le/power9/strncpy.S
076f82
index 291941c1e5c0eb4b..5421525acee3ebfe 100644
076f82
--- a/sysdeps/powerpc/powerpc64/le/power9/strncpy.S
076f82
+++ b/sysdeps/powerpc/powerpc64/le/power9/strncpy.S
076f82
@@ -352,7 +352,7 @@ L(zero_padding_loop):
076f82
 	cmpldi	cr6,r5,16	/* Check if length was reached.  */
076f82
 	ble	cr6,L(zero_padding_end)
076f82
 
076f82
-	stxv	v18,0(r11)
076f82
+	stxv	32+v18,0(r11)
076f82
 	addi	r11,r11,16
076f82
 	addi	r5,r5,-16
076f82
 
076f82
@@ -360,7 +360,7 @@ L(zero_padding_loop):
076f82
 
076f82
 L(zero_padding_end):
076f82
 	sldi	r10,r5,56	/* stxvl wants size in top 8 bits  */
076f82
-	stxvl	v18,r11,r10	/* Partial store  */
076f82
+	stxvl	32+v18,r11,r10	/* Partial store  */
076f82
 	blr
076f82
 
076f82
 	.align	4