about summary refs log tree commit diff
path: root/arch
Commit message (Collapse)AuthorAgeFilesLines
* fix __WORDSIZE on x32 sys/user.hRich Felker2022-03-081-1/+1
| | | | | | sys/reg.h already had it right as 32, to which it was explicitly changed when commit 664cd341921007cea52c8891f27ce35927dca378 derived x32 from x86_64. but the copy exposed in sys/user.h was missed.
* bits/syscall.h: add landlock syscalls from linux v5.13Szabolcs Nagy2022-03-0816-0/+48
| | | | | | | | | | | | | | | | | see linux commit a49f4f81cb48925e8d7cbd9e59068f516e984144 arch: Wire up Landlock syscalls linuxcommit 17ae69aba89dbfa2139b7f8024b757ab3cc42f59 Merge tag 'landlock_v34' of ... jmorris/linux-security Landlock provides for unprivileged application sandboxing. The goal of Landlock is to enable to restrict ambient rights (e.g. global filesystem access) for a set of processes. Landlock is inspired by seccomp-bpf but instead of filtering syscalls and their raw arguments, a Landlock rule can restrict the use of kernel objects like file hierarchies, according to the kernel semantic.
* s390x: add ptrace requests from linux v5.12Szabolcs Nagy2022-03-081-0/+3
| | | | | | | | PTRACE_OLDSETOPTIONS is old, but it was missing, PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP are new, see linux commit 56e62a73702836017564eaacd5212e4d0fa1c01d s390: convert to generic entry
* bits/syscall.h: add mount_setattr from linux v5.12Szabolcs Nagy2022-03-0816-0/+16
| | | | | | | | new syscall to change the properties of a mount or a mount tree using file descriptors which the new mount api is based on, see linux commit 2a1867219c7b27f928e2545782b86daaf9ad50bd fs: add mount_setattr()
* bits/syscall.h: add epoll_pwait2 from linux v5.11Szabolcs Nagy2022-03-0816-0/+16
| | | | | | | | | | | | see linux commit b0a0c2615f6f199a656ed8549d7dce625d77aa77 epoll: wire up syscall epoll_pwait2 linux commit 58169a52ebc9a733aeb5bea857bc5daa71a301bb epoll: add syscall epoll_pwait2 epoll_wait with struct timespec timeout instead of int. no time32 variant.
* add SPE FPU support to powerpc-sfRich Felker2021-09-232-2/+2
| | | | | | | | | | | | | | | | | | | When the soft-float ABI for PowerPC was added in commit 5a92dd95c77cee81755f1a441ae0b71e3ae2bcdb, with Freescale cpus using the alternative SPE FPU as the main use case, it was noted that we could probably support hard float on them, but that it would involve determining some difficult ABI constraints. This commit is the completion of that work. The Power-Arch-32 ABI supplement defines the ABI profiles, and indeed ATR-SPE is built on ATR-SOFT-FLOAT. But setjmp/longjmp compatibility are problematic for the same reason they're problematic on ARM, where optional float-related parts of the register file are "call-saved if present". This requires testing __hwcap, which is now done. In keeping with the existing powerpc-sf subarch definition, which did not have fenv, the fenv macros are not defined for SPE and the SPEFSCR control register is left (and assumed to start in) the default mode.
* fix excessively slow TLS performance on some mips modelsRich Felker2021-08-121-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | commit 6d99ad91e869aab35a4d76d34c3c9eaf29482bad introduced this regression as part of a larger change, based on an incorrect assumption that rdhwr being part of the mips r2 ISA level meant that the TLS register, known in the mips documentation as UserLocal, was unconditionally present on chips providing this ISA level and would not need trap-and-emulate. this turns out to be false. based on research by Stanislav Kljuhhin and Abilio Marques, who reported the problem as a performance regression on certain routers using OpenWRT vs older uclibc-based versions, it turns out the mips manuals document the UserLocal register as a feature that might or might not be implemented or enabled, reflected by a cpu capability bit in the CONFIG3 register, and that Linux checks for this and has to explicitly enable it on models that have it. thus, it's indeed possible that r2+ chips can lack the feature, bringing us back to the situation where Linux only has a fast trap-and-emulate path for the case where the destination register is $3. so, always read the thread pointer through $3. this may incur a gratuitous move to the desired final register on chips where it's not needed, but it really doesn't matter.
* fix broken struct shmid_ds on powerpc (32-bit)Rich Felker2021-07-061-1/+1
| | | | | | | | | | | | | | | | | the kernel structure has padding of the shm_segsz member up to 64 bits, as well as 2 unused longs at the end. somehow that was overlooked when the powerpc port was added, and it has been broken ever since; applications compiled with the wrong definition do not correctly see the shm_segsz, shm_cpid, and shm_lpid members. fixing the definition just by adding the missing padding would break the ABI size of the structure as well as the position of the time64 shm_atime and shm_dtime members we added at the end. instead, just move one of the unused padding members from the original end (before time64) of the structure to the position of the missing padding. this preserves size and preserves correct behavior of any compiled code that was already working. programs affected by the wrong definition need to be recompiled with the correct one.
* riscv: rename __NR_fstatat __NR_newfstatatKhem Raj2021-06-051-1/+1
| | | | | | on riscv64 this syscall is called __NR_newfstatat this helps the name match kernel UAPI for external programs
* aarch64/bits/mman.h: add PROT_MTE from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | see linux commit 9f3419315f3cdc41a7318e4d50ba18a592b30c8c arm64: mte: Add PROT_MTE support to mmap() and mprotect()
* aarch64/bits/hwcap.h: add HWCAP2_MTE from linux v5.10Szabolcs Nagy2021-02-151-0/+1
| | | | | | | see linux commit 3b714d24ef173f81c78af16f73dcc9b40428c803 arm64: mte: CPU feature detection and initial sysreg configuration
* add aarch64/bits/mman.h with PROT_BTI from linux v5.8Szabolcs Nagy2021-02-151-0/+1
| | | | | | | this was missing, see linux commit 8ef8f360cf30be12382f89ff48a57fbbd9b31c14 arm64: Basic Branch Target Identification support
* aarch64/bits/hwcap.h: add HWCAP2_BTI from linux v5.8Szabolcs Nagy2021-02-151-0/+1
| | | | | | | hwcap for BTI was missing, see linux commit 8ef8f360cf30be12382f89ff48a57fbbd9b31c14 arm64: Basic Branch Target Identification support
* bits/syscall.h: add process_madvise from linux v5.10Szabolcs Nagy2021-02-1516-0/+16
| | | | | | | | | mainly added to linux to allow a central process management service in android to give MADV_COLD|PAGEOUT hints for other processes, see linux commit ecb8ac8b1f146915aa6b96449b66dd48984caacc mm/madvise: introduce process_madvise() syscall: an external memory hinting API
* riscv64: define ELF_NFPREGKhem Raj2021-02-121-0/+1
| | | | ELF_NFPREG is used by some userspace applications like gdb
* sh: fix incorrect mcontext_t member namingAriadne Conill2020-12-122-4/+13
| | | | | while the layouts match, the member member naming expected by software using mcontext_t omits the sc_ prefix.
* riscv64: fix inconsistent ucontext_t struct tagDrew DeVault2020-12-061-2/+2
| | | | | | ucontext.h depends on the internal struct tag name for namespacing reasons, and the intent was always for it to be consistent across archs anyway.
* s390x: derive float_t from compiler or default to floatMarius Hillenbrand2020-12-032-1/+9
| | | | | | | | | | | | | | | | | | | float_t should represent the type that is used to evaluate float expressions internally. On s390x, float_t is currently set to double. In contrast, the isa supports single-precision float operations and compilers by default evaluate float in single precision, which violates the C standard (sections 5.2.4.2.2 and 7.12 in C11/C17, to be precise). With -fexcess-precision=standard, gcc evaluates float in double precision, which aligns with the standard yet at the cost of added conversion instructions. gcc-11 will drop the special case to retrofit double precision behavior for -fexcess-precision=standard so that __FLT_EVAL_METHOD__ will be 0 on s390x in any scenario. To improve standards compliance and compatibility with future compiler direction, this patch changes the definition of float_t to be derived from the compiler's __FLT_EVAL_METHOD__.
* bits/syscall.h: add __NR_close_range from linux v5.9Szabolcs Nagy2020-11-2916-0/+16
| | | | | | | | | | see linux commit 9b4feb630e8e9801603f3cab3a36369e3c1cf88d arch: wire-up close_range() linux commit 278a5fbaed89dacd04e9d052f4594ffd0e0585de open: add close_range()
* fix vector types in aarch64 register file structuresRich Felker2020-11-112-3/+3
| | | | | | | | | | the ABI type for the vector registers in fpregset_t, struct fpsimd_context, and struct user_fpsimd_struct is __uint128_t, which was presumably originally not used because it's a nonstandard type, but its existence is mandated by the aarch64 psABI. use of the wrong type here broke software using these structures, and encouraged incorrect fixes with casts rather than reinterpretation of representation.
* bits/syscall.h: add __NR_faccessat2 from linux v5.8Szabolcs Nagy2020-09-0916-0/+16
| | | | | | | | the linux faccessat syscall lacks a flag argument that is necessary to implement the posix api, see linux commit c8ffd8bcdd28296a198f237cc595148a8d4adfbe vfs: add faccessat2 syscall
* aarch64: add new HWCAP2_ macros from linux v5.6Szabolcs Nagy2020-09-091-0/+8
| | | | | | | | | | added in linux commit 1a50ec0b3b2e9a83f1b1245ea37a853aac2f741c arm64: Implement archrandom.h for ARMv8.5-RNG linux commit d4209d8b717311d114b5d47ba7f8249fd44e97c2 arm64: cpufeature: Export matrix and other features to userspace
* aarch64: add HWCAP2_ macros from linux v5.3Szabolcs Nagy2020-09-091-0/+2
| | | | | | | | | | these were missed before, added in linux commit 1201937491822b61641c1878ebcd16a93aed4540 arm64: Expose ARMv8.5 CondM capability to userspace linux commit ca9503fc9e9812aa6258e55d44edb03eb30fc46f arm64: Expose FRINT capabilities to userspace
* add pidfd_getfd and openat2 syscall numbers from linux v5.6Szabolcs Nagy2020-09-0916-0/+34
| | | | | | | | | | | | | | | | | | | also added clone3 on sh and m68k, on sh it's still missing (not yet wired up), but reserved so safe to add. see linux commit fddb5d430ad9fa91b49b1d34d0202ffe2fa0e179 open: introduce openat2(2) syscall linux commit 9a2cef09c801de54feecd912303ace5c27237f12 arch: wire up pidfd_getfd syscall linux commit 8649c322f75c96e7ced2fec201e123b2b073bf09 pid: Implement pidfd_getfd syscall linux commit e8bb2a2a1d51511e6b3f7e08125d52ec73c11139 m68k: Wire up clone3() syscall
* use generic bits/fcntl.h for x86_64 and riscv64Rich Felker2020-09-032-78/+0
| | | | | these were only using a custom version because they needed the "non-64" variants of the file locking command macros.
* make generic bits/fcntl.h shareable with 64-bit archsRich Felker2020-09-031-0/+6
| | | | | | | | | | | the fcntl file locking command macro values in the existing generic bits/fcntl.h were the "64" variants, requiring 64-bit archs that use the "plain" variants to have their own bits/fcntl.h, even if they otherwise use the common definitions for everything. since commit 7cc79d10afd43811a486fd5e9fcdf8e45ac599e0 exposed __LONG_MAX to all bits headers, we can now make the generic one common between 32- and 64-bit archs.
* fix missing O_LARGEFILE values on x86_64, x32, and mips64Rich Felker2020-09-033-3/+3
| | | | | | | | | | | | | | | | | prior to commit 685e40bb09f5f24a2af54ea09c97328808f76990, x86_64 was correctly passing O_LARGEFILE to SYS_open; it was removed (defined to 0 in the public header, and changed to use the public definition) as part of that change, probably out of a mistaken belief that it's not needed. however, on a mixed system with 32-bit and 64-bit binaries, it's important that all files be opened with O_LARGEFILE, even if the opening process is 64-bit, in case a descriptor is passed to a 32-bit process. otherwise, attempts to access past 2GB in the 32-bit process could produce EOVERFLOW. most 64-bit archs added later got this right alread, except for mips64. x32 was also affected. there are now fixed.
* remove redundant pthread struct members repeated for layout purposesRich Felker2020-08-273-5/+1
| | | | | | | dtv_copy, canary2, and canary_at_end existed solely to match multiple ABI and asm-accessed layouts simultaneously. now that pthread_arch.h can be included before struct __pthread is defined, the struct layout can depend on macros defined by pthread_arch.h.
* deduplicate __pthread_self thread pointer adjustment out of each archRich Felker2020-08-2716-65/+63
| | | | | | | | | | | | | | | | the adjustment made is entirely a function of TLS_ABOVE_TP and TP_OFFSET. aside from avoiding repetition of the TP_OFFSET value and arithmetic, this change makes pthread_arch.h independent of the definition of struct __pthread from pthread_impl.h. this in turn will allow inclusion of pthread_arch.h to be moved to the top of pthread_impl.h so that it can influence the definition of the structure. previously, arch files were very inconsistent about the type used for the thread pointer. this change unifies the new __get_tp interface to always use uintptr_t, which is the most correct when performing arithmetic that may involve addresses outside the actual pointed-to object (due to TP_OFFSET).
* deduplicate TP_ADJ logic out of each arch, replace with TP_OFFSETRich Felker2020-08-2416-21/+6
| | | | | | the only part of TP_ADJ that was not uniquely determined by TLS_ABOVE_TP was the 0x7000 adjustment used mainly on mips and powerpc variants.
* prefer new socket syscalls, fallback to SYS_socketcall only if neededRich Felker2020-08-085-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | a number of users performing seccomp filtering have requested use of the new individual syscall numbers for socket syscalls, rather than the legacy multiplexed socketcall, since the latter has the arguments all in memory where they can't participate in filter decisions. previously, some archs used the multiplexed socketcall if it was historically all that was available, while other archs used the separate syscalls. the intent was that the latter set only include archs that have "always" had separate socket syscalls, at least going back to linux 2.6.0. however, at least powerpc, powerpc64, and sh were wrongly included in this set, and thus socket operations completely failed on old kernels for these archs. with the changes made here, the separate syscalls are always preferred, but fallback code is compiled for archs that also define SYS_socketcall. two such archs, mips (plain o32) and microblaze, define SYS_socketcall despite never having needed it, so it's now undefined by their versions of syscall_arch.h to prevent inclusion of useless fallback code. some archs, where the separate syscalls were only added after the addition of SYS_accept4, lack SYS_accept. because socket calls are always made with zeros in the unused argument positions, it suffices to just use SYS_accept4 to provide a definition of SYS_accept, and this is done to make happy the macro machinery that concatenates the socket call name onto __SC_ and SYS_.
* fix incorrect SIGSTKFLT on all mips archsRich Felker2020-05-213-3/+3
| | | | | | signal 7 is SIGEMT on Linux mips* ABI according to the man pages and kernel. it's not clear where the wrong name came from but it dates back to original mips commit.
* remove arm (32-bit) support for vdso clock_gettimeRich Felker2020-04-261-6/+0
| | | | | | | | | | | | | | | | | | | it's been reported that the vdso clock_gettime64 function on (32-bit) arm is broken, producing erratic results that grow at a rate far greater than one reported second per actual elapsed second. the vdso function seems to have been added sometime between linux 5.4 and 5.6, so if there's ever been a working version, it was only present for a very short window. it's not clear what the eventual upstream kernel solution will be, but something needs to be done on the libc side so as not to be producing binaries that seem to work on older/existing/lts kernels (which lack the function and thus lack the bug) but will break fantastically when moving to newer kernels. hopefully vdso support will be added back soon, but with a new symbol name or version from the kernel to allow continued rejection of broken ones.
* define MAP_SYNC on powerpc/powerpc64Samuel Holland2020-03-142-2/+0
| | | | | | Linux defines MAP_SYNC on powerpc and powerpc64 as of commit 22fcea6f85f2 ("mm: move MAP_SYNC to asm-generic/mman-common.h"), so we can stop undefining it on those architectures.
* work around negated error code bug on some mips kernelsRich Felker2020-03-143-22/+22
| | | | | | | | | | | | on all mips variants, Linux did (and maybe still does) have some syscall return paths that wrongly return both the error flag in r7 and a negated error code in r2. in particular this happened for at least some causes of ENOSYS. add an extra check to only negate the error code if it's positive to begin with. bug report and concept for patch by Andreas Dröscher.
* remove useless mips syscall asm constraint, align style with mips64/n32Rich Felker2020-03-141-15/+16
| | | | | | | | | | | | | | | | | | commit 4221f154ff29ab0d6be1e7beaa5ea2d1731bc58e added the r7 constraint apparently out of a misunderstanding of the breakage it was addressing, and did so because the asm was in a shared macro used by all the __syscallN inline functions. now "+r" is used in the output section for the forms 4-argument and up, so having it in input is redundant, and the forms with 0-3 arguments don't need it as an input at all. the r2 constraint is kept because without it most gcc versions (seems to be all prior to 9.x) fail to honor the output register binding for r2. this seems to be a variant of gcc bug #87733. both the r7 and r2 input constraints look useless, but the r2 one was a quiet workaround for gcc bug 87733, which affects all modern versions prior to 9.x, so it's kept and documented.
* revert mips (32-bit, o32) syscall asm clean-up due to regressionsRich Felker2020-03-141-32/+31
| | | | | | | | | | exactly revert commit 604f8d3d8b08ee4f548de193050ef93a7753c2e0 which was wrong; it caused a major regression on Linux versions prior to 2.6.36. old kernels did not properly preserve r2 across syscall restart, and instead restarted with the instruction right before syscall, imposing a contract that the previous instruction must load r2 from an immediate or a register (or memory) not clobbered by the syscall.
* revert mips64/n32 syscall asm clean-up due to regressionsRich Felker2020-03-142-56/+61
| | | | | | | | | | | | | | | | | | | | | | effectivly revert commit ddc7c4f936c7a90781072f10dbaa122007e939d0 which was wrong; it caused a major regression on Linux versions prior to 2.6.36. old kernels did not properly preserve r2 across syscall restart, and instead restarted with the instruction right before syscall, imposing a contract that the previous instruction must load r2 from an immediate or a register (or memory) not clobbered by the syscall. since other changes were made since, including removal of the struct stat conversion that was replaced by separate struct kstat, this is not a direct revert, only a functional one. the "0"(r2) input constraint added back seems useless/erroneous, but without it most gcc versions (seems to be all prior to 9.x) fail to honor the output register binding for r2. this seems to be a variant of gcc bug #87733. further changes should be made later if a better workaround is found, but this one has been working since 2012. it seems this issue was encountered but misidentified then, when it inspired commit 4221f154ff29ab0d6be1e7beaa5ea2d1731bc58e.
* remove legacy time32 timer[fd] syscalls from public syscall.hRich Felker2020-02-059-36/+36
| | | | | | | this extends commit 5a105f19b5aae79dd302899e634b6b18b3dcd0d6, removing timer[fd]_settime and timer[fd]_gettime. the timerfd ones are likely to have been used in software that started using them before it could rely on libc exposing functions.
* remove further legacy time32 clock syscalls from public syscall.hRich Felker2020-02-059-36/+36
| | | | | this extends commit 5a105f19b5aae79dd302899e634b6b18b3dcd0d6, removing clock_settime, clock_getres, clock_nanosleep, and settimeofday.
* move riscv64 register index constants to signal.hRich Felker2020-02-042-6/+9
| | | | | | under _GNU_SOURCE for namespace cleanliness, analogous to other archs. the original placement in sys/reg.h seems not to have been motivated; such a header isn't even present on other implementations.
* remove legacy clock_gettime and gettimeofday from public syscall.hRich Felker2020-01-309-18/+18
| | | | | | | | | | | | | | | | | | | | | | | some nontrivial number of applications have historically performed direct syscalls for these operations rather than using the public functions. such usage is invalid now that time_t is 64-bit and these syscalls no longer match the types they are used with, and it was already harmful before (by suppressing use of vdso). since syscall() has no type safety, incorrect usage of these syscalls can't be caught at compile-time. so, without manually inspecting or running additional tools to check sources, the risk of such errors slipping through is high. this patch renames the syscalls on 32-bit archs to clock_gettime32 and gettimeofday_time32, so that applications using the original names will fail to build without being fixed. note that there are a number of other syscalls that may also be unsafe to use directly after the time64 switchover, but (1) these are the main two that seem to be in widespread use, and (2) most of the others continue to have valid usage with a null timeval/timespec argument, as the argument is an optional timeout or similar.
* move struct dirent to bits header, allow NAME_MAX to varyRich Felker2020-01-251-0/+11
| | | | | | this is not necessary for linux but is a simple, inexpensive change to make that facilitates ports to systems where NAME_MAX needs to be longer.
* fix riscv64 a_cas inline asm operand sign extensionLuís Marques2020-01-221-1/+1
| | | | | | | | This patch adds an explicit cast to the int arguments passed to the inline asm used in the RISC-V's implementation of `a_cas`, to ensure that they are properly sign extended to 64 bits. They aren't automatically sign extended by Clang, and GCC technically also doesn't guarantee that they will be sign extended.
* mips: add clone3 syscall numbers from linux v5.4Szabolcs Nagy2019-12-303-0/+3
| | | | | | | the syscall numbers were reserved in v5.3 but not wired up on mips, see linux commit 0671c5b84e9e0a6d42d22da9b5d093787ac1c5f3 MIPS: Wire up clone3 syscall
* mips: add hwcap bits from linux v5.4Szabolcs Nagy2019-12-301-0/+11
| | | | | | | | mips application specific isa extensions were previously not exported in hwcaps so userspace could not apply optimized code at runtime. linux commit 38dffe1e4dde1d3174fdce09d67370412843ebb5 MIPS: elf_hwcap: Export userspace ASEs
* add clone3 syscall number from linux v5.3Szabolcs Nagy2019-12-3011-0/+12
| | | | | | | | | | | | | | the syscall number is reserved on all targets, but it is not wired up on all targets, see linux commit 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 Merge tag 'clone3-v5.3' of ... brauner/linux linux commit 8f3220a806545442f6f26195bc491520f5276e7c arch: wire-up clone3() syscall linux commit 7f192e3cd316ba58c88dfa26796cf77789dd9872 fork: add clone3
* add pidfd_open syscall number from linux v5.3Szabolcs Nagy2019-12-3016-0/+16
| | | | | | | | | | see linux commit 7615d9e1780e26e0178c93c55b73309a5dc093d7 arch: wire-up pidfd_open() linux commit 32fcb426ec001cb6d5a4a195091a8486ea77e2df pid: add pidfd_open()
* fix types for mips sigcontext/mcontext_t regset membersKhem Raj2019-12-301-2/+6
|
* fix build regression on mips64 due to endian.h removalRich Felker2019-11-051-0/+2
| | | | | | | | | | | | | | | | commit 4d3a162d001a93edd285fb6603a883c30ae553ba overlooked that the mips64 reloc.h dependent on endian.h not only for setting the ABI ldso name to match the byte order, but also for use of the byte swapping macros. they are needed to override R_TYPE, R_SYM, and R_INFO, to compensate for a mips "quirk" of always using big endian order for symbol references in relocations. part of that commit canot be reverted because the original code was wrong: it's invalid to define _GNU_SOURCE or any feature test macro in reloc.h, or anywhere except at the top of a source file. however, thanks to commit 316730cdc7a330cddf288b4e5c1de5daa64e19f4, the feature test macro is no longer needed to access the endian-swapping macros, so simply bringing back the #include directive suffices.