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