[v1] x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896]
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
call strcmp-avx2 and wcsncmp-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. Note not tested on a machine that supports RTM (non
available).
---
sysdeps/x86_64/multiarch/strcmp-avx2.S | 8 ++------
sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S | 1 +
sysdeps/x86_64/multiarch/strncmp-avx2.S | 1 +
sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S | 2 +-
sysdeps/x86_64/multiarch/wcsncmp-avx2.S | 2 +-
5 files changed, 6 insertions(+), 8 deletions(-)
Comments
On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
> call strcmp-avx2 and wcsncmp-avx2 respectively. This would have
> not checks around vzeroupper and would trigger spurious
> aborts. This commit fixes that.
Include a testcase?
> test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all
> pass. Note not tested on a machine that supports RTM (non
> available).
> ---
> sysdeps/x86_64/multiarch/strcmp-avx2.S | 8 ++------
> sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S | 1 +
> sysdeps/x86_64/multiarch/strncmp-avx2.S | 1 +
> sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S | 2 +-
> sysdeps/x86_64/multiarch/wcsncmp-avx2.S | 2 +-
> 5 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> index 07a5a2c889..52ff5ad724 100644
> --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
> +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> @@ -193,10 +193,10 @@ L(ret_zero):
> .p2align 4,, 5
> L(one_or_less):
> 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
> @@ -205,10 +205,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
> subl %ecx, %eax
> diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> index 37d1224bb9..68bad365ba 100644
> --- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> +++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> @@ -1,3 +1,4 @@
> #define STRCMP __strncmp_avx2_rtm
> #define USE_AS_STRNCMP 1
> +#define OVERFLOW_STRCMP __strcmp_avx2_rtm
> #include "strcmp-avx2-rtm.S"
> diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> index 1678bcc235..f138e9f1fd 100644
> --- a/sysdeps/x86_64/multiarch/strncmp-avx2.S
> +++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> @@ -1,3 +1,4 @@
> #define STRCMP __strncmp_avx2
> #define USE_AS_STRNCMP 1
> +#define OVERFLOW_STRCMP __strcmp_avx2
> #include "strcmp-avx2.S"
> diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> index 4e88c70cc6..f467582cbe 100644
> --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> @@ -1,5 +1,5 @@
> #define STRCMP __wcsncmp_avx2_rtm
> #define USE_AS_STRNCMP 1
> #define USE_AS_WCSCMP 1
> -
> +#define OVERFLOW_STRCMP __wcscmp_avx2_rtm
> #include "strcmp-avx2-rtm.S"
> diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> index 4fa1de4d3f..e9ede522b8 100644
> --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> @@ -1,5 +1,5 @@
> #define STRCMP __wcsncmp_avx2
> #define USE_AS_STRNCMP 1
> #define USE_AS_WCSCMP 1
> -
> +#define OVERFLOW_STRCMP __wcscmp_avx2
> #include "strcmp-avx2.S"
> --
> 2.25.1
>
On Tue, Feb 15, 2022 at 10:30 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
> > call strcmp-avx2 and wcsncmp-avx2 respectively. This would have
> > not checks around vzeroupper and would trigger spurious
> > aborts. This commit fixes that.
>
> Include a testcase?
Added test case in V2. Don't have the hardware to check it though,
can you?
>
> > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all
> > pass. Note not tested on a machine that supports RTM (non
> > available).
> > ---
> > sysdeps/x86_64/multiarch/strcmp-avx2.S | 8 ++------
> > sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S | 1 +
> > sysdeps/x86_64/multiarch/strncmp-avx2.S | 1 +
> > sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S | 2 +-
> > sysdeps/x86_64/multiarch/wcsncmp-avx2.S | 2 +-
> > 5 files changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > index 07a5a2c889..52ff5ad724 100644
> > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > @@ -193,10 +193,10 @@ L(ret_zero):
> > .p2align 4,, 5
> > L(one_or_less):
> > 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
> > @@ -205,10 +205,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
> > subl %ecx, %eax
> > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > index 37d1224bb9..68bad365ba 100644
> > --- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > @@ -1,3 +1,4 @@
> > #define STRCMP __strncmp_avx2_rtm
> > #define USE_AS_STRNCMP 1
> > +#define OVERFLOW_STRCMP __strcmp_avx2_rtm
> > #include "strcmp-avx2-rtm.S"
> > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > index 1678bcc235..f138e9f1fd 100644
> > --- a/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > @@ -1,3 +1,4 @@
> > #define STRCMP __strncmp_avx2
> > #define USE_AS_STRNCMP 1
> > +#define OVERFLOW_STRCMP __strcmp_avx2
> > #include "strcmp-avx2.S"
> > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > index 4e88c70cc6..f467582cbe 100644
> > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > @@ -1,5 +1,5 @@
> > #define STRCMP __wcsncmp_avx2_rtm
> > #define USE_AS_STRNCMP 1
> > #define USE_AS_WCSCMP 1
> > -
> > +#define OVERFLOW_STRCMP __wcscmp_avx2_rtm
> > #include "strcmp-avx2-rtm.S"
> > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > index 4fa1de4d3f..e9ede522b8 100644
> > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > @@ -1,5 +1,5 @@
> > #define STRCMP __wcsncmp_avx2
> > #define USE_AS_STRNCMP 1
> > #define USE_AS_WCSCMP 1
> > -
> > +#define OVERFLOW_STRCMP __wcscmp_avx2
> > #include "strcmp-avx2.S"
> > --
> > 2.25.1
> >
>
>
> --
> H.J.
On Tue, Feb 15, 2022 at 8:51 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> On Tue, Feb 15, 2022 at 10:30 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > >
> > > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
> > > call strcmp-avx2 and wcsncmp-avx2 respectively. This would have
> > > not checks around vzeroupper and would trigger spurious
> > > aborts. This commit fixes that.
> >
> > Include a testcase?
> Added test case in V2. Don't have the hardware to check it though,
> can you?
Yes, I can. Please V2 on a branch in gitlab.
Thanks.
> >
> > > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all
> > > pass. Note not tested on a machine that supports RTM (non
> > > available).
> > > ---
> > > sysdeps/x86_64/multiarch/strcmp-avx2.S | 8 ++------
> > > sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S | 1 +
> > > sysdeps/x86_64/multiarch/strncmp-avx2.S | 1 +
> > > sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S | 2 +-
> > > sysdeps/x86_64/multiarch/wcsncmp-avx2.S | 2 +-
> > > 5 files changed, 6 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > > index 07a5a2c889..52ff5ad724 100644
> > > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > > @@ -193,10 +193,10 @@ L(ret_zero):
> > > .p2align 4,, 5
> > > L(one_or_less):
> > > 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
> > > @@ -205,10 +205,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
> > > subl %ecx, %eax
> > > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > > index 37d1224bb9..68bad365ba 100644
> > > --- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > > @@ -1,3 +1,4 @@
> > > #define STRCMP __strncmp_avx2_rtm
> > > #define USE_AS_STRNCMP 1
> > > +#define OVERFLOW_STRCMP __strcmp_avx2_rtm
> > > #include "strcmp-avx2-rtm.S"
> > > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > > index 1678bcc235..f138e9f1fd 100644
> > > --- a/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > > @@ -1,3 +1,4 @@
> > > #define STRCMP __strncmp_avx2
> > > #define USE_AS_STRNCMP 1
> > > +#define OVERFLOW_STRCMP __strcmp_avx2
> > > #include "strcmp-avx2.S"
> > > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > > index 4e88c70cc6..f467582cbe 100644
> > > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > > @@ -1,5 +1,5 @@
> > > #define STRCMP __wcsncmp_avx2_rtm
> > > #define USE_AS_STRNCMP 1
> > > #define USE_AS_WCSCMP 1
> > > -
> > > +#define OVERFLOW_STRCMP __wcscmp_avx2_rtm
> > > #include "strcmp-avx2-rtm.S"
> > > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > > index 4fa1de4d3f..e9ede522b8 100644
> > > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > > @@ -1,5 +1,5 @@
> > > #define STRCMP __wcsncmp_avx2
> > > #define USE_AS_STRNCMP 1
> > > #define USE_AS_WCSCMP 1
> > > -
> > > +#define OVERFLOW_STRCMP __wcscmp_avx2
> > > #include "strcmp-avx2.S"
> > > --
> > > 2.25.1
> > >
> >
> >
> > --
> > H.J.
On Tue, Feb 15, 2022 at 11:00 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Feb 15, 2022 at 8:51 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > On Tue, Feb 15, 2022 at 10:30 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > > >
> > > > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
> > > > call strcmp-avx2 and wcsncmp-avx2 respectively. This would have
> > > > not checks around vzeroupper and would trigger spurious
> > > > aborts. This commit fixes that.
> > >
> > > Include a testcase?
> > Added test case in V2. Don't have the hardware to check it though,
> > can you?
>
> Yes, I can. Please V2 on a branch in gitlab.
https://gitlab.com/x86-glibc/glibc/-/commits/users/goldsteinn/strncmp-rtm-test
>
> Thanks.
>
> > >
> > > > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all
> > > > pass. Note not tested on a machine that supports RTM (non
> > > > available).
> > > > ---
> > > > sysdeps/x86_64/multiarch/strcmp-avx2.S | 8 ++------
> > > > sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S | 1 +
> > > > sysdeps/x86_64/multiarch/strncmp-avx2.S | 1 +
> > > > sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S | 2 +-
> > > > sysdeps/x86_64/multiarch/wcsncmp-avx2.S | 2 +-
> > > > 5 files changed, 6 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > > > index 07a5a2c889..52ff5ad724 100644
> > > > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > > > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > > > @@ -193,10 +193,10 @@ L(ret_zero):
> > > > .p2align 4,, 5
> > > > L(one_or_less):
> > > > 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
> > > > @@ -205,10 +205,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
> > > > subl %ecx, %eax
> > > > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > > > index 37d1224bb9..68bad365ba 100644
> > > > --- a/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > > > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2-rtm.S
> > > > @@ -1,3 +1,4 @@
> > > > #define STRCMP __strncmp_avx2_rtm
> > > > #define USE_AS_STRNCMP 1
> > > > +#define OVERFLOW_STRCMP __strcmp_avx2_rtm
> > > > #include "strcmp-avx2-rtm.S"
> > > > diff --git a/sysdeps/x86_64/multiarch/strncmp-avx2.S b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > > > index 1678bcc235..f138e9f1fd 100644
> > > > --- a/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > > > +++ b/sysdeps/x86_64/multiarch/strncmp-avx2.S
> > > > @@ -1,3 +1,4 @@
> > > > #define STRCMP __strncmp_avx2
> > > > #define USE_AS_STRNCMP 1
> > > > +#define OVERFLOW_STRCMP __strcmp_avx2
> > > > #include "strcmp-avx2.S"
> > > > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > > > index 4e88c70cc6..f467582cbe 100644
> > > > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > > > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2-rtm.S
> > > > @@ -1,5 +1,5 @@
> > > > #define STRCMP __wcsncmp_avx2_rtm
> > > > #define USE_AS_STRNCMP 1
> > > > #define USE_AS_WCSCMP 1
> > > > -
> > > > +#define OVERFLOW_STRCMP __wcscmp_avx2_rtm
> > > > #include "strcmp-avx2-rtm.S"
> > > > diff --git a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > > > index 4fa1de4d3f..e9ede522b8 100644
> > > > --- a/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > > > +++ b/sysdeps/x86_64/multiarch/wcsncmp-avx2.S
> > > > @@ -1,5 +1,5 @@
> > > > #define STRCMP __wcsncmp_avx2
> > > > #define USE_AS_STRNCMP 1
> > > > #define USE_AS_WCSCMP 1
> > > > -
> > > > +#define OVERFLOW_STRCMP __wcscmp_avx2
> > > > #include "strcmp-avx2.S"
> > > > --
> > > > 2.25.1
> > > >
> > >
> > >
> > > --
> > > H.J.
>
>
>
> --
> H.J.
On Tue, Feb 15, 2022 at 9:06 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> On Tue, Feb 15, 2022 at 11:00 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Tue, Feb 15, 2022 at 8:51 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > >
> > > On Tue, Feb 15, 2022 at 10:30 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > >
> > > > On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > > > >
> > > > > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
> > > > > call strcmp-avx2 and wcsncmp-avx2 respectively. This would have
> > > > > not checks around vzeroupper and would trigger spurious
> > > > > aborts. This commit fixes that.
> > > >
> > > > Include a testcase?
> > > Added test case in V2. Don't have the hardware to check it though,
> > > can you?
> >
> > Yes, I can. Please V2 on a branch in gitlab.
>
> https://gitlab.com/x86-glibc/glibc/-/commits/users/goldsteinn/strncmp-rtm-test
I updated your branch with some fixes in the testcase and the commit log.
I tested it on an AVX2 machine with RTM. The testcase fails without your
fix.
Please submit the v2 patch.
Thanks.
On Tue, Feb 15, 2022 at 12:50 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Tue, Feb 15, 2022 at 9:06 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > On Tue, Feb 15, 2022 at 11:00 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Tue, Feb 15, 2022 at 8:51 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > > >
> > > > On Tue, Feb 15, 2022 at 10:30 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > > >
> > > > > On Tue, Feb 15, 2022 at 8:28 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> > > > > >
> > > > > > In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
> > > > > > call strcmp-avx2 and wcsncmp-avx2 respectively. This would have
> > > > > > not checks around vzeroupper and would trigger spurious
> > > > > > aborts. This commit fixes that.
> > > > >
> > > > > Include a testcase?
> > > > Added test case in V2. Don't have the hardware to check it though,
> > > > can you?
> > >
> > > Yes, I can. Please V2 on a branch in gitlab.
> >
> > https://gitlab.com/x86-glibc/glibc/-/commits/users/goldsteinn/strncmp-rtm-test
>
> I updated your branch with some fixes in the testcase and the commit log.
> I tested it on an AVX2 machine with RTM. The testcase fails without your
> fix.
>
> Please submit the v2 patch.
It's up.
>
> Thanks.
>
> --
> H.J.
@@ -193,10 +193,10 @@ L(ret_zero):
.p2align 4,, 5
L(one_or_less):
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
@@ -205,10 +205,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
subl %ecx, %eax
@@ -1,3 +1,4 @@
#define STRCMP __strncmp_avx2_rtm
#define USE_AS_STRNCMP 1
+#define OVERFLOW_STRCMP __strcmp_avx2_rtm
#include "strcmp-avx2-rtm.S"
@@ -1,3 +1,4 @@
#define STRCMP __strncmp_avx2
#define USE_AS_STRNCMP 1
+#define OVERFLOW_STRCMP __strcmp_avx2
#include "strcmp-avx2.S"
@@ -1,5 +1,5 @@
#define STRCMP __wcsncmp_avx2_rtm
#define USE_AS_STRNCMP 1
#define USE_AS_WCSCMP 1
-
+#define OVERFLOW_STRCMP __wcscmp_avx2_rtm
#include "strcmp-avx2-rtm.S"
@@ -1,5 +1,5 @@
#define STRCMP __wcsncmp_avx2
#define USE_AS_STRNCMP 1
#define USE_AS_WCSCMP 1
-
+#define OVERFLOW_STRCMP __wcscmp_avx2
#include "strcmp-avx2.S"