Blame SOURCES/glibc-rh1385004-19.patch

147e83
From 2fd1041a8d9684978546886d58fdf8add8c8d9f7 Mon Sep 17 00:00:00 2001
147e83
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
147e83
Date: Tue, 5 Jul 2016 21:20:41 +0530
147e83
Subject: [PATCH] powerpc: Fix return code of strcasecmp for unaligned inputs
147e83
147e83
If the input values are unaligned and if there are null characters in the
147e83
memory before the starting address of the input values, strcasecmp
147e83
gives incorrect return code. Fixed it by adding mask the bits that
147e83
are not part of the string.
147e83
147e83
(cherry picked from commit 30e4cc5413f72c2c728a544389da0c48500d9904)
147e83
---
147e83
 ChangeLog                                     |  6 ++++++
147e83
 sysdeps/powerpc/powerpc64/power8/strcasecmp.S | 17 ++++++++++++++---
147e83
 2 files changed, 20 insertions(+), 3 deletions(-)
147e83
147e83
diff --git a/ChangeLog b/ChangeLog
147e83
index 9385bd0..af5f694 100644
147e83
diff --git a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
147e83
index 63f6217..c83dc52 100644
147e83
--- a/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
147e83
+++ b/sysdeps/powerpc/powerpc64/power8/strcasecmp.S
147e83
@@ -40,11 +40,20 @@
147e83
 	vsel	v5, v7, v5, v8; \
147e83
 	vcmpequb.	v7, v5, v4;
147e83
 
147e83
-/* Get 16 bytes for unaligned case.  */
147e83
+/*
147e83
+ * Get 16 bytes for unaligned case.
147e83
+ * reg1: Vector to hold next 16 bytes.
147e83
+ * reg2: Address to read from.
147e83
+ * reg3: Permute control vector.
147e83
+ * v8: Tmp vector used to mask unwanted bytes.
147e83
+ * v9: Tmp vector,0 when null is found on first 16 bytes
147e83
+ */
147e83
 #ifdef __LITTLE_ENDIAN__
147e83
 #define GET16BYTES(reg1, reg2, reg3) \
147e83
 	lvx	reg1, 0, reg2; \
147e83
-	vcmpequb.	v8, v0, reg1; \
147e83
+	vspltisb	v8, -1; \
147e83
+	vperm	v8, v8, reg1, reg3; \
147e83
+	vcmpequb.	v8, v0, v8; \
147e83
 	beq	cr6, 1f; \
147e83
 	vspltisb	v9, 0; \
147e83
 	b	2f; \
147e83
@@ -57,7 +66,9 @@
147e83
 #else
147e83
 #define GET16BYTES(reg1, reg2, reg3) \
147e83
 	lvx	reg1, 0, reg2; \
147e83
-	vcmpequb.	v8, v0, reg1; \
147e83
+	vspltisb	 v8, -1; \
147e83
+	vperm	v8, reg1, v8,  reg3; \
147e83
+	vcmpequb.	v8, v0, v8; \
147e83
 	beq	cr6, 1f; \
147e83
 	vspltisb	v9, 0; \
147e83
 	b	2f; \
147e83
-- 
147e83
2.1.0
147e83