190885
From 3c819146751bedbca46f5f089a786d7b5595baa8 Mon Sep 17 00:00:00 2001
190885
From: "H.J. Lu" <hjl.tools@gmail.com>
190885
Date: Wed, 2 Mar 2022 16:30:33 -0800
190885
Subject: [PATCH] x86-64: Use notl in EVEX strcmp [BZ #28646]
190885
190885
Must use notl %edi here as lower bits are for CHAR comparisons
190885
potentially out of range thus can be 0 without indicating mismatch.
190885
This fixes BZ #28646.
190885
190885
Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
190885
(cherry picked from commit 4df1fa6ddc8925a75f3da644d5da3bb16eb33f02)
190885
---
190885
 sysdeps/x86_64/multiarch/strcmp-evex.S | 14 ++++++++------
190885
 1 file changed, 8 insertions(+), 6 deletions(-)
190885
190885
diff --git a/sysdeps/x86_64/multiarch/strcmp-evex.S b/sysdeps/x86_64/multiarch/strcmp-evex.S
190885
index 82f12ac8..6f5c4bf9 100644
190885
--- a/sysdeps/x86_64/multiarch/strcmp-evex.S
190885
+++ b/sysdeps/x86_64/multiarch/strcmp-evex.S
190885
@@ -656,12 +656,13 @@ L(loop_cross_page):
190885
 	   in YMM3 and 32 bytes at VEC_SIZE(%rdx, %r10).  */
190885
 	VPCMP	$0, VEC_SIZE(%rdx, %r10), %YMM3, %k3{%k4}
190885
 	kmovd	%k3, %edi
190885
+    /* Must use notl %edi here as lower bits are for CHAR
190885
+	   comparisons potentially out of range thus can be 0 without
190885
+	   indicating mismatch.  */
190885
+	notl	%edi
190885
 # ifdef USE_AS_WCSCMP
190885
 	/* Don't use subl since it is the upper 8 bits of EDI below.  */
190885
-	notl	%edi
190885
 	andl	$0xff, %edi
190885
-# else
190885
-	incl	%edi
190885
 # endif
190885
 
190885
 # ifdef USE_AS_WCSCMP
190885
@@ -743,12 +744,13 @@ L(loop_cross_page_2_vec):
190885
 	   in YMM1 and 32 bytes at (VEC_SIZE * 3)(%rdx, %r10).  */
190885
 	VPCMP	$0, (VEC_SIZE * 3)(%rdx, %r10), %YMM1, %k3{%k4}
190885
 	kmovd	%k3, %edi
190885
+	/* Must use notl %edi here as lower bits are for CHAR
190885
+	   comparisons potentially out of range thus can be 0 without
190885
+	   indicating mismatch.  */
190885
+	notl	%edi
190885
 # ifdef USE_AS_WCSCMP
190885
 	/* Don't use subl since it is the upper 8 bits of EDI below.  */
190885
-	notl	%edi
190885
 	andl	$0xff, %edi
190885
-# else
190885
-	incl	%edi
190885
 # endif
190885
 
190885
 # ifdef USE_AS_WCSCMP
190885
-- 
190885
GitLab
190885