summaryrefslogtreecommitdiff
path: root/arch
AgeCommit message (Collapse)AuthorLines
2020-11-11fix vector types in aarch64 register file structuresRich Felker-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.
2020-09-09bits/syscall.h: add __NR_faccessat2 from linux v5.8Szabolcs Nagy-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
2020-09-09aarch64: add new HWCAP2_ macros from linux v5.6Szabolcs Nagy-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
2020-09-09aarch64: add HWCAP2_ macros from linux v5.3Szabolcs Nagy-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
2020-09-09add pidfd_getfd and openat2 syscall numbers from linux v5.6Szabolcs Nagy-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
2020-09-03use generic bits/fcntl.h for x86_64 and riscv64Rich Felker-78/+0
these were only using a custom version because they needed the "non-64" variants of the file locking command macros.
2020-09-03make generic bits/fcntl.h shareable with 64-bit archsRich Felker-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.
2020-09-03fix missing O_LARGEFILE values on x86_64, x32, and mips64Rich Felker-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.
2020-08-27remove redundant pthread struct members repeated for layout purposesRich Felker-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.
2020-08-27deduplicate __pthread_self thread pointer adjustment out of each archRich Felker-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).
2020-08-24deduplicate TP_ADJ logic out of each arch, replace with TP_OFFSETRich Felker-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.
2020-08-08prefer new socket syscalls, fallback to SYS_socketcall only if neededRich Felker-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_.
2020-05-21fix incorrect SIGSTKFLT on all mips archsRich Felker-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.
2020-04-26remove arm (32-bit) support for vdso clock_gettimeRich Felker-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.
2020-03-14define MAP_SYNC on powerpc/powerpc64Samuel Holland-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.
2020-03-14work around negated error code bug on some mips kernelsRich Felker-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.
2020-03-14remove useless mips syscall asm constraint, align style with mips64/n32Rich Felker-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.
2020-03-14revert mips (32-bit, o32) syscall asm clean-up due to regressionsRich Felker-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.
2020-03-14revert mips64/n32 syscall asm clean-up due to regressionsRich Felker-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.
2020-02-05remove legacy time32 timer[fd] syscalls from public syscall.hRich Felker-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.
2020-02-05remove further legacy time32 clock syscalls from public syscall.hRich Felker-36/+36
this extends commit 5a105f19b5aae79dd302899e634b6b18b3dcd0d6, removing clock_settime, clock_getres, clock_nanosleep, and settimeofday.
2020-02-04move riscv64 register index constants to signal.hRich Felker-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.
2020-01-30remove legacy clock_gettime and gettimeofday from public syscall.hRich Felker-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.
2020-01-25move struct dirent to bits header, allow NAME_MAX to varyRich Felker-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.
2020-01-22fix riscv64 a_cas inline asm operand sign extensionLuís Marques-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.
2019-12-30mips: add clone3 syscall numbers from linux v5.4Szabolcs Nagy-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
2019-12-30mips: add hwcap bits from linux v5.4Szabolcs Nagy-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
2019-12-30add clone3 syscall number from linux v5.3Szabolcs Nagy-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
2019-12-30add pidfd_open syscall number from linux v5.3Szabolcs Nagy-0/+16
see linux commit 7615d9e1780e26e0178c93c55b73309a5dc093d7 arch: wire-up pidfd_open() linux commit 32fcb426ec001cb6d5a4a195091a8486ea77e2df pid: add pidfd_open()
2019-12-30fix types for mips sigcontext/mcontext_t regset membersKhem Raj-2/+6
2019-11-05fix build regression on mips64 due to endian.h removalRich Felker-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.
2019-11-02move time_t and suseconds_t definitions to common alltypes.h.inRich Felker-48/+0
now that all 32-bit archs have 64-bit time_t (and suseconds_t), the arch-provided _Int64 macro (long or long long, as appropriate) can be used to define them, and arch-specific definitions are no longer needed.
2019-11-02move time64 ioctl numbers to generic bits/ioctl.hRich Felker-21/+5
now that all 32-bit archs have 64-bit time types, the values for the time-related ioctls can be shared. the mechanism for this is an arch/generic version of the bits header. archs which don't use the generic header still need to duplicate the definitions. x32, which does not use the new time64 values of the macros, already has its own overrides, so this commit does not affect it.
2019-11-02move time64 socket options from arch bits to top-level sys/socket.hRich Felker-45/+0
now that all 32-bit archs have 64-bit time types, the values for the time-related socket option macros can be treated as universal for 32-bit archs. the sys/socket.h mechanism for this predates arch/generic and is instead in the top-level header. x32, which does not use the new time64 values of the macros, already has its own overrides, so this commit does not affect it.
2019-11-02switch all existing 32-bit archs to 64-bit time_tRich Felker-217/+420
this commit preserves ABI fully for existing interface boundaries between libc and libc consumers (applications or libraries), by retaining existing symbol names for the legacy 32-bit interfaces and redirecting sources compiled against the new headers to alternate symbol names. this does not necessarily, however, preserve the pairwise ABI of libc consumers with one another; where they use time_t-derived types in their interfaces with one another, it may be necessary to synchronize updates with each other. the intent is that ABI resulting from this commit already be stable and permanent, but it will not be officially so until a release is made. changes to some header-defined types that do not play any role in the ABI between libc and its consumers may still be subject to change. mechanically, the changes made by this commit for each 32-bit arch are as follows: - _REDIR_TIME64 is defined to activate the symbol redirections in public headers - COMPAT_SRC_DIRS is defined in arch.mak to activate build of ABI compat shims to serve as definitions for the original symbol names - time_t and suseconds_t definitions are changed to long long (64-bit) - IPC_STAT definition is changed to add the IPC_TIME64 bit (0x100), triggering conversion of semid_ds, shmid_ds, and msqid_ds split low/high time bits into new time_t members - structs semid_ds, shmid_ds, msqid_ds, and stat are modified to add new 64-bit time_t/timespec members at the end, maintaining existing layout of other members. - socket options (SO_*) and ioctl (sockios) command macros are redefined to use the kernel's "_NEW" values. in addition, on archs where vdso clock_gettime is used, the VDSO_CGT_SYM macro definition in syscall_arch.h is changed to use a new time64 vdso function if available, and a new VDSO_CGT32_SYM macro is added for use as fallback on kernels lacking time64.
2019-11-02add x32 bits/ioctl_fix.h defining time-related sockios macrosRich Felker-0/+4
these definitions are copied from generic bits/ioctl.h, so that x32 keeps the "_OLD" versions (which are already time64 on x32) when 32-bit archs switch to 64-bit time_t.
2019-11-02add back x32 bits/socket.h defining time-related socket optionsRich Felker-0/+5
these definitions are merely copied from the top-level sys/socket.h, so there is no functional change at this time. however, the top-level definitions will change to use the time64 "_NEW" versions on 32-bit archs when time_t is switched over to 64-bit. this commit ensures that change will be suppressed on x32.
2019-11-02move msghdr and cmsghdr out of bits/socket.hRich Felker-208/+0
these structures can now be defined generically in terms of endianness and long size. previously, the 32-bit archs all shared a common definition from the generic bits header, and each 64-bit arch had to repeat the 64-bit version, with endian conditionals if the arch had variants of each endianness. I would prefer getting rid of the preprocessor conditionals for padding and instead using unnamed bitfield members, like commit 9b2921bea1d5017832e1b45d1fd64220047a9802 did for struct timespec. however, at present sendmsg, recvmsg, and recvmmsg need access to the padding members by name to zero them. this could perhaps be cleaned up in the future.
2019-11-02fix x32 msghdr struct by removing x32 bits/socket.hRich Felker-16/+0
being that it contains pointers and (from the kernel perspective, which is wrong) size_t members, x32 uses the 32-bit version of the structure, not a half-32-bit, half-64-bit layout like we had here. the x86_64 definition was inadvertently copied when x32 was first added. unlike errors in the opposite direction (missing padding), this error was not easily detected breakage, because the layout of the commonly used initial subset of members still matched. breakage could only be observed in the presence of control messages or flags.
2019-10-28add missing m68k user.h/procfs.h regset typesRich Felker-0/+5
2019-10-19internally, define time64 rusage syscalls on x32 as the existing onesRich Felker-0/+2
this is analogous to commit 40aa18d55ab763e69ad16d0cf1cebea708ffde47. so far, there are not any actual time64 versions of the rusage syscalls (getrusage and wait4) and might never be. however, the existing x32 ones behave the way time64 versions would if they existed: using 64-bit slots in place of all longs. presently, wait4 and getrusage are broken on x32, storing the timevals correctly but messing up everything else due to the long/kernel-long mismatch. this would be a huge buffer overflow if not for the 16 reserved slots we left long ago, which suffice to prevent 14 double-sized longs from overflowing into unrelated memory. this commit will make it possible to fix them.
2019-10-19use struct pt_regs * rather than void * for powerpc[64] sigcontext regsRich Felker-2/+2
this is to match the kernel and glibc interfaces. here, struct pt_regs is an incomplete type, but that's harmless, and if it's completed by inclusion of another header then members of the struct pointed to by the regs member can be accessed directly without going through a cast or intermediate pointer object.
2019-10-19fix fpregset_t type on powerpc64Rich Felker-5/+1
the userspace ucontext API has this as an array rather than a structure. commit 3c59a868956636bc8adafb1b168d090897692532 fixed the corresponding mistake for vrregset_t, namely that the original powerpc64 port used a mix of types from 32-bit powerpc and powerpc64 rather than matching the 64-bit types.
2019-10-17move pthread types out of per-arch alltypes.hRich Felker-128/+0
policy has long been that these definitions are purely a function of whether long/pointer is 32- or 64-bit, and that they are not allowed to vary per-arch. move the definition to the shared alltypes.h.in fragment, using integer constant expressions in terms of sizeof to vary the array dimensions appropriately. I'm not sure whether this is more or less ugly than using preprocessor conditionals and two sets of definitions here, but either way is a lot less ugly than repeating the same thing for every arch.
2019-10-17define LONG_MAX via arch alltypes.h, strip down bits/limits.hRich Felker-112/+24
LLONG_MAX is uniform for all archs we support and plenty of header and code level logic assumes it is, so it does not make sense for limits.h bits mechanism to pretend it's variable. LONG_BIT can be defined in terms of LONG_MAX; there's no reason to put it in bits. by moving LONG_MAX definition to __LONG_MAX in alltypes.h and moving LLONG_MAX out of bits, there are now no plain-C limits that are defined in the bits header, so the bits header only needs to be included in the POSIX or extended profiles. this allows the feature test macro logic to be removed from the bits header, facilitating a long-term goal of getting such logic out of bits. having __LONG_MAX in alltypes.h will allow further generalization of headers. archs without a constant PAGESIZE no longer need bits/limits.h at all.
2019-10-17remove use of endian.h from arch reloc.h headers, clean upRich Felker-24/+0
building on commit 97d35a552ec5b6ddf7923dd2f9a8eb973526acea, __BYTE_ORDER is now available wherever alltypes.h is included. since reloc.h is only used from src/internal/dynlink.h, it can be assumed that __BYTE_ORDER is exposed. reloc.h is not permitted to be included in other contexts, and generally, like most arch headers, lacks inclusion guards that would allow such usage. the mips64 version mistakenly included such guards; they are removed for consistency.
2019-10-17remove indirect use of endian.h from public headersRich Felker-8/+0
building on commit 97d35a552ec5b6ddf7923dd2f9a8eb973526acea, __BYTE_ORDER is now available wherever alltypes.h is included. endian.h should not be used since, in the future, it will expose identifiers that are not in the reserved namespace for the headers which were previously using it.
2019-10-17move __BYTE_ORDER definition to alltypes.hRich Felker-62/+64
this change is motivated by the intersection of several factors. presently, despite being a nonstandard header, endian.h is exposing the unprefixed byte order macros and functions only if _BSD_SOURCE or _GNU_SOURCE is defined. this is to accommodate use of endian.h from other headers, including bits headers, which need to define structure layout in terms of endianness. with time64 switch-over, even more headers will need to do this. at the same time, the resolution of Austin Group issue 162 makes endian.h a standard header for POSIX-future, requiring that it expose the unprefixed macros and the functions even in standards-conforming profiles. changes to meet this new requirement would break existing internal usage of endian.h by causing it to violate namespace where it's used. instead, have the arch's alltypes.h define __BYTE_ORDER, either as a fixed constant or depending on the right arch-specific predefined macros for determining endianness. explicit literals 1234 and 4321 are used instead of __LITTLE_ENDIAN and __BIG_ENDIAN so that there's no danger of getting the wrong result if a macro is undefined and implicitly evaluates to 0 at the preprocessor level. the powerpc (32-bit) bits/endian.h being removed had logic for varying endianness, but our powerpc arch has never supported that and has always been big-endian-only. this logic is not carried over to the new __BYTE_ORDER definition in alltypes.h.
2019-10-17remove per-arch definitions for va_listRich Felker-48/+0
now that commit f7f1079796abc6f97c69521d2334e9c7d3945dd8 removed the legacy i386 conditional definition, va_list is in no way arch-specific, and has no reason to be in the future. move it to the shared part of alltypes.h.in
2019-10-17remove i386 support for legacy struct __va_listRich Felker-5/+0
commit ffaaa6d230512f3a7f3d040b943517728f3dc3cf removed the corresponding stdarg.h support for compilers without va_list builtins, but failed to remove the alternate type definition, leaving incorrect va_list definitions in place with compilers that don't define __GNUC__ with a value >= 3.