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