about summary refs log tree commit diff
path: root/sysdeps/unix
Commit message (Collapse)AuthorAgeFilesLines
* Remove stat wrapper functions, move them to exported symbolsAdhemerval Zanella2020-10-0951-92/+325
| | | | | | | | | | | | | | | | | | | | | | | | This patch removes the stat, stat64, lstat, lstat64, fstat, fstat64, fstatat, and fstatat64 static wrapper and add the symbol on the libc with the expected names. Both the prototypes of the internal symbol linked by the static wrappers and the inline redirectors are also removed from the installed sys/stat.h header file. The wrapper implementation license LGPL exception is also removed since it is no longer statically linked to binaries. Internally the _STAT_VER* definitions are moved to a arch-specific xstatver.h file. The internal defines that redirects internals {f}stat{at} to their {f}xstat{at} counterparts are removed for Linux (!NO_RTLD_HIDDEN). Hurd still requires them since {f}stat{at} pulls extra objects that makes the loader build fail otherwise (I haven't dig into why exactly). Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Add missing cancellation flags on futex_internal and pselect32Adhemerval Zanella2020-10-071-0/+1
| | | | | | | It fixes the tst-cancelx{4,5} and tst-cancel24-{static} regression on some platforms (arm and sparc32). Checked on arm-linux-gnueabihf and sparcv9-linux-gnu.
* elf: Implement _dl_writeFlorian Weimer2020-10-071-0/+30
| | | | | | | | The generic version is parallel to _dl_writev. It cannot use _dl_writev directly because the errno value needs to be obtained under a lock. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Require properly configured /dev/pts for PTYsFlorian Weimer2020-10-073-192/+43
| | | | | | | | | | | | | Current systems do not have BSD terminals, so the fallback code in posix_openpt/getpt does not do anything. Also remove the file system check for /dev/pts. Current systems always have a devpts file system mounted there if /dev/ptmx exists. grantpt is now essentially a no-op. It only verifies that the argument is a ptmx-descriptor. Therefore, this change indirectly addresses bug 24941. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: unlockpt needs to fail with EINVAL, not ENOTTY (bug 26053)Florian Weimer2020-10-071-16/+5
| | | | | | | | | | The EINVAL error code is mandated by POSIX and documented in the manual. Also clean up the unlockpt implementation a bit, assuming that TIOCSPTLCK is always defined. Enhance login/tst-grantpt to cover unlockpt corner cases. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* posix: Fix -Warray-bounds instances building timer_create [BZ #26687]Adhemerval Zanella2020-10-068-89/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 11 -Warray-bounds triggers invalid warnings when building Linux timer_create.c: ../sysdeps/unix/sysv/linux/timer_create.c: In function '__timer_create_new': ../sysdeps/unix/sysv/linux/timer_create.c:83:17: warning: array subscript 'struct timer[0]' is partly outside array bounds of 'unsigned char[8]' [-Warray-bounds] 83 | newp->sigev_notify = (evp != NULL | ^~ ../sysdeps/unix/sysv/linux/timer_create.c:59:47: note: referencing an object of size 8 allocated by 'malloc' 59 | struct timer *newp = (struct timer *) malloc (offsetof (struct timer, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | thrfunc)); | ~~~~~~~~~ The struct allocated for !SIGEV_THREAD timers only requires two 'int' fields (sigev_notify and ktimerid) and the offsetof trick tries minimize the memory usage by only allocation the required size. However, although the resulting size is suffice for !SIGEV_THREAD time, accessing the partially allocated object is error-prone and UB. This patch fixes both issues by embedding the information whether the timer if a SIGEV_THREAD in the returned 'timer_t'. For !SIGEV_THREAD, the resulting 'timer_t' is the returned kernel timer identifer (kernel_timer_t), while for SIGEV_THREAD it uses the fact malloc returns at least _Alignof (max_align_t) pointers plus that valid kernel_timer_t are always positive to set MSB bit of the returned 'timer_t' to indicate the timer handles a SIGEV_THREAD. It allows to remove the memory allocation for !SIGEV_THREAD and also remove the 'sigev_notify' field from 'struct timer'. Checked on x86_64-linux-gnu and i686-linux-gnu.
* Replace Minumum/minumum with Minimum/minimumH.J. Lu2020-10-062-2/+2
| | | | Replace Minumum/minumum in comments with Minimum/minimum.
* sysvipc: Return EINVAL for invalid msgctl commandsAdhemerval Zanella2020-10-021-10/+31
| | | | | | | | It avoids regressions on possible future commands that might require additional libc support. The downside is new commands added by newer kernels will need further glibc support. Checked on x86_64-linux-gnu and i686-linux-gnu (Linux v4.15 and v5.4).
* sysvipc: Fix IPC_INFO and MSG_INFO handling [BZ #26639]Adhemerval Zanella2020-10-023-5/+196
| | | | | | | | | | | | | | | | Both commands are Linux extensions where the third argument is a 'struct msginfo' instead of 'struct msqid_ds' and its information does not contain any time related fields (so there is no need to extra conversion for __IPC_TIME64. The regression testcase checks for Linux specifix SysV ipc message control extension. For IPC_INFO/MSG_INFO it tries to match the values against the tunable /proc values and for MSG_STAT/MSG_STAT_ANY it check if the create message queue is within the global list returned by the kernel. Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on Linux v4.15).
* sysvipc: Return EINVAL for invalid semctl commandsAdhemerval Zanella2020-10-021-0/+10
| | | | | | | | It avoids regressions on possible future commands that might require additional libc support. The downside is new commands added by newer kernels will need further glibc support. Checked on x86_64-linux-gnu and i686-linux-gnu (Linux v4.15 and v5.4).
* sysvipc: Fix SEM_STAT_ANY kernel argument pass [BZ #26637]Dmitry V. Levin2020-10-023-1/+191
| | | | | | | | | | | | | | | | Handle SEM_STAT_ANY the same way as SEM_STAT so that the buffer argument of SEM_STAT_ANY is properly passed to the kernel and back. The regression testcase checks for Linux specifix SysV ipc message control extension. For IPC_INFO/SEM_INFO it tries to match the values against the tunable /proc values and for SEM_STAT/SEM_STAT_ANY it check if the create message queue is within the global list returned by the kernel. Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on Linux v4.15). Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysvipc: Fix semtimedop for Linux < 5.1 for 64-bit ABIAdhemerval Zanella2020-09-301-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Both powerpc64 and s390x provides semtimedop through __NR_ipc for pre v5.1 kernel. Neither the y2038 support (7c437d3778) nor the attempt to fix an issue for !__ASSUME_DIRECT_SYSVIPC_SYSCALLS (aaa12e9ff0) took this in consideration. This patch fixes it by issuing __NR_semtimedop_time64 iff it is defined, otherwise __NR_semtimeop is issued if both __ASSUME_DIRECT_SYSVIPC_SYSCALLS it set and __NR_semtimedop is define, other __NR_ipc is used instead. To summarize: 1. For 32-bit architetures __NR_semtimedop_time64 is always issued. The fallback is used only for !__ASSUME_TIME64_SYSCALLS and it issues either __NR_ipc or __NR_semtimedop. 2. For 64-bit architecture with wire-up SysV syscall (__ASSUME_DIRECT_SYSVIPC_SYSCALLS and __NR_semtimeop defined) __NR_semtimeop is issued. 3. Otherwise __NR_ipc is used instead. Checked on x86_64-linux-gnu, i686-linux-gnu (kernel 4.15 and 5.4), powerpc64le (kernel 4.18), and s390x (kernel 4.12). Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
* linux: Add time64 recvmmsg supportAdhemerval Zanella2020-09-281-11/+52
| | | | | | | | | | | | | | | The wire-up syscall __NR_recvmmsg_time64 (for 32-bit) or __NR_recvmmsg (for 64-bit) is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_socketcall or __NR_recvmmsg (32-bit time_t). It does not handle the timestamps on ancillary data (SCM_TIMESTAMPING records). Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Add time64 support for nanosleepAdhemerval Zanella2020-09-281-0/+50
| | | | | | | | | It uses __clock_nanosleep64 and adds the __nanosleep64 symbol. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Consolidate utimesAdhemerval Zanella2020-09-283-81/+0
| | | | | | | | | | | The generic version does not have time64 support and Linux default uses utimensat. With hppa version gone, __ASSUME_UTIMES is not used anymore. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Use 64-bit time_t syscall on clock_getcputclockidAdhemerval Zanella2020-09-281-10/+15
| | | | | | | | | | | | | | | The syscall __NR_clock_getres_time64 (for 32-bit) or __NR_clock_getres (for 64-bit) is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_rt_sigtimedwait (32-bit time_t). Since the symbol does not use any type which might be affected by the time_t, there is no need to add a 64-bit variant. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Add time64 sigtimedwait supportAdhemerval Zanella2020-09-281-8/+42
| | | | | | | | | | | The syscall __NR_sigtimedwait_time64 (for 32-bit) or __NR_sigtimedwait (for 64-bit) is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_rt_sigtimedwait (32-bit time_t). Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Add time64 select supportAdhemerval Zanella2020-09-281-23/+69
| | | | | | | | | | | | | The syscall __NR_pselect6_time64 (32-bit) or __NR_pselect6 (64-bit) is used as default. For architectures with __ASSUME_TIME64_SYSCALLS the 32-bit fallback uses __NR_select/__NR__newselect or __NR_pselect6 (it should cover the microblaze case where older kernels do not provide __NR_pselect6). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* sysvipc: Fix semtimeop for !__ASSUME_DIRECT_SYSVIPC_SYSCALLSAdhemerval Zanella2020-09-281-8/+3
| | | | | | | The __NR_ipc syscall does not support 64-bit time operations. It fixes 7c437d3778. Checked on i686-linux-gnu on a Linux 5.4.
* Update mallinfo2 ABI, and testDJ Delorie2020-09-1732-0/+32
| | | | | | | This patch adds the ABI-related bits to reflect the new mallinfo2 function, and adds a test case to verify basic functionality. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Allow memset local PLT reference for RISC-V.Alistair Francis2020-09-171-0/+1
| | | | | | | | | | | | | | | | This is similar to commit a26e2e9feab87d4f745c31411458b048742ac733 "Allow memset local PLT reference for powerpc soft-float.". GCC 10.1 results in the localplt test failing for RISC-V. From the original commit for power-pc: Since memset is documented as a function GCC may always implicitly generate calls to, it seems reasonable to allow that local PLT reference (just like those for libgcc functions that GCC implicitly generates calls to and that are also exported from libc.so), which this patch does. Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
* pselect.c: Pass a pointer to SYSCALL_CANCEL [BZ #26606]H.J. Lu2020-09-151-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | commit a92f4e6299fe0e3cb6f77e79de00817aece501ce Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Mon Jul 6 13:27:12 2020 -0300 linux: Add time64 pselect support changed pselect.c to r = SYSCALL_CANCEL (pselect6_time64, nfds, readfds, writefds, exceptfds, timeout, ((__syscall_ulong_t[]){ (uintptr_t) sigmask, __NSIG_BYTES })); which doesn't work with x32's ARGIFY and data passed to syscall isn't initialized with sigmask and __NSIG_BYTES. Change to __syscall_ulong_t data[2] = { (uintptr_t) sigmask, __NSIG_BYTES }; r = SYSCALL_CANCEL (pselect6_time64, nfds, readfds, writefds, exceptfds, timeout, data); fixes [BZ #26606].
* x86: Install <sys/platform/x86.h> [BZ #26124]H.J. Lu2020-09-113-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Install <sys/platform/x86.h> so that programmers can do #if __has_include(<sys/platform/x86.h>) #include <sys/platform/x86.h> #endif ... if (CPU_FEATURE_USABLE (SSE2)) ... if (CPU_FEATURE_USABLE (AVX2)) ... <sys/platform/x86.h> exports only: enum { COMMON_CPUID_INDEX_1 = 0, COMMON_CPUID_INDEX_7, COMMON_CPUID_INDEX_80000001, COMMON_CPUID_INDEX_D_ECX_1, COMMON_CPUID_INDEX_80000007, COMMON_CPUID_INDEX_80000008, COMMON_CPUID_INDEX_7_ECX_1, /* Keep the following line at the end. */ COMMON_CPUID_INDEX_MAX }; struct cpuid_features { struct cpuid_registers cpuid; struct cpuid_registers usable; }; struct cpu_features { struct cpu_features_basic basic; struct cpuid_features features[COMMON_CPUID_INDEX_MAX]; }; /* Get a pointer to the CPU features structure. */ extern const struct cpu_features *__x86_get_cpu_features (unsigned int max) __attribute__ ((const)); Since all feature checks are done through macros, programs compiled with a newer <sys/platform/x86.h> are compatible with the older glibc binaries as long as the layout of struct cpu_features is identical. The features array can be expanded with backward binary compatibility for both .o and .so files. When COMMON_CPUID_INDEX_MAX is increased to support new processor features, __x86_get_cpu_features in the older glibc binaries returns NULL and HAS_CPU_FEATURE/CPU_FEATURE_USABLE return false on the new processor feature. No new symbol version is neeeded. Both CPU_FEATURE_USABLE and HAS_CPU_FEATURE are provided. HAS_CPU_FEATURE can be used to identify processor features. Note: Although GCC has __builtin_cpu_supports, it only supports a subset of <sys/platform/x86.h> and it is equivalent to CPU_FEATURE_USABLE. It doesn't support HAS_CPU_FEATURE.
* linux: Add time64 pselect supportAdhemerval Zanella2020-09-114-35/+99
| | | | | | | | | | | | | | | The syscall __NR_pselect6_time64 (32-bit) or __NR_pselect6 (64-bit) is used as default. For architectures with __ASSUME_TIME64_SYSCALLS the 32-bit fallback uses __NR_pselec6. To accomodate microblaze missing pselect6 support on kernel older than 3.15 the fallback is moved to its own function to the microblaze specific implementation can override it. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Add time64 semtimedop supportAdhemerval Zanella2020-09-112-8/+55
| | | | | | | | | | | | Either the __NR_semtimedop_time64 (for 32-bit) or the __NR_semtimedop (for 64-bit) syscall is used as default. The 32-bit fallback is used iff __ASSUME_TIME64_SYSCALLS is not defined, which assumes the kernel ABI provides either __NR_ipc or __NR_semtimeop (for 32-bit time_t). Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Add ppoll time64 optimizationAdhemerval Zanella2020-09-111-5/+13
| | | | | | | | | | It avoid continuing issue the __NR_ppoll_time64 syscall once the kernel advertise it does not support it. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* linux: Simplify clock_getresAdhemerval Zanella2020-09-111-23/+15
| | | | | | | | | | | | | With arch-syscall.h it can now assumes the existance of either __NR_clock_getres or __NR_clock_getres_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. It also uses the time64-support functions to simplify it further. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* Remove internal usage of extensible stat functionsAdhemerval Zanella2020-09-117-16/+16
| | | | | | | | | | | | It replaces the internal usage of __{f,l}xstat{at}{64} with the __{f,l}stat{at}{64}. It should not change the generate code since sys/stat.h explicit defines redirections to internal calls back to xstat* symbols. Checked with a build for all affected ABIs. I also check on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Linux: Consolidate xmknodAdhemerval Zanella2020-09-112-59/+3
| | | | | | | | | The __NR_mknodat syscall is supported on all kernels, so the generic implementation is used as default. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Consolidate fxstatat{64}Adhemerval Zanella2020-09-1123-301/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LFS support is implemented on fxstat64.c, instead of fxstat.c for 64-bit architectures. The fxstatat.c implements the non-LFS and it is a no-op for !XSTAT_IS_XSTAT64. The generic non-LFS implementation handles two cases: 1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and nios): it issues __NR_fstatat64 plus handle the overflow on st_ino, st_size, or st_blocks. It only handles _STAT_VER_KERNEL. 2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k, mips32, microblaze, s390, sh, powerpc, and sparc32). it issues __NR_fstatat64 and convert to non-LFS stat struct based on the version. Also non-LFS mips64 is an outlier and it has its own implementation since _STAT_VER_LINUX requires a different conversion function (it uses the kernel_stat as the sysissues argument since its exported ABI is different than the kernel one for both non-LFS and LFS implementation). The generic LFS implementation handles multiple cases: 1. XSTAT_IS_XSTAT64 being 1: 1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, riscv64, and x86_64): it issues __NR_newfstatat for _STAT_VER_KERNEL or _STAT_VER_LINUX. 1.2. 64-bit kABI outlier (sparc64): it issuess fstatat64 with a temporary stat64 and convert to output stat64 based on the input version (and using a sparc64 specific __xstat32_conv). 1.3. New 32-bit kABIs with only 64-bit time_t support (arc and riscv32): it issues __NR_statx and covert to struct stat64. 2. Old ABIs with XSTAT_IS_XSTAT64 being 0 (arm, csky, i386, hppa, m68k, microblaze, mips32, nios2, sh, powerpc32, and sparc32): it issues __NR_fstat64. Also, two special cases requires specific implementations: 1. alpha: it uses the __NR_fstatat64 syscall instead. 2. mips64: as for non-LFS implementation its ABIs differ from glibc exported one, which requires an specific conversion function to handle the kernel_stat. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Consolidate fxstat{64}Adhemerval Zanella2020-09-1118-268/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LFS support is implemented on fxstat64.c, instead of fxstat.c for 64-bit architectures. The fxstat.c implements the non-LFS and it is a no-op for !XSTAT_IS_XSTAT64. The generic non-LFS implementation handles two cases: 1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and nios): it issuess __NR_fstat64 plus handle the overflow on st_ino, st_size, or st_blocks. It only handles _STAT_VER_KERNEL. 2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k, microblaze, s390, sh, powerpc, and sparc32). For _STAT_VER_KERNEL it issues __NR_fstat, otherwise it calls __NR_fstat64 and convert to non-LFS stat struct and handle possible overflows on st_ino, st_size, or st_blocks. Also non-LFS mips is an outlier and it has its own implementation since _STAT_VER_LINUX requires a different conversion function (it uses the kernel_stat as the sysissues argument since its exported ABI is different than the kernel one for both non-LFS and LFS implementation). The generic LFS implementation handles multiple cases: 1. XSTAT_IS_XSTAT64 being 1: 1.1. 64-bit kABI (aarch64, ia64, powerpc64*, s390x, riscv64, and x86_64): it issuess __NR_fstat for _STAT_VER_KERNEL or _STAT_VER_LINUX. 1.2. Old 64-bit kABI with defines __NR_fstat64 instead of __NR_fstat (sparc64): it issues __NR_fstat for _STAT_VER_KERNEL or __NR_fstat64 and convert to struct stat64. 1.3. New 32-bit kABIs with only 64-bit time_t support (arc and riscv32): it issuess __NR_statx and covert to struct stat64. 2. Old ABIs with XSTAT_IS_XSTAT64 being 0 (arm, csky, i386, hppa, m68k, microblaze, mips32, nios2, sh, powerpc32, and sparc32): it issues __NR_fstat64. Also, two special cases requires specific implementations: 1. alpha: it requires to handle _STAT_VER_KERNEL64 to issues __NR_fstat64 and use the kernel_stat with __NR_fstat otherwise. 2. mips64: as for non-LFS implementation its ABIs differ from glibc exported one, which requires an specific conversion function to handle the kernel_stat. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Consolidate lxstat{64}Adhemerval Zanella2020-09-1119-345/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LFS support is implemented on lxstat64.c, instead of lxstat.c for 64-bit architectures. The xstat.c implements the non-LFS and it is a no-op for !XSTAT_IS_XSTAT64. The generic non-LFS implementation handles two cases: 1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and nios): it issues __NR_fstat64 with AT_SYMLINK_NOFOLLOW plus handles the possible overflow off st_ino, st_size, or st_blocks. It only handles _STAT_VER_KERNEL. 2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k, microblaze, s390, sh, powerpc, and sparc32). For _STAT_VER_KERNEL it issues __NR_lstat, otherwise it isseus __NR_lstat64 and convert to non-LFS stat struct and handle possible overflows on st_ino, st_size, or st_blocks. Also non-LFS mips is an outlier and it has its own implementation since _STAT_VER_LINUX requires a different conversion function (it uses the kernel_stat as the syscall argument since its exported ABI is different than the kernel one for both non-LFS and LFS implementation). The generic LFS implementation handles multiple cases: 1. XSTAT_IS_XSTAT64 being 1: 1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, sparc64, x86_64): it issues __NR_lstat for _STAT_VER_KERNEL or _STAT_VER_LINUX. 1.2. Old 64-bit kABI with defines __NR_lstat64 instead of __NR_lstat (sparc64): it issues __NR_lstat for _STAT_VER_KERNEL or __NR_lstat64 and convert to struct stat64. 1.3. New kABIs which uses generic 64-bit Linux ABI (aarch64 and riscv64): it issues __NR_newfstatat with AT_SYMLINK_NOFOLLOW and only for _STAT_VER_KERNEL. 1.4. New 32-bit kABIs with only 64-bit time_t support (arc and riscv32): it issues __NR_statx and covert to struct stat64. 2. Old ABIs with XSTAT_IS_XSTAT64 being 0: 2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL. 2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k, microblaze, s390, sh, mips32, powerpc32, and sparc32): it issues __NR_lstat64. Also, two special cases requires specific LFS implementations: 1. alpha: it requires to handle _STAT_VER_KERNEL64 to issue __NR_lstat64 and use the kernel_stat with __NR_lstat otherwise. 2. mips64: as for non-LFS implementation its ABIs differ from glibc exported one, which requires a specific conversion function to handle the kernel_stat. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Consolidate xstat{64}Adhemerval Zanella2020-09-1120-332/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LFS support is implemented on xstat64.c, instead of xstat.c for 64-bit architectures. The xstat.c implements the non-LFS it is no-op for !XSTAT_IS_XSTAT64. The generic non-LFS implementation handle two cases: 1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and nios): it issues __NR_fstat64 plus handle the overflow on st_ino, st_size, or st_blocks. It only handles _STAT_VER_KERNEL. 2. Old KABIs with old non-LFS support (arm, i386, hppa, m68k, microblaze, s390, sh, powerpc, and sparc32). For _STAT_VER_KERNEL it issues __NR_stat, otherwise it issues __NR_stat64 and convert to non-LFS stat struct handling possible overflows on st_ino, st_size, or st_blocks. Also the non-LFS mips is an outlier and it has its own implementation since _STAT_VER_LINUX requires a different conversion function (it uses the kernel_stat as the syscall argument since its exported ABI is different than the kernel one for both non-LFS and LFS implementation). The generic LFS implementation handles multiple cases: 1. XSTAT_IS_XSTAT64 being 1: 1.1. Old 64-bit kABI (ia64, powerpc64*, s390x, x86_64): it issues __NR_stat for _STAT_VER_KERNEL or _STAT_VER_LINUX. 1.2. Old 64-bit kABI with defines __NR_stat64 instead of __NR_stat (sparc64): it issues __NR_stat for _STAT_VER_KERNEL or __NR_stat64 and convert to struct stat64. 1.3. New kABIs which uses generic 64-bit Linux ABI (aarch64 and riscv64): it issues __NR_newfstatat and only for _STAT_VER_KERNEL. 1.4. New 32-bit kABIs with only 64-bit time_t support (arc and riscv32): it issues __NR_statx and covert to struct stat64. 2. Old ABIs with XSTAT_IS_XSTAT64 being 0: 2.1. New kABIs which uses generic pre 64-bit time Linux ABI (csky and nios2): it issues __NR_fstatat64 for _STAT_VER_KERNEL. 2.2. Old kABIs with old non-LFS support (arm, i386, hppa, m68k, microblaze, s390, sh, mips32, powerpc32, and sparc32): it issues __NR_stat64. Also, two special cases requires specific LFS implementations: 1. alpha: it requires to handle _STAT_VER_KERNEL64 to call __NR_stat64 or use the kernel_stat with __NR_stat otherwise. 2. mips64: as for non-LFS implementation its ABIs differ from glibc exported one, which requires an specific conversion function to handle the kernel_stat. Checked with a build for all affected ABIs. I also checked on x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, and s390x. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Define STAT64_IS_KERNEL_STAT64Adhemerval Zanella2020-09-1113-0/+23
| | | | | | | | | | | It indicates that the glibc export stat64 is similar in size and layout of the kernel stat64 used on the syscall. It is not currently used on stat implementation, but the idea is to indicate whether to use the kernel_stat to issue on the syscall on the *stat*64 variant (more specifically on mips which its exported ABI does not match the kernel). Reviewed-by: Lukasz Majewski <lukma@denx.de>
* linux: Always define STAT_IS_KERNEL_STATAdhemerval Zanella2020-09-1114-7/+15
| | | | | | | | It allows to check for its value instead of its existence. Checked with a build for all affected ABIS. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use LFS readdir in generic POSIX getcwd [BZ# 22899]Adhemerval Zanella2020-09-021-0/+4
| | | | Checked on x86_64-linux-gnu and i686-linux-gnu.
* linux: Remove __ASSUME_ATFCTSAdhemerval Zanella2020-09-021-4/+0
| | | | | | The __have_atfcts is not used anywhere. Checked on x86_64-linux-gnu.
* Sync getcwd with gnulibAdhemerval Zanella2020-09-021-7/+5
| | | | | | | | | | This is the first of a series of patches to sync with Gnulib commit 615b43e1f9. This patch adopts most of the changes of Gnulib, except it retains GETCWD_RETURN_TYPE and does not always use a 64-bit internal API. These remaining discrepancies will be addressed in later patches in this series. Checked on x86_64-linux-gnu and i686-linux-gnu.
* x32: Add <fixup-asm-unistd.h> and regenerate arch-syscall.hH.J. Lu2020-08-312-0/+22
| | | | | | | | | | | | | | | | X32 uses the same 64-bit syscall interface for set_thread_area. But __NR_set_thread_area is missing from <asm/unistd_x32.h>. A kernel patch was submitted: From 7b05d5b43ae2545e0d4a3edb24205d18bc883626 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.tools@gmail.com> Date: Sat, 15 Aug 2020 10:34:00 -0700 Subject: [PATCH] x86-64: Enable x32 set_thread_area X32 uses the common 64-bit syscall interface for set_thread_area. Add <fixup-asm-unistd.h> to provide __NR_set_thread_area. Co-authored-by: Florian Weimer <fweimer@redhat.com>
* RISC-V: Build infrastructure for 32-bit portZong Li2020-08-275-5/+63
| | | | | | | | This patch lays out the top-level organisation of the RISC-V 32-bit port. It provides all the Implies files as well as various other fragments of the build infrastructure. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Add rv32 path to RTLDLIST in lddZong Li2020-08-271-1/+1
| | | | Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* riscv32: Specify the arch_minimum_kernel as 5.4Alistair Francis2020-08-272-0/+8
| | | | | | | | | | Specify the minimum kernel version for RISC-V 32-bit as the 5.4 kernel. We require this commit: "waitid: Add support for waiting for the current process group" for the kernel as it adds support for the P_PGID id for the waitid syscall. Without this patch we can't replace the wait4 syscall on 64-bit time_t only systems. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Add 32-bit ABI listsAlistair Francis2020-08-2713-0/+3336
| | | | | | Use the update-abi Make target to generate the abilist for RV32. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Support the 32-bit ABI implementationAlistair Francis2020-08-271-0/+55
| | | | | | | This patch adds the ABI implementation for 32-bit RISC-V. It contains the Linux-specific and RISC-V architecture code. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Add arch-syscall.h for RV32Alistair Francis2020-08-271-0/+284
| | | | Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Add path of library directories for the 32-bitAlistair Francis2020-08-271-16/+38
| | | | | | | | | | | | | | | | | With RV32 support the list of possible RISC-V system directories increases to: - /lib64/lp64d - /lib64/lp64 - /lib32/ilp32d - /lib32/ilp32 - /lib (only ld.so) This patch changes the add_system_dir () macro to support the new ilp32d and ilp32 directories for RV32. While refactoring this code let's split out the confusing if statements into a loop to make it easier to understand and extend. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Support dynamic loader for the 32-bitZong Li2020-08-271-1/+1
| | | | | | Add the LD_SO_ABI definition for RISC-V 32-bit. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Add support for 32-bit vDSO callsAlistair Francis2020-08-271-6/+17
| | | | Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Use 64-bit-time syscall numbers with the 32-bit portAlistair Francis2020-08-271-0/+23
| | | | | | | | | | | | | | | | | | | sysdep.h redefines only the syscall where the generic implementation still does not have actual 64-bit time_t support: /* Workarounds for generic code needing to handle 64-bit time_t. */ /* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c. */ #define __NR_clock_getres __NR_clock_getres_time64 /* Fix sysdeps/nptl/lowlevellock-futex.h. */ #define __NR_futex __NR_futex_time64 [...] This patch also adds a comment that it is a workaround to handle 64-bit time_t and on each #define comment for which implementation it intends to. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>
* RISC-V: Cleanup some of the sysdep.h codeAlistair Francis2020-08-271-13/+4
| | | | | | | | Remove a duplicate inclusion of <sysdeps/unix/sysdep.h> which is already pulled via <sysdeps/unix/sysv/linux/generic/sysdep.h>, and the inclusion of <errno.h> whose definition of `__set_errno' is not needed here. Reviewed-by: Maciej W. Rozycki <macro@wdc.com>