08c3a6
commit 83ae8287c1c3009459ff29241b647ff61363b22c
08c3a6
Author: Noah Goldstein <goldstein.w.n@gmail.com>
08c3a6
Date:   Tue Feb 15 08:18:15 2022 -0600
08c3a6
08c3a6
    x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #29127]
08c3a6
    
08c3a6
    Re-cherry-pick commit c627209832 for strcmp-avx2.S change which was
08c3a6
    omitted in intial cherry pick because at the time this bug was not
08c3a6
    present on release branch.
08c3a6
    
08c3a6
    Fixes BZ #29127.
08c3a6
    
08c3a6
    In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
08c3a6
    call strcmp-avx2 and wcscmp-avx2 respectively. This would have
08c3a6
    not checks around vzeroupper and would trigger spurious
08c3a6
    aborts. This commit fixes that.
08c3a6
    
08c3a6
    test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
08c3a6
    AVX2 machines with and without RTM.
08c3a6
    
08c3a6
    Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
08c3a6
    (cherry picked from commit c6272098323153db373f2986c67786ea8c85f1cf)
08c3a6
08c3a6
diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
08c3a6
index aa91f6e48a0e1ce5..a9806daadbbfd18b 100644
08c3a6
--- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
08c3a6
+++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
08c3a6
@@ -345,10 +345,10 @@ L(one_or_less):
08c3a6
 	movq	%LOCALE_REG, %rdx
08c3a6
 #  endif
08c3a6
 	jb	L(ret_zero)
08c3a6
-#  ifdef USE_AS_WCSCMP
08c3a6
 	/* 'nbe' covers the case where length is negative (large
08c3a6
 	   unsigned).  */
08c3a6
-	jnbe	__wcscmp_avx2
08c3a6
+	jnbe	OVERFLOW_STRCMP
08c3a6
+#  ifdef USE_AS_WCSCMP
08c3a6
 	movl	(%rdi), %edx
08c3a6
 	xorl	%eax, %eax
08c3a6
 	cmpl	(%rsi), %edx
08c3a6
@@ -357,10 +357,6 @@ L(one_or_less):
08c3a6
 	negl	%eax
08c3a6
 	orl	$1, %eax
08c3a6
 #  else
08c3a6
-	/* 'nbe' covers the case where length is negative (large
08c3a6
-	   unsigned).  */
08c3a6
-
08c3a6
-	jnbe	__strcmp_avx2
08c3a6
 	movzbl	(%rdi), %eax
08c3a6
 	movzbl	(%rsi), %ecx
08c3a6
 	TOLOWER_gpr (%rax, %eax)