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