about summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
* sysdeps/unix/sysv/linux/x86_64/Makefile: Add the end markerH.J. Lu2024-02-281-3/+6
| | | | Add the end marker to tests, tests-container and modules-names.
* s390: Improve static-pie configure testsAdhemerval Zanella2024-02-282-231/+40
| | | | | | | | | | | | | | | | | | | | Instead of tying based on the linker name and version, check for the required support: * whether it does not generate dynamic TLS relocations in PIE (binutils PR ld/22263); * if it accepts --no-dynamic-linker (by using -static-pie); * and if it adds a DT_JMPREL pointing to .rela.iplt with static pie. The patch also trims the comments, for binutils one of the tests should already cover it. The kernel ones are not clear which version should have the backport, nor it is something that glibc can do much about it. Finally, the glibc is somewhat confusing, since it refers to commits not related to s390x. Checked with a build for s390x-linux-gnu. Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
* x86: Change ENQCMD test to CHECK_FEATURE_PRESENTH.J. Lu2024-02-271-1/+1
| | | | | | Since ENQCMD is mainly used in kernel, change the ENQCMD test to CHECK_FEATURE_PRESENT. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* aarch64/fpu: Sync libmvec routines from 2.39 and before with AORJoe Ramsay2024-02-2618-105/+111
| | | | | | | This includes a fix for big-endian in AdvSIMD log, some cosmetic changes, and numerous small optimisations mainly around inlining and using indexed variants of MLA intrinsics. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* S390: Do not clobber r7 in clone [BZ #31402]Stefan Liebler2024-02-263-12/+63
| | | | | | | | | | | | Starting with commit e57d8fc97b90127de4ed3e3a9cdf663667580935 "S390: Always use svc 0" clone clobbers the call-saved register r7 in error case: function or stack is NULL. This patch restores the saved registers also in the error case. Furthermore the existing test misc/tst-clone is extended to check all error cases and that clone does not clobber registers in this error case.
* x86_64: Exclude SSE, AVX and FMA4 variants in libm multiarchSunil K Pandey2024-02-2562-295/+953
| | | | | | | | | | | | | | | | | | | When glibc is built with ISA level 3 or higher by default, the resulting glibc binaries won't run on SSE or FMA4 processors. Exclude SSE, AVX and FMA4 variants in libm multiarch when ISA level 3 or higher is enabled by default. When glibc is built with ISA level 2 enabled by default, only keep SSE4.1 variant. Fixes BZ 31335. NB: elf/tst-valgrind-smoke test fails with ISA level 4, because valgrind doesn't support AVX512 instructions: https://bugs.kde.org/show_bug.cgi?id=383010 Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86-64: Save APX registers in ld.so trampolineH.J. Lu2024-02-251-6/+46
| | | | | | | | | Add APX registers to STATE_SAVE_MASK so that APX registers are saved in ld.so trampoline. This fixes BZ #31371. Also update STATE_SAVE_OFFSET and STATE_SAVE_MASK for i386 which will be used by i386 _dl_tlsdesc_dynamic. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
* tests: gracefully handle AppArmor userns containmentSimon Chopin2024-02-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Recent AppArmor containment allows restricting unprivileged user namespaces, which is enabled by default on recent Ubuntu systems. When this happens, as is common with Linux Security Modules, the syscall will fail with -EACCESS. When that happens, the affected tests will now be considered unsupported rather than simply failing. Further information: * https://gitlab.com/apparmor/apparmor/-/wikis/unprivileged_userns_restriction * https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces * https://manpages.ubuntu.com/manpages/jammy/man5/apparmor.d.5.html (for the return code) V2: * Fix duplicated line in check_unshare_hints * Also handle similar failure in tst-pidfd_getpid V3: * Comment formatting * Aded some more documentation on syscall return value Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
* powerpc: Remove power7 strstr optimizationAdhemerval Zanella2024-02-238-671/+1
| | | | | | | | | | | | | | | The optimization is not faster than the generic algorithm, using the bench-strstr the geometric mean running on a POWER10 machine using gcc 13.1.1 is 482.47 while the default __strstr_ppc is 340.97 (which uses the generic implementation). Also, there is no need to redirect the internal str*/mem* call to optimized version, internal ifunc is supported and enabled for internal calls (meaning that the generic implementation will use any asm optimization if available). Checked on powerpc64le-linux-gnu. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
* arm: Use _dl_find_object on __gnu_Unwind_Find_exidx (BZ 31405)Adhemerval Zanella2024-02-231-53/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of __dl_iterate_phdr. On ARM dlfo_eh_frame/dlfo_eh_count maps to PT_ARM_EXIDX vaddr start / length. On a Neoverse N1 machine with 160 cores, the following program: $ cat test.c #include <stdlib.h> #include <pthread.h> #include <assert.h> enum { niter = 1024, ntimes = 128, }; static void * tf (void *arg) { int a = (int) arg; for (int i = 0; i < niter; i++) { void *p[ntimes]; for (int j = 0; j < ntimes; j++) p[j] = malloc (a * 128); for (int j = 0; j < ntimes; j++) free (p[j]); } return NULL; } int main (int argc, char *argv[]) { enum { nthreads = 16 }; pthread_t t[nthreads]; for (int i = 0; i < nthreads; i ++) assert (pthread_create (&t[i], NULL, tf, (void *) i) == 0); for (int i = 0; i < nthreads; i++) { void *r; assert (pthread_join (t[i], &r) == 0); assert (r == NULL); } return 0; } $ arm-linux-gnueabihf-gcc -fsanitize=address test.c -o test Improves from ~15s to 0.5s. Checked on arm-linux-gnueabihf.
* math: Update mips64 ulpsXi Ruoyao2024-02-221-3/+4
| | | | Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
* sparc: Treat the version field in the FPU control word as reservedDaniel Cederman2024-02-191-1/+1
| | | | | | | | | | The FSR version field is read-only and might be non-zero. This allows math/test-fpucw* to correctly pass when the version is non-zero. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Implement setcontext/getcontext/makecontext/swapcontext for Hurd x86_64Flavio Cruz2024-02-176-0/+456
| | | | | Tested with the tests provided by glibc plus some other toy examples. Message-ID: <20240217202535.1860803-1-flaviocruz@gmail.com>
* Use proc_getchildren_rusage when available in getrusage and times.Flavio Cruz2024-02-174-3/+216
| | | | Message-ID: <20240217164846.1837223-1-flaviocruz@gmail.com>
* Linux: Switch back to assembly syscall wrapper for prctl (bug 29770)Florian Weimer2024-02-172-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit ff026950e280bc3e9487b41b460fb31bc5b57721 ("Add a C wrapper for prctl [BZ #25896]") replaced the assembler wrapper with a C function. However, on powerpc64le-linux-gnu, the C variadic function implementation requires extra work in the caller to set up the parameter save area. Calling a function that needs a parameter save area without one (because the prototype used indicates the function is not variadic) corrupts the caller's stack. The Linux manual pages project documents prctl as a non-variadic function. This has resulted in various projects over the years using non-variadic prototypes, including the sanitizer libraries in LLVm and GCC (GCC PR 113728). This commit switches back to the assembler implementation on most targets and only keeps the C implementation for x86-64 x32. Also add the __prctl_time64 alias from commit b39ffab860cd743a82c91946619f1b8158b0b65e ("Linux: Add time64 alias for prctl") to sysdeps/unix/sysv/linux/syscalls.list; it was not yet present in commit ff026950e280bc3e9487b41b460fb31bc5b57721. This restores the old ABI on powerpc64le-linux-gnu, thus fixing bug 29770. Reviewed-By: Simon Chopin <simon.chopin@canonical.com>
* i386: Use generic memrchr in libc (bug 31316)Florian Weimer2024-02-162-1/+1
| | | | | | | | Before this change, we incorrectly used the SSE2 variant in the implementation, without checking that the system actually supports SSE2. Tested-by: Sam James <sam@gentoo.org>
* Apply the Makefile sorting fixH.J. Lu2024-02-155-57/+57
| | | | Apply the Makefile sorting fix generated by sort-makefile-lines.py.
* sysdeps/x86_64/Makefile (tests): Add the end markerH.J. Lu2024-02-151-2/+4
|
* mips: Use builtins for ffs and ffsllJunxian Zhu2024-02-141-0/+3
| | | | | | | | | | | __builtin_ffs{,ll} basically on __builtin_ctz{,ll} in MIPS GCC compiler. The hardware ctz instructions were available after MIPS{32,64} Release1. By using builtin ctz. It can also reduce code size of ffs/ffsll. Checked on mips o32. mips64. Signed-off-by: Junxian Zhu <zhujunxian@oss.cipunited.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
* x86: Expand the comment on when REP STOSB is used on memsetAdhemerval Zanella2024-02-131-1/+3
| | | | Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86: Do not prefer ERMS for memset on Zen3+Adhemerval Zanella2024-02-131-0/+5
| | | | | | | | For AMD Zen3+ architecture, the performance of the vectorized loop is slightly better than ERMS. Checked on x86_64-linux-gnu on Zen3. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86: Fix Zen3/Zen4 ERMS selection (BZ 30994)Adhemerval Zanella2024-02-131-20/+18
| | | | | | | | | | | | | | | | The REP MOVSB usage on memcpy/memmove does not show much performance improvement on Zen3/Zen4 cores compared to the vectorized loops. Also, as from BZ 30994, if the source is aligned and the destination is not the performance can be 20x slower. The performance difference is noticeable with small buffer sizes, closer to the lower bounds limits when memcpy/memmove starts to use ERMS. The performance of REP MOVSB is similar to vectorized instruction on the size limit (the L2 cache). Also, there is no drawback to multiple cores sharing the cache. Checked on x86_64-linux-gnu on Zen3. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* x86/cet: fix shadow stack test scriptsMichael Jeanson2024-02-123-3/+3
| | | | | | | | | | | | | Some shadow stack test scripts use the '==' operator with the 'test' command to validate exit codes resulting in the following error: sysdeps/x86_64/tst-shstk-legacy-1e.sh: 31: test: 139: unexpected operator The '==' operator is invalid for the 'test' command, use '-eq' like the previous call to 'test'. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* Add SOL_VSOCK from Linux 6.7 to bits/socket.hJoseph Myers2024-02-081-0/+1
| | | | | | | | | Linux 6.7 adds a constant SOL_VSOCK (recall that various constants in include/linux/socket.h are in fact part of the kernel-userspace API despite that not being a uapi header). Add it to glibc's bits/socket.h. Tested for x86_64.
* Add new AArch64 HWCAP2 definitions from Linux 6.7 to bits/hwcap.hJoseph Myers2024-02-081-0/+3
| | | | | Linux 6.7 adds three new HWCAP2_* values for AArch64; add them to bits/hwcap.h in glibc.
* arm: Remove wrong ldr from _dl_start_user (BZ 31339)Adhemerval Zanella2024-02-051-1/+0
| | | | | | | | | | | | | | | | | | The commit 49d877a80b29d3002887b084eec6676d9f5fec18 (arm: Remove _dl_skip_args usage) removed the _SKIP_ARGS literal, which was previously loader to r4 on loader _start. However, the cleanup did not remove the following 'ldr r4, [sl, r4]' on _dl_start_user, used to check to skip the arguments after ld self-relocations. In my testing, the kernel initially set r4 to 0, which makes the ldr instruction just read the _GLOBAL_OFFSET_TABLE_. However, since r4 is a callee-saved register; a different runtime might not zero initialize it and thus trigger an invalid memory access. Checked on arm-linux-gnu. Reported-by: Adrian Ratiu <adrian.ratiu@collabora.com> Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* LoongArch: Use builtins for ffs and ffsllXi Ruoyao2024-02-051-0/+2
| | | | | | | | | | | | On LoongArch GCC compiles __builtin_ffs{,ll} to basically `(x ? __builtin_ctz (x) : -1) + 1`. Since a hardware ctz instruction is available, this is much better than the table-driven generic implementation. Tested on loongarch64. Signed-off-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Remove sysdeps/ia64/math-use-builtins-ffs.hXi Ruoyao2024-02-051-2/+0
| | | | | | IA64 is gone. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
* mips: FIx clone3 implementation (BZ 31325)Adhemerval Zanella2024-02-021-5/+27
| | | | | | | | | | | | | For o32 we need to setup a minimal stack frame to allow cprestore on __thread_start_clone3 (which instruct the linker to save the gp for PIC). Also, there is no guarantee by kABI that $8 will be preserved after syscall execution, so we need to save it on the provided stack. Checked on mipsel-linux-gnu. Reported-by: Khem Raj <raj.khem@gmail.com> Tested-by: Khem Raj <raj.khem@gmail.com>
* Rename c2x / gnu2x tests to c23 / gnu23Joseph Myers2024-02-0115-26/+26
| | | | | | | Complete the internal renaming from "C2X" and related names in GCC by renaming *-c2x and *-gnu2x tests to *-c23 and *-gnu23. Tested for x86_64, and with build-many-glibcs.py for powerpc64le.
* string: Use builtins for ffs and ffsllAdhemerval Zanella Netto2024-02-0126-648/+35
| | | | | | | It allows to remove a lot of arch-specific implementations. Checked on x86_64, aarch64, powerpc64. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* misc: tst-poll: Proper synchronize with child before sending the signalAdhemerval Zanella2024-02-011-3/+3
| | | | | | | | | | When running the testsuite in parallel, for instance running make -j $(nproc) check, occasionally tst-epoll fails with a timeout. It happens because it sometimes takes a bit more than 10ms for the process to get cloned and blocked by the syscall. In that case the signal is sent to early, and the test fails with a timeout. Checked on x86_64-linux-gnu.
* Refer to C23 in place of C2X in glibcJoseph Myers2024-02-0118-24/+28
| | | | | | | | | | | | | | | WG14 decided to use the name C23 as the informal name of the next revision of the C standard (notwithstanding the publication date in 2024). Update references to C2X in glibc to use the C23 name. This is intended to update everything *except* where it involves renaming files (the changes involving renaming tests are intended to be done separately). In the case of the _ISOC2X_SOURCE feature test macro - the only user-visible interface involved - support for that macro is kept for backwards compatibility, while adding _ISOC23_SOURCE. Tested for x86_64.
* S390: Fix building with --disable-mutli-arch [BZ #31196]Stefan Liebler2024-01-302-2/+6
| | | | | | | | | | | | | | | | | | | | | | Starting with commits - 7ea510127e2067efa07865158ac92c330c379950 string: Add libc_hidden_proto for strchrnul - 22999b2f0fb62eed1af4095d062bd1272d6afeb1 string: Add libc_hidden_proto for memrchr building glibc on s390x with --disable-multi-arch fails if only the C-variant of strchrnul / memrchr is used. This is the case if gcc uses -march < z13. The build fails with: ../sysdeps/s390/strchrnul-c.c:28:49: error: ‘__strchrnul_c’ undeclared here (not in a function); did you mean ‘__strchrnul’? 28 | __hidden_ver1 (__strchrnul_c, __GI___strchrnul, __strchrnul_c); With --disable-multi-arch, __strchrnul_c is not available as string/strchrnul.c is just included without defining STRCHRNUL and thus we also don't have to create the internal hidden symbol. Tested-by: Andreas K. Hüttel <dilfridge@gentoo.org>
* riscv: add support for static PIEAndreas Schwab2024-01-221-0/+11
| | | | | In order to support static PIE the startup code must avoid relocations before __libc_start_main is called.
* sh: Fix static build with --enable-fortifyAdhemerval Zanella2024-01-221-2/+2
| | | | | | | For static the internal symbols should not be prepended with the internal __GI_. Checked with a make check for sh4-linux-gnu.
* sparc: Fix sparc64 memmove length comparison (BZ 31266)Adhemerval Zanella2024-01-221-1/+1
| | | | | | | | The small counts copy bytes comparsion should be unsigned (as the memmove size argument). It fixes string/tst-memmove-overflow on sparcv9, where the input size triggers an invalid code path. Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
* sparc64: Remove unwind information from signal return stubs [BZ#31244]Adhemerval Zanella2024-01-221-2/+5
| | | | | | | | | | | | | Similar to sparc32 fix, remove the unwind information on the signal return stubs. This fixes the regressions: FAIL: nptl/tst-cancel24-static FAIL: nptl/tst-cond8-static FAIL: nptl/tst-mutex8-static FAIL: nptl/tst-mutexpi8-static FAIL: nptl/tst-mutexpi9 On sparc64-linux-gnu.
* sparc: Remove 64 bit check on sparc32 wordsize (BZ 27574)Adhemerval Zanella2024-01-221-9/+4
| | | | | | The sparc32 is always 32 bits. Checked on sparcv9-linux-gnu.
* sparc: Do not test preservation of NaN payloads for LEONDaniel Cederman2024-01-181-0/+30
| | | | | | | | The FPU used by LEON does not preserve NaN payload. This change allows the math/test-*-canonicalize tests to pass on LEON. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sparc: Force calculation that raises exceptionDaniel Cederman2024-01-181-5/+6
| | | | | | | | | | Use the math_force_eval() macro to force the calculation to complete and raise the exception. With this change the math/test-fenv test pass. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sparc: Fix llrint and llround missing exceptions on SPARC V8Daniel Cederman2024-01-181-0/+43
| | | | | | | | | | Conversions from a float to a long long on SPARC v8 uses a libgcc function that may not raise the correct exceptions on overflow. It also may raise spurious "inexact" exceptions on non overflow cases. This patch fixes the problem in the same way as for RV32. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sparc: Remove unwind information from signal return stubs [BZ #31244]Daniel Cederman2024-01-182-4/+16
| | | | | | | | | | | | | | | | | | The functions were previously written in C, but were not compiled with unwind information. The ENTRY/END macros includes .cfi_startproc and .cfi_endproc which adds unwind information. This caused the tests cleanup-8 and cleanup-10 in the GCC testsuite to fail. This patch adds a version of the ENTRY/END macros without the CFI instructions that can be used instead. sigaction registers a restorer address that is located two instructions before the stub function. This patch adds a two instruction padding to avoid that the unwinder accesses the unwind information from the function that the linker has placed right before it in memory. This fixes an issue with pthread_cancel that caused tst-mutex8-static (and other tests) to fail. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sparc: Prevent stfsr from directly following floating-point instructionDaniel Cederman2024-01-181-1/+6
| | | | | | | | | | | | | On LEON, if the stfsr instruction is immediately following a floating-point operation instruction in a running program, with no other instruction in between the two, the stfsr might behave as if the order was reversed between the two instructions and the stfsr occurred before the floating-point operation. Add a nop instruction before the stfsr to prevent this from happening. Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sparc: Use existing macros to avoid code duplicationDaniel Cederman2024-01-181-7/+3
| | | | | | | | | Macros for using inline assembly to access the fp state register exists in both fenv_private.h and in fpu_control.h. Let fenv_private.h use the macros from fpu_control.h Signed-off-by: Daniel Cederman <cederman@gaisler.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Update kernel version to 6.7 in header constant testsJoseph Myers2024-01-173-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.7. (There are no new constants covered by these tests in 6.7 that need any other header changes.) Tested with build-many-glibcs.py.
* Update syscall lists for Linux 6.7Joseph Myers2024-01-1727-2/+107
| | | | | | | | | Linux 6.7 adds the futex_requeue, futex_wait and futex_wake syscalls, and enables map_shadow_stack for architectures previously missing it. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
* x86-64: Check if mprotect works before rewriting PLTH.J. Lu2024-01-153-1/+75
| | | | | | | | | | | | | | | | Systemd execution environment configuration may prohibit changing a memory mapping to become executable: MemoryDenyWriteExecute= Takes a boolean argument. If set, attempts to create memory mappings that are writable and executable at the same time, or to change existing memory mappings to become executable, or mapping shared memory segments as executable, are prohibited. When it is set, systemd service stops working if PLT rewrite is enabled. Check if mprotect works before rewriting PLT. This fixes BZ #31230. This also works with SELinux when deny_execmem is on. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* x86_64: Optimize ffsll function code size.Sunil K Pandey2024-01-131-5/+5
| | | | | | | | | | | | | | | | | Ffsll function randomly regress by ~20%, depending on how code gets aligned in memory. Ffsll function code size is 17 bytes. Since default function alignment is 16 bytes, it can load on 16, 32, 48 or 64 bytes aligned memory. When ffsll function load at 16, 32 or 64 bytes aligned memory, entire code fits in single 64 bytes cache line. When ffsll function load at 48 bytes aligned memory, it splits in two cache line, hence random regression. Ffsll function size reduction from 17 bytes to 12 bytes ensures that it will always fit in single 64 bytes cache line. This patch fixes ffsll function random performance regression. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* RISC-V: Enable static-pie.Yanzhang Wang2024-01-123-1/+77
| | | | | | | | | This patch referents the commit 374cef3 to add static-pie support. And because the dummy link map is used when relocating ourselves, so need not to set __global_pointer$ at this time. It will also check whether toolchain supports to build static-pie. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>