]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #29127]
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 15 Feb 2022 14:18:15 +0000 (08:18 -0600)
committerSunil K Pandey <skpgkp2@gmail.com>
Wed, 25 May 2022 22:07:28 +0000 (15:07 -0700)
Re-cherry-pick commit c627209832 for strcmp-avx2.S change which was
omitted in intial cherry pick because at the time this bug was not
present on release branch.

Fixes BZ #29127.

In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
call strcmp-avx2 and wcscmp-avx2 respectively. This would have
not checks around vzeroupper and would trigger spurious
aborts. This commit fixes that.

test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
AVX2 machines with and without RTM.

Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit c6272098323153db373f2986c67786ea8c85f1cf)

sysdeps/x86_64/multiarch/strcmp-avx2.S

index aa91f6e48a0e1ce5b4f36e0e76ead6e069f5696d..a9806daadbbfd18be74cc56f8cb8cd80ec812c5a 100644 (file)
@@ -345,10 +345,10 @@ L(one_or_less):
        movq    %LOCALE_REG, %rdx
 #  endif
        jb      L(ret_zero)
-#  ifdef USE_AS_WCSCMP
        /* 'nbe' covers the case where length is negative (large
           unsigned).  */
-       jnbe    __wcscmp_avx2
+       jnbe    OVERFLOW_STRCMP
+#  ifdef USE_AS_WCSCMP
        movl    (%rdi), %edx
        xorl    %eax, %eax
        cmpl    (%rsi), %edx
@@ -357,10 +357,6 @@ L(one_or_less):
        negl    %eax
        orl     $1, %eax
 #  else
-       /* 'nbe' covers the case where length is negative (large
-          unsigned).  */
-
-       jnbe    __strcmp_avx2
        movzbl  (%rdi), %eax
        movzbl  (%rsi), %ecx
        TOLOWER_gpr (%rax, %eax)