glibc/sysdeps
Noah Goldstein 7da0886247 x86: Fix bug in strchrnul-evex512 [BZ #32078]
Issue was we were expecting not matches with CHAR before the start of
the string in the page cross case.

The check code in the page cross case:
```
    and    $0xffffffffffffffc0,%rax
    vmovdqa64 (%rax),%zmm17
    vpcmpneqb %zmm17,%zmm16,%k1
    vptestmb %zmm17,%zmm17,%k0{%k1}
    kmovq  %k0,%rax
    inc    %rax
    shr    %cl,%rax
    je     L(continue)
```

expects that all characters that neither match null nor CHAR will be
1s in `rax` prior to the `inc`. Then the `inc` will overflow all of
the 1s where no relevant match was found.

This is incorrect in the page-cross case, as the
`vmovdqa64 (%rax),%zmm17` loads from before the start of the input
string.

If there are matches with CHAR before the start of the string, `rax`
won't properly overflow.

The fix is quite simple. Just replace:

```
    inc    %rax
    shr    %cl,%rax
```
With:
```
    sar    %cl,%rax
    inc    %rax
```

The arithmetic shift will clear any matches prior to the start of the
string while maintaining the signbit so the 1s can properly overflow
to zero in the case of no matches.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-15 08:11:33 -07:00
..
aarch64 aarch64: Regenerate ULPs 2024-08-07 11:02:03 -03:00
alpha math: Update alpha ulps 2024-07-14 12:44:15 +02:00
arc ARC: Regenerate ULPs 2024-08-11 15:29:56 +02:00
arm arm: Regenerate ULPs 2024-08-07 11:02:03 -03:00
csky elf: Remove HWCAP_IMPORTANT 2024-06-18 10:45:36 +02:00
generic elf: Avoid re-initializing already allocated TLS in dlopen (bug 31717) 2024-08-05 18:26:52 +02:00
gnu sysdeps: Re-flow and sort multiline gnu/Makefile definitions 2024-08-07 11:02:03 -03:00
hppa hppa: Update libm-test-ulps 2024-07-24 16:43:01 -04:00
htl hurd: Fix missing pthread_ compat symbol in libc 2024-08-01 23:58:51 +02:00
hurd hurd: Move internal functions to internal header 2024-03-23 22:43:07 +01:00
i386 i386: Regenerate ULPs 2024-08-07 11:02:03 -03:00
ieee754 Convert to autoconf 2.72 (vanilla release, no distribution patches) 2024-06-17 21:15:28 +02:00
loongarch LoongArch: Add cfi instructions for _dl_tlsdesc_dynamic 2024-08-09 09:06:17 +08:00
m68k math: Update m68k ULPs 2024-07-08 21:51:03 +02:00
mach hurd: Fix missing pthread_ compat symbol in libc 2024-08-01 23:58:51 +02:00
microblaze Implement C23 logp1 2024-06-17 13:47:09 +00:00
mips MIPS: Regenerate ULPs 2024-08-08 14:53:53 +02:00
nios2 Convert to autoconf 2.72 (vanilla release, no distribution patches) 2024-06-17 21:15:28 +02:00
nptl Linux: Make __rseq_size useful for feature detection (bug 31965) 2024-07-09 19:33:37 +02:00
or1k Implement C23 logp1 2024-06-17 13:47:09 +00:00
posix posix: Sync tempname with gnulib 2024-04-10 14:53:39 -03:00
powerpc powerpc64le: Update ulps 2024-08-08 13:42:12 +02:00
pthread nptl: Use <support/check.h> facilities in tst-setuid3 2024-07-26 13:21:34 +01:00
riscv RISC-V: Regenerate ULPs 2024-08-08 14:53:55 +02:00
s390 s390x: Update ulps 2024-08-08 13:01:02 +02:00
sh Implement C23 logp1 2024-06-17 13:47:09 +00:00
sparc sparc: Regenerate ULPs 2024-08-07 11:02:03 -03:00
unix Add mremap tests 2024-08-01 05:06:12 -07:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
wordsize-64 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
x86 x86: Tunables may incorrectly set Prefer_PMINUB_for_stringop (bug 32047) 2024-08-02 18:08:14 +02:00
x86_64 x86: Fix bug in strchrnul-evex512 [BZ #32078] 2024-08-15 08:11:33 -07:00