summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
* x86: Fix strncat-avx2.S reading past length [BZ #30065]Noah Goldstein2023-01-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Occurs when `src` has no null-term. Two cases: 1) Zero-length check is doing: ``` test %rdx, %rdx jl L(zero_len) ``` which doesn't actually check zero (was at some point `decq` and the flag never got updated). The fix is just make the flag `jle` i.e: ``` test %rdx, %rdx jle L(zero_len) ``` 2) Length check in page-cross case checking if we should continue is doing: ``` cmpq %r8, %rdx jb L(page_cross_small) ``` which means we will continue searching for null-term if length ends at the end of a page and there was no null-term in `src`. The fix is to make the flag: ``` cmpq %r8, %rdx jbe L(page_cross_small) ```
* Regenerate configure.Carlos O'Donell2023-01-312-3/+4
| | | | | | | Run using vanilla upstream autoconf 2.69. Minor whitespace change to sysdeps/loongarch/configure and sysdeps/mach/configure, and nothing else.
* sparc (64bit): Regenerate ulpsAndreas K. Hüttel2023-01-241-3/+4
| | | | | | | Linux catbus 5.15.69-gentoo #1 SMP Sat Sep 24 07:56:24 PDT 2022 sparc64 sun4v UltraSparc T5 (Niagara5) GNU/Linux gcc (Gentoo 11.3.1_p20221209 p3) 11.3.1 20221209 GNU ld (Gentoo 2.38 p4) 2.38 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* ia64: Regenerate ulpsAndreas K. Hüttel2023-01-241-2/+2
| | | | | | | Linux guppy 5.13.0-00002-gdecb01746d6c #368 SMP Sat Aug 14 20:10:13 UTC 2021 ia64 Dual-Core Intel(R) Itanium(R) Processor 9040 GenuineIntel GNU/Linux gcc (Gentoo 12.2.1_p20221231 p8) 12.2.1 20221231 GNU ld (Gentoo 2.40 p1) 2.40 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* x86: Cache computation for AMD architecture.Sajan Karumanchi2023-01-181-159/+45
| | | | | | | | All AMD architectures cache details will be computed based on __cpuid__ `0x8000_001D` and the reference to __cpuid__ `0x8000_0006` will be zeroed out for future architectures. Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
* AArch64: Improve strrchrWilco Dijkstra2023-01-171-25/+33
| | | | | | | | Use shrn for narrowing the mask which simplifies code and speeds up small strings. Unroll the first search loop to improve performance on large strings. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Optimize strnlenWilco Dijkstra2023-01-171-21/+18
| | | | | | | | Optimize strnlen using the shrn instruction and improve the main loop. Small strings are around 10% faster, large strings are 40% faster on modern CPUs. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Optimize strlenWilco Dijkstra2023-01-171-8/+12
| | | | | | | Optimize strlen by unrolling the main loop. Large strings are 64% faster on modern CPUs. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Optimize strcpyWilco Dijkstra2023-01-171-17/+19
| | | | | | Unroll the main loop. Large strings are around 20% faster on modern CPUs. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Improve strchrnulWilco Dijkstra2023-01-171-2/+10
| | | | | | Unroll the main loop, which improves performance slightly. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Optimize strchrWilco Dijkstra2023-01-171-28/+24
| | | | | | | Simplify calculation of the mask using shrn. Unroll the main loop. Small strings are 20% faster on modern CPUs. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Improve strlen_asimdWilco Dijkstra2023-01-171-12/+4
| | | | | | | Use shrn for the mask, merge tst+bne into cbnz, and tweak code alignment. Performance improves slightly as a result. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Optimize memrchrWilco Dijkstra2023-01-171-9/+11
| | | | | | Optimize the main loop - large strings are 43% faster on modern CPUs. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* AArch64: Optimize memchrWilco Dijkstra2023-01-171-13/+14
| | | | | | Optimize the main loop - large strings are 40% faster on modern CPUs. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* math: Suppress -O0 warnings for soft-fp fsqrt [BZ #19444]Adhemerval Zanella2023-01-111-0/+11
| | | | | | The patch suppress the same warnings from 87c266d758d29e52bfb717f90, that shows issues for microblaze, mips soft-fp, nios2, and or1k. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add HWCAP2_SVE_EBF16 from Linux 6.1 to AArch64 bits/hwcap.hJoseph Myers2023-01-101-0/+1
| | | | | | | Linux 6.1 adds a new AArch64 HWCAP2 value HWCAP2_SVE_EBF16; add it to the corresponding bits/hwcap.h. Tested with build-many-glibcs.py for aarch64.
* Update copyright dates with scripts/update-copyrightsJoseph Myers2023-01-067110-7110/+7110
|
* Fix ldbl-128 built-in function useJoseph Myers2023-01-053-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following issues with built-in function use in sysdeps/ieee754/ldbl-128 and sysdeps/ieee754/float128: * fabsl used __builtin_fabsf128 unconditionally, breaking the build with GCC 6 for several architectures; it should use __builtin_fabsl with an appropriate redirection in float128_private.h. (I'm not particularly concerned with building glibc with GCC 6; rather, I want to be able to run the tgmath.h tests with GCC 6, which is a significantly different case for tgmath.h compared to GCC 7 and later because of the lack of _FloatN / _FloatNx support in the compiler, and at present running the tests with a compiler means building glibc with that compiler.) * Some (conditional) uses of built-in functions had been added to ldbl-128 without appropriate float128_private.h remapping (there was remapping for the macros controlling whether the built-in functions are used, just not for the functions themselves). * s_llrintl.c called __builtin_round not __builtin_llrintl, which is obviously wrong. Tested with build-many-glibcs.py for aarch64-linux-gnu, GCC 6 (where it fixes the glibc build) and GCC 12, and with the glibc testsuite for x86_64.
* x86: Check minimum/maximum of non_temporal_threshold [BZ #29953]H.J. Lu2023-01-031-9/+16
| | | | | | | | | The minimum non_temporal_threshold is 0x4040. non_temporal_threshold may be set to less than the minimum value when the shared cache size isn't available (e.g., in an emulator) or by the tunable. Add checks for minimum and maximum of non_temporal_threshold. This fixes BZ #29953.
* i686: Regenerate ulpsAndreas K. Hüttel2023-01-021-7/+7
| | | | Reviewed-by: Florian Weimer <fweimer@redhat.com>
* hurd getcwd: Fix memory leak on errorSamuel Thibault2023-01-021-0/+2
|
* hurd fcntl: Make LOCKED macro more robustSamuel Thibault2023-01-021-2/+3
|
* hurd: Make dl-sysdep __sbrk check __vm_allocate callSamuel Thibault2023-01-021-1/+2
| | | | | The caller won't be able to progress, but better crash than use random addr.
* htl: Drop duplicate check in __pthread_stack_allocSamuel Thibault2023-01-021-3/+0
|
* htl: Fix sem_wait race between read and gsync_waitSamuel Thibault2022-12-301-2/+2
| | | | | | | | | If the value changes between sem_wait's read and the gsync_wait call, the kernel will return KERN_INVALID_ARGUMENT, which we have to interpret as the value having already changed. This fixes applications (e.g. libgo) seeing sem_wait erroneously return KERN_INVALID_ARGUMENT.
* Linux: Pass size argument of epoll_create to the kernelFlorian Weimer2022-12-221-1/+1
| | | | | | | | | | | The kernel actually verifies it, and a garbage value in the register causes improper system call failures. Fixes commit c1c0dea38833751f36a145c32 ("Linux: Remove epoll_create, inotify_init from syscalls.list") and commit d1d23b134244d59c4d6ef2295 ("Lninux: consolidate epoll_create implementation"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Define MADV_COLLAPSE from Linux 6.1Joseph Myers2022-12-222-0/+3
| | | | | | | Add the MADV_COLLAPSE constant from Linux 6.1 to bits/mman-linux.h and the hppa bits/mman.h. Tested for x86_64.
* powerpc64: Increase SIGSTKSZ and MINSIGSTKSZRajalakshmi Srinivasaraghavan2022-12-211-0/+5
| | | | | | | This patch increases the value of SIGSTKSZ and MINSIGSTKSZ for powerpc64 similar to the kernel commit 2f82ec19757f58549467db568c56e7dfff8af283 to allow further expansion of the signal stack frame size.
* Update kernel version to 6.1 in header constant testsJoseph Myers2022-12-213-4/+4
| | | | | | | | | This patch updates the kernel version in the tests tst-mman-consts.py, tst-mount-consts.py and tst-pidfd-consts.py to 6.1. (There are no new constants covered by these tests in 6.1 that need any other header changes.) Tested with build-many-glibcs.py.
* Update syscall lists for Linux 6.1Joseph Myers2022-12-201-2/+2
| | | | | Linux 6.1 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.1.
* stdio-common: Convert vfprintf and related functions to buffersFlorian Weimer2022-12-195-101/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vfprintf is entangled with vfwprintf (of course), __printf_fp, __printf_fphex, __vstrfmon_l_internal, and the strfrom family of functions. The latter use the internal snprintf functionality, so vsnprintf is converted as well. The simples conversion is __printf_fphex, followed by __vstrfmon_l_internal and __printf_fp, and finally __vfprintf_internal and __vfwprintf_internal. __vsnprintf_internal and strfrom* are mostly consuming the new interfaces, so they are comparatively simple. __printf_fp is a public symbol, so the FILE *-based interface had to preserved. The __printf_fp rewrite does not change the actual binary-to-decimal conversion algorithm, and digits are still not emitted directly to the target buffer. However, the staging buffer now uses bytes instead of wide characters, and one buffer copy is eliminated. The changes are at least performance-neutral in my testing. Floating point printing and snprintf improved measurably, so that this Lua script for i=1,5000000 do print(i, i * math.pi) end runs about 5% faster for me. To preserve fprintf performance for a simple "%d" format, this commit has some logic changes under LABEL (unsigned_number) to avoid additional function calls. There are certainly some very easy performance improvements here: binary, octal and hexadecimal formatting can easily avoid the temporary work buffer (the number of digits can be computed ahead-of-time using one of the __builtin_clz* built-ins). Decimal formatting can use a specialized version of _itoa_word for base 10. The existing (inconsistent) width handling between strfmon and printf is preserved here. __print_fp_buffer_1 would have to use __translated_number_width to achieve ISO conformance for printf. Test expectations in libio/tst-vtables-common.c are adjusted because the internal staging buffer merges all virtual function calls into one. In general, stack buffer usage is greatly reduced, particularly for unbuffered input streams. __printf_fp can still use a large buffer in binary128 mode for %g, though. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Remove epoll_create, inotify_init from syscalls.listFlorian Weimer2022-12-192-2/+2
| | | | | | | | | | | Their presence causes stub warnings to be created on architectures which do not implement them. Fixes commit d1d23b134244d59c4d6ef2295 ("Lninux: consolidate epoll_create implementation") and commit 842128f160a48e5545900ea3b ("Linux: consolidate inotify_init implementation"). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Reflow and sort some Makefile variablesFlorian Weimer2022-12-191-63/+155
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* mach: Drop remnants of old_CFLAGSSamuel Thibault2022-12-192-8/+0
|
* mach: Fix passing -ffreestanding when checking for gnumach headersSamuel Thibault2022-12-192-12/+6
| | | | | | 8b8c768e3c70 ("Force use of -ffreestanding when checking for gnumach headers") was passing -ffreestanding to CFLAGS only, but headers checks are performed with the preprocessor, so we rather need to pass it to CPPFLAGS.
* Force use of -ffreestanding when checking for gnumach headersFlavio Cruz2022-12-192-1/+13
| | | | | | | Without this ./configure assumes that we are in a fully hosted environment, which might not be the case. After this patch, we can rely on the freestanding header files provided by GCC such as stdint.h. Message-Id: <Y5+0V9osFc/zXMq0@mars>
* x86: Prevent SIGSEGV in memcmp-sse2 when data is concurrently modified [BZ ↵Noah Goldstein2022-12-151-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #29863] In the case of INCORRECT usage of `memcmp(a, b, N)` where `a` and `b` are concurrently modified as `memcmp` runs, there can be a SIGSEGV in `L(ret_nonzero_vec_end_0)` because the sequential logic assumes that `(rdx - 32 + rax)` is a positive 32-bit integer. To be clear, this change does not mean the usage of `memcmp` is supported. The program behaviour is undefined (UB) in the presence of data races, and `memcmp` is incorrect when the values of `a` and/or `b` are modified concurrently (data race). This UB may manifest itself as a SIGSEGV. That being said, if we can allow the idiomatic use cases, like those in yottadb with opportunistic concurrency control (OCC), to execute without a SIGSEGV, at no cost to regular use cases, then we can aim to minimize harm to those existing users. The fix replaces a 32-bit `addl %edx, %eax` with the 64-bit variant `addq %rdx, %rax`. The 1-extra byte of code size from using the 64-bit instruction doesn't contribute to overall code size as the next target is aligned and has multiple bytes of `nop` padding before it. As well all the logic between the add and `ret` still fits in the same fetch block, so the cost of this change is basically zero. The relevant sequential logic can be seen in the following pseudo-code: ``` /* * rsi = a * rdi = b * rdx = len - 32 */ /* cmp a[0:15] and b[0:15]. Since length is known to be [17, 32] in this case, this check is also assumed to cover a[0:(31 - len)] and b[0:(31 - len)]. */ movups (%rsi), %xmm0 movups (%rdi), %xmm1 PCMPEQ %xmm0, %xmm1 pmovmskb %xmm1, %eax subl %ecx, %eax jnz L(END_NEQ) /* cmp a[len-16:len-1] and b[len-16:len-1]. */ movups 16(%rsi, %rdx), %xmm0 movups 16(%rdi, %rdx), %xmm1 PCMPEQ %xmm0, %xmm1 pmovmskb %xmm1, %eax subl %ecx, %eax jnz L(END_NEQ2) ret L(END2): /* Position first mismatch. */ bsfl %eax, %eax /* The sequential version is able to assume this value is a positive 32-bit value because the first check included bytes in range a[0:(31 - len)] and b[0:(31 - len)] so `eax` must be greater than `31 - len` so the minimum value of `edx` + `eax` is `(len - 32) + (32 - len) >= 0`. In the concurrent case, however, `a` or `b` could have been changed so a mismatch in `eax` less or equal than `(31 - len)` is possible (the new low bound is `(16 - len)`. This can result in a negative 32-bit signed integer, which when zero extended to 64-bits is a random large value this out out of bounds. */ addl %edx, %eax /* Crash here because 32-bit negative number in `eax` zero extends to out of bounds 64-bit offset. */ movzbl 16(%rdi, %rax), %ecx movzbl 16(%rsi, %rax), %eax ``` This fix is quite simple, just make the `addl %edx, %eax` 64 bit (i.e `addq %rdx, %rax`). This prevents the 32-bit zero extension and since `eax` is still a low bound of `16 - len` the `rdx + rax` is bound by `(len - 32) - (16 - len) >= -16`. Since we have a fixed offset of `16` in the memory access this must be in bounds.
* Allow _Qp_fgt in sparc64 localplt.dataJoseph Myers2022-12-131-0/+1
| | | | | | | | | | A recent GCC change resulted in localplt test failures on sparc64 because of references to _Qp_fgt. This is analogous to all the other floating-point symbols allowed in localplt.data, so it seems appropriate to allow this one as well. Tested with build-many-glibcs.py for sparc64-linux-gnu (GCC mainline), where it fixes the test failure.
* Linux: Consolidate typesizes.hAdhemerval Zanella Netto2022-12-079-0/+646
| | | | | | | | | | | | | | | The generic (sysdeps/unix/sysv/linux/generic/bits/typesizes.h) and default (bits/typesizes.h) differs in two fields: bits/typesizes.h Linux generic __NLINK_T_TYPE __UWORD_TYPE __U32_TYPE __BLKSIZE_T_TYPE __SLONGWORD_TYPE __S32_TYPE Sinceit leads to different C++ mangling names, the default typesize.h is copied for the requires archtiectures and the generic is make the default Linux one. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Make generic fcntl.h the default oneAdhemerval Zanella Netto2022-12-072-57/+54
| | | | | | | | It is currently used for csky, arc, nios2, and or1k. Newer 64 bit architecture, like riscv32 and loongarch, reimplement it to override F_GETLK64/F_SETLK64/F_SETLKW64. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: make generic xstatver.h the default oneAdhemerval Zanella Netto2022-12-074-11/+37
| | | | | | And copy the current default one to required ABIs. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Remove generic sysdepAdhemerval Zanella Netto2022-12-0710-33/+21
| | | | | | | The includes chain is added on each architecture sysdep.h and the __NR__llseek hack is moved to lseek.c and lseek64.c. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Assume and consolidate shutdown wire-up syscallAdhemerval Zanella Netto2022-12-0710-15/+8
| | | | | | | | And disable if kernel does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Assume and consolidate listen wire-up syscallAdhemerval Zanella Netto2022-12-0710-17/+6
| | | | | | | | And disable if kernel does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Assume and consolidate socketpair wire-up syscallAdhemerval Zanella Netto2022-12-0710-14/+5
| | | | | | | | And disable if kernel does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Assume and consolidate socket wire-up syscallAdhemerval Zanella Netto2022-12-0710-14/+5
| | | | | | | | And disable if kernel does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: Assume and consolidate bind wire-up syscallAdhemerval Zanella Netto2022-12-0710-14/+9
| | | | | | | | And disable if kernel does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: consolidate ____longjmp_chkAdhemerval Zanella Netto2022-12-071-3/+3
| | | | | | Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: consolidate sendfile implementationAdhemerval Zanella Netto2022-12-077-11/+49
| | | | | | | | | | | | | This is similar to other LFS consolidation, where the non-LFS is only built if __OFF_T_MATCHES_OFF64_T is not defined and the LFS version is aliased to non-LFS name if __OFF_T_MATCHES_OFF64_T is defined. For non-LFS variant, use sendfile syscall if defined, otherwise use sendfile64 plus the offset overflow check (as generic implementation). Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Linux: consolidate unlink implementationAdhemerval Zanella Netto2022-12-071-2/+7
| | | | | | | | Use unlink syscall if defined, otherwise use unlinkat. Checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>