758 Commits
Author SHA1 Message Date
sisungo 1c8ee1fa29 feat: update upstream musl libc to v1.2.6 2026-06-27 13:16:53 +08:00
Xing LiandRich Felker 9355c44311 loongarch64: add lsx and lasx regset definition 2026-03-12 21:21:50 -04:00
JianTao ShanandRich Felker b5146b83ab loongarch64: add fpu and simd context to signal.h
The signal stack extension field of loongarch64 is mutable, and the
types are distinguished according to some magic.
2026-03-12 20:39:22 -04:00
Szabolcs NagyandRich Felker 5c901bb360 update syscalls up to linux 6.19
Add two missing syscalls from v5.14 and new syscalls from v6.4 .. v6.19

add __NR_quotactl_fd from linux v5.14 see

  linux commit 9dfa23c8de925041b7b45637a1a80a98a22f19dd
  quota: Add mountpath based quota support

  linux commit fa8b90070a80bb1a3042b4b25af4b3ee2c4c27e1
  quota: wire up quotactl_path

  linux commit 64c2c2c62f92339b176ea24403d8db16db36f9e6
  quota: Change quotactl_path() systcall to an fd-based one

add __NR_memfd_secret from linux v5.14 see

  linux commit 7bb7f2ac24a028b20fca466b9633847b289b156a
  arch, mm: wire up memfd_secret system call where relevant

  linux commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49
  mm: introduce memfd_secret system call to create "secret" memory areas

note: was already added on x86 and s390, now on aarch64 and riscv*.

add riscv __NR_riscv_hwprobe from linux v6.4 see

  linux commit ea3de9ce8aa280c5175c835bd3e94a3a9b814b74
  RISC-V: Add a syscall for HW probing

add x86_64 only map_shadow_stack syscall from linux v6.6 see

  linux commit c35559f94ebc3e3bc82e56e07161bb5986cd9761
  x86/shstk: Introduce map_shadow_stack syscall

add map_shadow_stack syscall from linux v6.7 see

  linux commit 2fd0ebad27bcd4c8fc61c61a98d4283c47054bcf
  arch: Reserve map_shadow_stack() syscall number for all architectures

add futex_* syscalls from linux v6.7 see

  linux commit 9f6c532f59b20580acf8ede9409c9b8dce6e74e1
  futex: Add sys_futex_wake()

  linux commit cb8c4312afca1b2dc64107e7e7cea81911055612
  futex: Add sys_futex_wait()

  linux commit 0f4b5f972216782a4acb1ae00dcb55173847c2ff
  futex: Add sys_futex_requeue()

add statmount, listmount syscalls from linux v6.8 see

  linux commit d8b0f5465012538cc4bb10ddc4affadbab73465b
  wire up syscalls for statmount/listmount

  linux commit b4c2bea8ceaa50cd42a8f73667389d801a3ecf2d
  add listmount(2) syscall

  linux commit 46eae99ef73302f9fb3dddcd67c374b3dffe8fd6
  add statmount(2) syscall

add lsm_* syscalls from linux v6.8 see

  linux commit 5f42375904b08890f2e8e7cd955c5bf0c2c0d05a
  LSM: wireup Linux Security Module syscalls

  linux commit ad4aff9ec25f400608283c10d634cc4eeda83a02
  LSM: Create lsm_list_modules system call

  linux commit a04a1198088a1378d0389c250cc684f649bcc91e
  LSM: syscalls for current process attributes

add mseal syscall from linux v6.10 see

  linux commit ff388fe5c481d39cc0a5940d1ad46f7920f1d646
  mseal: wire up mseal syscall

on sh add sync_file_range2 from linux v6.10 see

  linux commit 30766f1105d6d2459c3b9fe34a3e52b637a72950
  sh: rework sync_file_range ABI

on x86 add uretprobe from linux v6.11 see

  linux commit 54233a4254036efca91b9bffbd398ecf39e90555
  uretprobe: change syscall number, again

add *xattrat syscalls from linux v6.13 see

  linux commit 6140be90ec70c39fa844741ca3cc807dd0866394
  fs/xattr: add *at family syscalls

add open_tree_attr from linux v6.15 see

  linux commit c4a16820d90199409c9bf01c4f794e1e9e8d8fd8
  fs: add open_tree_attr()

add file_{get,set}attr from linux v6.17 see

  linux commit be7efb2d20d67f334a7de2aef77ae6c69367e646
  fs: introduce file_getattr and file_setattr syscalls

on x86 add uprobe from linux v6.18 see

  linux commit 56101b69c9190667f473b9f93f8b6d8209aaa816
  uprobes/x86: Add uprobe syscall to speed up uprobe

add listns from linux v6.19 see

  linux commit b36d4b6aa88ef039647228b98c59a875e92f8c8e
  arch: hookup listns() system call
2026-03-10 23:06:02 -04:00
sisungo 0f531e2cb8 feat: remove time32 support
The time32 support, in musl, is used to keep compatibility with old 32-bit
binaries. Our fork, though maintains ABI compatibility with musl libc,
but not legacy ones, so removing it.
2026-02-19 09:16:46 +08:00
Rich Felker f6944eb3c4 powerpc[64]: fix missing ctr and xer regs in syscall asm clobberlists
the ctr and xer special registers are call-clobbered and
syscall-clobbered. failure to include them in the clobber list may
result in wrong code that attempts to use a value which is no longer
present in the register after the syscall. this has been reported to
manifest newly with gcc 15.
2025-08-07 19:34:41 -04:00
A. WilcoxandRich Felker 86373b4999 powerpc: update HWCAP bits for Power10
Linux kernel commit ee988c11acf6f9464b7b44e9a091bf6afb3b3a49 added two
new HWCAP bits: one for ARCH_3_1, which is the Power10 ISA revision, and
one for MMA, which is the optional Matrix Multiply Assist extension.
2025-05-27 12:19:38 -04:00
Xing LiandRich Felker b0dc340b38 loongarch64: add bits/hwcap.h for cpu feature bits in AT_HWCAP auxv entry 2025-02-21 19:49:55 -05:00
Alex Rønne PetersenandRich Felker f1cda422cd i386, x86_64, x32: set the symbol type for the crt1 START function 2025-02-21 19:29:44 -05:00
Xing LiandRich Felker 61399d4bd0 loongarch64: add TLSDESC support 2024-10-22 20:36:09 -04:00
Rich Felker 9b6a24f9c5 wire up vdso clock_gettime for riscv32 and riscv64 2024-10-22 19:26:31 -04:00
Rich Felker f2375aacac wire up vdso clock_gettime for powerpc, powerpc64, and s390x
symbol names and versions obtained from vdso(7) man page.
2024-10-22 19:11:24 -04:00
Stefan LieblerandRich Felker 5be920e910 s390x: don't allow br r0 in CRTJMP asm
The instruction encoding that would be "br %r0" is not actually a
branch to r0, but instead a nop/memory-barrier. gcc 14 has been found
to choose r0 for the "r"(pc) constraint, breaking CRTJMP.

This patch adjusts the inline assembly constraints and marks "pc" as
address ("a"), which disallows usage of r0.
2024-10-11 12:21:35 -04:00
Baruch SiachandRich Felker b09e3174a6 m68k: fix POLLWRNORM and POLLWRBAND
As noted in commit f5011c62c3 ("fix POLLWRNORM and POLLWRBAND on mips")
m68k uses a different definition.
2024-08-09 23:07:04 -04:00
Rich Felker 2c124e13bd stdint.h: derive limits from __LONG_MAX, use common fast16 types
the bits file is retained, but as a single generic version, to allow
for the unlikely future possibility of letting a new arch define
something differently.
2024-05-07 09:17:51 -04:00
Rich Felker 7019fbe103 sys/user.h: derive __WORDSIZE from __LONG_MAX
previously, only a few archs defined it here. this change makes the
presence consistent across all archs, and reduces the amount of header
duplication (and potential for future inconsistency) between archs.
2024-05-07 09:11:10 -04:00
Rich Felker e709a6f07a sys/reg.h: derive __WORDSIZE from __LONG_MAX
this removes an otherwise-unnecessary bits header from most archs,
replacing it with an empty generic version.
2024-05-07 09:08:31 -04:00
Rich Felker 29b216b2f2 unistd.h: derive ILP32/LP64 macros from __LONG_MAX instead of arch bits 2024-05-07 09:01:47 -04:00
Rich Felker 0dfa1d8caa unify bits/stat.h for all archs sharing a common definition
future archs should not define their own bits/stat.h but use this
generic one.
2024-05-07 08:58:45 -04:00
Rich Felker ef600888d2 align aarch64, riscv64, loongarch64 stat structure padding type
this change is purely to document that they are the same in
preparation to remove the arch-specific headers for these archs and
replace them with a generic version that matches riscv32 and can be
shared by these and all future archs.
2024-05-07 08:55:55 -04:00
Michael ForneyandRich Felker a23cf8f9c5 riscv mcontext_t/sigcontext: use __aligned__ instead of aligned
aligned may be defined by the application for its own use before
bits/signal.h is included.
2024-05-06 10:59:12 -04:00
wanghongliangandRich Felker 8d9d266573 loongarch64: add new syscall numbers 2024-02-29 17:33:45 -05:00
Rich Felker 8d852cdacd loongarch64: remove getrlimit/setrlimit syscall numbers
these are not supported by the kernel for new archs; prlimit64
replaces them.
2024-02-29 17:32:27 -05:00
wanghongliangandRich Felker 13cd64af31 loongarch64: remove ptrace.h macros 2024-02-29 17:30:11 -05:00
Khem RajandRich Felker d25f0cccb9 riscv: define REG_S1 and REG_S2
These are used by applications to access members of mcontext, and are
also defined by other libcs on linux.
2024-02-29 16:36:55 -05:00
Khem RajandRich Felker 8432d16a46 riscv32: add new syscall numbers
- add mount_setattr from linux v5.12
- add epoll_pwait2 from linux v5.11
- add process_madvise from linux v5.10
- add __NR_faccessat2 from linux v5.8
- add pidfd_getfd and openat2 syscall numbers from linux v5.6
- add clone3 syscall number from linux v5.3
- add process_mrelease from linux v5.15
- add futex_waitv from linux v5.16
- add set_mempolicy_home_node from linux v5.17
- add cachestat from linux v6.4
- add __NR_fchmodat2 from linux v6.6
2024-02-29 16:36:55 -05:00
Rich Felker 3ea3fcf78a riscv32: add sysvipc msg/sem/shm bits
despite riscv32 being natively time64, the IPC_TIME64 bit (0x100) is
set in IPC_STAT and derived command macros, differentiating their
values from the raw command values used to interface with the kernel.
this reflects that the kernel ipc structure types are not natively
time64, but have broken-down hi/lo fields that cannot be used in-place
and require translation, and that the userspace struct types differ
from the kernel types (relevant to things like strace).
2024-02-29 16:36:55 -05:00
Stefan O'RearandRich Felker 01d9fe4d9f riscv32: add arch headers
These are mostly copied from riscv64. _Addr and _Reg had to become int
to match compiler-controlled parts of the ABI (result type of sizeof,
etc.). There is no kernel stat struct; the userspace stat matches
glibc in the sizes and offsets of all fields (including glibc's
__dev_t __pad1). The jump buffer is 12 words larger to account for 12
saved double-precision floats; additionally it should be 64-bit
aligned to save doubles.

The syscall list was significantly revised by deleting all time32 and
pre-statx syscalls, and renaming several syscalls that have different
names depending on __BITS_PER_LONG, notably mmap2 and _llseek.

futex was added as an alias to futex_time64 since it is widely used by
software which does not pass time arguments.
2024-02-29 16:35:30 -05:00
Hongliang WangandRich Felker ec325b3828 add loongarch64 user.h structs; adjust elf_fpreg_t and ELF_NFPREG
user_regs_struct and user_fp_struct were missing from the initial
commit of the port.

the union type for elf_fpreg_t and the new value of ELF_NFPREG are
made consistent with glibc.
2024-02-26 15:22:58 -05:00
wanghongliangandRich Felker f2c9350543 add loongarch64 signal.h register index macros 2024-02-26 15:22:54 -05:00
Gaël PORTAYandRich Felker 3d5c9fe39f bits/syscall.h: add __NR_fchmodat2 from linux v6.6
the linux fchmodat syscall lacks a flag argument that is necessary to
implement the posix api, see

  linux commit 09da082b07bbae1c11d9560c8502800039aebcea
  fs: Add fchmodat2()

  linux commit 78252deb023cf0879256fcfbafe37022c390762b
  arch: Register fchmodat2, usually as syscall 452
2024-02-22 19:24:18 -05:00
Gaël PORTAYandRich Felker dd690c4909 bits/syscall.h: add cachestat from linux v6.4
see

    linux commit cf264e1329fb0307e044f7675849f9f38b44c11a
    cachestat: implement cachestat syscall

    linux commit 946e697c69ffeeefdd84dad90eac307284df46be
    cachestat: wire up cachestat for other architectures
2024-02-22 19:23:47 -05:00
Gaël PORTAYandRich Felker 33e8c469a9 bits/syscall.h: add set_mempolicy_home_node from linux v5.17
see

    linux commit c6018b4b254971863bd0ad36bb5e7d0fa0f0ddb0
    mm/mempolicy: add set_mempolicy_home_node syscall

    linux commit 21b084fdf2a49ca1634e8e360e9ab6f9ff0dee11
    mm/mempolicy: wire up syscall set_mempolicy_home_node
2024-02-22 19:23:37 -05:00
Gaël PORTAYandRich Felker b2c4c3d590 bits/syscall.h: add futex_waitv from linux v5.16
see

    linux commit 039c0ec9bb77446d7ada7f55f90af9299b28ca49
    futex,x86: Wire up sys_futex_waitv()

    linux commit ea7c45fde5aa3e761aaddb7902a31a95cb120e7b
    futex,arm: Wire up sys_futex_waitv()

    linux commit b3ff2881ba18b852f79f5476d7631940071f1adb
    MIPS: syscalls: Wire up futex_waitv syscall

    linux commit 6c122360cf2f4c5a856fcbd79b4485b7baec942a
    s390: wire up sys_futex_waitv system call

    linux commit a0eb2da92b715d0c97b96b09979689ea09faefe6
    futex: Wireup futex_waitv syscall
2024-02-22 19:23:13 -05:00
Rich Felker e975127947 bits/syscall.h: add process_mrelease from linux v5.15
see

    linux commit 884a7e5964e06ed93c7771c0d7cf19c09a8946f1
    mm: introduce process_mrelease system call

    linux commit dce49103962840dd61423d7627748d6c558d58c5
    mm: wire up syscall process_mrelease
2024-02-22 19:23:05 -05:00
Gaël PORTAYandRich Felker a526314c80 bits/syscall.h: add memfd_secret from linux v5.14
see

    linux commit 7bb7f2ac24a028b20fca466b9633847b289b156a
    arch, mm: wire up memfd_secret system call where relevant

    linux commit 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49
    mm: introduce memfd_secret system call to create "secret" memory areas

    linux commit b633896314c0f78f2b4eb7b19a530d68f2a35445
    tools headers UAPI: Sync s390 syscall table file that wires up the
    memfd_secret syscall
2024-02-22 19:22:38 -05:00
Hongliang WangandRich Felker 522bd54eda add loongarch64 port
Author: Xiaojuan Zhai <[email protected]>
Author: Meidan Li <[email protected]>
Author: Guoqi Chen <[email protected]>
Author: Xiaolin Zhao <[email protected]>
Author: Fan peng <[email protected]>
Author: Jiantao Shan <[email protected]>
Author: Xuhui Qiang <[email protected]>
Author: Jingyun Hua <[email protected]>
Author: Liu xue <[email protected]>
Author: Hongliang Wang <[email protected]>
2024-02-16 09:33:10 -05:00
Rich Felker 407aea628a riscv: add TLSDESC support 2024-02-03 19:59:26 -05:00
Rich Felker 039d3c34f2 ldso: convert TLSDESC_BACKWARDS from "#ifdef" to "if" logic
this style is preferred because it allows the code to be
compile-checked even on archs where it is not used.
2023-11-06 21:48:02 -05:00
Rich Felker 269d193820 fix wrong sigaction syscall ABI on mips*, or1k, microblaze, riscv64
we wrongly defined a dummy SA_RESTORER flag on these archs, despite
the kernel interface not actually having such a feature. on archs
which lack SA_RESTORER, the kernel sigaction structure also lacks the
restorer function pointer member, which means the signal mask appears
at a different offset. the kernel was thereby interpreting the bits of
the code address as part of the signal set to be masked while handling
the signal.

this patch removes the erroneous SA_RESTORER definitions from archs
which do not have it, makes access to the member conditional on
whether SA_RESTORER is defined for the arch, and removes the
now-unused asm for the affected archs.

because there are reportedly versions of qemu-user which also use the
wrong ABI here, the old ksigaction struct size is preserved with an
unused member at the end. this is harmless and mitigates the risk of
such a bug turning into a buffer overflow onto the sigaction
function's stack.
2023-02-09 12:33:35 -05:00
Rich Felker f897461d4f fix debugger tracking of shared libraries on mips with PIE main program
mips has its own mechanisms for DT_DEBUG because it makes _DYNAMIC
read-only, and the original mechanism, DT_MIPS_RLD_MAP, was
PIE-incompatible. DT_MIPS_RLD_MAP_REL was added to remedy this, but we
never implemented support for it. add it now using the same idioms for
mips-specific ldso logic.
2023-01-18 10:32:14 -05:00
Rich Felker bf14ef193b re-enable vdso clock_gettime on arm (32-bit) with workaround
commit 4486c579cb disabled vdso
clock_gettime on arm due to a Linux kernel bug that was not understood
at the time, whereby the vdso function silently produced
catastrophically wrong results on some systems.

since then, the bug was tracked down to the way the arm kernel
disabled use of vdso clock_gettime on kernels where the necessary
timer was not available or was disabled. it simply patched out the
symbols, but it only did this for the legacy time32 functions, and
left the time64 function in place but non-operational. kernel commit
4405bdf3c57ec28d606bdf5325f1167505bfdcd4 (first present in 5.8)
provided the fix.

if this were a bug that impacted all users of the broken kernel
versions, we could probably ignore it and assume it had been patched
or replaced. however, it's very possible that these kernels appear in
the wild in devices running time32 userspace (glibc, musl 1.1.x, or
some other environment) where they appear to work fine, but where our
new binaries would fail catastrophically if we used the time64 vdso
function.

since the kernel has not (yet?) given us a way to probe for the
working time64 vdso function semantically, we work around the problem
by refusing to use the time64 one unless the time32 one is also
present. this will revert to not using vdso at all if the time32 one
is ever removed, but at least that's safe against wrong results and is
just a missed optimization.
2022-09-19 13:21:54 -04:00
Rich Felker 760f5d7efe fix __WORDSIZE on x32 sys/user.h
sys/reg.h already had it right as 32, to which it was explicitly
changed when commit 664cd34192 derived
x32 from x86_64. but the copy exposed in sys/user.h was missed.
2022-03-08 17:21:49 -05:00
Szabolcs NagyandRich Felker ee05b11b67 bits/syscall.h: add landlock syscalls from linux v5.13
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.
2022-03-08 17:21:14 -05:00
Szabolcs NagyandRich Felker 9ffd145479 s390x: add ptrace requests from linux v5.12
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
2022-03-08 17:19:52 -05:00
Szabolcs NagyandRich Felker f7d3db5bfc bits/syscall.h: add mount_setattr from linux v5.12
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()
2022-03-08 17:19:51 -05:00
Szabolcs NagyandRich Felker b21f3ded78 bits/syscall.h: add epoll_pwait2 from linux v5.11
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.
2022-03-08 17:19:36 -05:00
Rich Felker 7be59733d7 add SPE FPU support to powerpc-sf
When the soft-float ABI for PowerPC was added in commit
5a92dd95c7, 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.
2021-09-23 19:11:46 -04:00
Rich Felker b713b8b2e4 fix excessively slow TLS performance on some mips models
commit 6d99ad91e8 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.
2021-08-12 18:07:44 -04:00
Rich Felker 0fbd7d6683 fix broken struct shmid_ds on powerpc (32-bit)
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.
2021-07-06 21:12:02 -04:00