]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
2 months agodoc: Fix typos in documentation of _TIME_BITS
Jonathan Wakely [Tue, 27 May 2025 10:15:22 +0000 (11:15 +0100)] 
doc: Fix typos in documentation of _TIME_BITS

2 months agoFix comment typo in libc-symbols.h
Jonathan Wakely [Tue, 27 May 2025 10:07:43 +0000 (11:07 +0100)] 
Fix comment typo in libc-symbols.h

Reviewed-by: Sam James <sam@gentoo.org>
2 months agoTurn on -Wmissing-parameter-name by default if available
Florian Weimer [Tue, 27 May 2025 05:14:58 +0000 (07:14 +0200)] 
Turn on -Wmissing-parameter-name by default if available

This flags another hazard for backporting changes to earlier branches.

Reviewed-by: Sam James <sam@gentoo.org>
2 months agomanual: Document getopt_long_only with single letter options (bug 32980)
Tomas Volf [Mon, 26 May 2025 13:53:54 +0000 (15:53 +0200)] 
manual: Document getopt_long_only with single letter options (bug 32980)

Signed-off-by: Tomas Volf <~@wolfsden.cz>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoTurn on -Wfree-labels by default if available
Florian Weimer [Mon, 26 May 2025 06:49:19 +0000 (08:49 +0200)] 
Turn on -Wfree-labels by default if available

This flags a hazard for backporting changes to earlier branches.

Reviewed-by: Sam James <sam@gentoo.org>
2 months agoS390: Use cfi_val_offset instead of cfi_escape. 31bit part
Stefan Liebler [Wed, 14 May 2025 12:26:36 +0000 (14:26 +0200)] 
S390: Use cfi_val_offset instead of cfi_escape. 31bit part

Due to raising the minimum binutils version to version >=2.28,
the used cfi_escape for cfi_val_offset can now be ommitted.

The commit 0fc76d876261ee8253fef198ffec48c832edd4ff
has already adjusted it for the 64bit part of mcount.
This patch also adjusts it for the 31bit part of mcount.

Checked with "objdump -WF" / "objdump -Wf" that the previous
cfi_escape and the new cfi_val_offset are equal.

2 months agolibmvec: Add inputs for asinpi(f), acospi(f), atanpi(f) and atan2pi(f)
Wilco Dijkstra [Tue, 20 May 2025 13:20:17 +0000 (13:20 +0000)] 
libmvec: Add inputs for asinpi(f), acospi(f), atanpi(f) and atan2pi(f)

Add initial inputs for asinpi(f), acospi(f), atanpi(f) and atan2pi(f) based
on existing asin/acos/atan inputs.

Benchtests now works on the new libmvec function.

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2 months agoINSTALL: Regenerate with texinfo 7.2
Mark Wielaard [Wed, 14 May 2025 21:11:15 +0000 (23:11 +0200)] 
INSTALL: Regenerate with texinfo 7.2

This fixes make dist on systems with the latest texinfo installed.
GNU texinfo 7.2 changes @xrefs in proper plain text sentences instead
of pseudo info references.

Tested-By: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
2 months agoFix error reporting (false negatives) in SGID tests
Florian Weimer [Thu, 22 May 2025 12:36:37 +0000 (14:36 +0200)] 
Fix error reporting (false negatives) in SGID tests

And simplify the interface of support_capture_subprogram_self_sgid.

Use the existing framework for temporary directories (now with
mode 0700) and directory/file deletion.  Handle all execution
errors within support_capture_subprogram_self_sgid.  In particular,
this includes test failures because the invoked program did not
exit with exit status zero.  Existing tests that expect exit
status 42 are adjusted to use zero instead.

In addition, fix callers not to call exit (0) with test failures
pending (which may mask them, especially when running with --direct).

Fixes commit 35fc356fa3b4f485bd3ba3114c9f774e5df7d3c2
("elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agomanual: Use more inclusive language in comments.
Carlos O'Donell [Tue, 20 May 2025 11:45:25 +0000 (07:45 -0400)] 
manual: Use more inclusive language in comments.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoMakerules: Use 'original' instead of 'master' in source.
Carlos O'Donell [Tue, 20 May 2025 11:45:21 +0000 (07:45 -0400)] 
Makerules: Use 'original' instead of 'master' in source.

Use more inclusive language in makefile source.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agogen-libm-test: Use 'original source' instead of 'master' in code.
Carlos O'Donell [Tue, 20 May 2025 11:45:20 +0000 (07:45 -0400)] 
gen-libm-test: Use 'original source' instead of 'master' in code.

Use more inclusive language in generated sources.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agonss_test1: Use 'parametrized template' instead of 'master' in comment.
Carlos O'Donell [Tue, 20 May 2025 11:45:19 +0000 (07:45 -0400)] 
nss_test1: Use 'parametrized template' instead of 'master' in comment.

Use more inclusive language in code comments.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agolinknamespace: Use 'ALLOWLIST' instead of 'WHITELIST' in code.
Carlos O'Donell [Tue, 20 May 2025 11:45:17 +0000 (07:45 -0400)] 
linknamespace: Use 'ALLOWLIST' instead of 'WHITELIST' in code.

Use more inclusive language in code.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoposix: Use more inclusive language in test data.
Carlos O'Donell [Tue, 20 May 2025 11:45:16 +0000 (07:45 -0400)] 
posix: Use more inclusive language in test data.

Remove Changelog entries that use 'blacklist' or 'master' in the
test data. The test data still contains enough accented characters
to serve the purposes of the posix/tst-regex.c test.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agopylintrc: Remove obsolete ignore section and comments.
Carlos O'Donell [Tue, 20 May 2025 11:45:14 +0000 (07:45 -0400)] 
pylintrc: Remove obsolete ignore section and comments.

Remove the obsolete ignore=CVS since we use git now.

We make the code more inclusive by removing obsolete comments.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agosupport: Pick group in support_capture_subprogram_self_sgid if UID == 0
Florian Weimer [Wed, 21 May 2025 14:47:34 +0000 (16:47 +0200)] 
support: Pick group in support_capture_subprogram_self_sgid if UID == 0

When running as root, it is likely that we can run under any group.
Pick a harmless group from /etc/group in this case.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agoldbl-128: also disable lgammaf128_r builtin when building lgammal_r
Andreas Schwab [Tue, 20 May 2025 10:42:19 +0000 (12:42 +0200)] 
ldbl-128: also disable lgammaf128_r builtin when building lgammal_r

2 months agoelf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)
Florian Weimer [Wed, 21 May 2025 06:43:32 +0000 (08:43 +0200)] 
elf: Fix subprocess status handling for tst-dlopen-sgid (bug 32987)

This should really move into support_capture_subprogram_self_sgid.

Reviewed-by: Sam James <sam@gentoo.org>
2 months agox86_64: Fix typo in ifunc-impl-list.c.
Sunil K Pandey [Tue, 20 May 2025 17:07:27 +0000 (10:07 -0700)] 
x86_64: Fix typo in ifunc-impl-list.c.

Fix wcsncpy and wcpncpy typo in ifunc-impl-list.c.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoelf: Test case for bug 32976 (CVE-2025-4802)
Florian Weimer [Tue, 20 May 2025 17:36:02 +0000 (19:36 +0200)] 
elf: Test case for bug 32976 (CVE-2025-4802)

Check that LD_LIBRARY_PATH is ignored for AT_SECURE statically
linked binaries, using support_capture_subprogram_self_sgid.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agosupport: Use const char * argument in support_capture_subprogram_self_sgid
Florian Weimer [Tue, 20 May 2025 17:36:02 +0000 (19:36 +0200)] 
support: Use const char * argument in support_capture_subprogram_self_sgid

The function does not modify the passed-in string, so make this clear
via the prototype.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agoAArch64: Fix typo in math-vector.h
Wilco Dijkstra [Tue, 20 May 2025 13:39:02 +0000 (13:39 +0000)] 
AArch64: Fix typo in math-vector.h

Fix typo atanpi2->atan2pi in math-vector.h.

2 months agoFix typos in ldbl-opt makefile
Andreas Schwab [Tue, 20 May 2025 09:13:01 +0000 (11:13 +0200)] 
Fix typos in ldbl-opt makefile

The -fno-builtin options need to disable the long double builtins.

2 months agoAArch64: Cleanup SVE config and defines
Wilco Dijkstra [Wed, 14 May 2025 11:38:19 +0000 (11:38 +0000)] 
AArch64: Cleanup SVE config and defines

Now we finally support modern GCC and binutils, it's time for a cleanup.
Remove HAVE_AARCH64_SVE_ASM define and conditional compilation.  Remove SVE
configure checks for SVE, ACLE and variant-PCS support.

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2 months agoAArch64: Cleanup PAC and BTI
Wilco Dijkstra [Wed, 14 May 2025 16:32:31 +0000 (16:32 +0000)] 
AArch64: Cleanup PAC and BTI

Now we finally support modern GCC and binutils, it's time for a cleanup.
Use PAC and BTI instructions unconditionally and use proper assembler syntax.
Remove the PR target/94791 strip_pac workarounds for buggy GCCs.  Remove the
PAC/BTI configure checks - always emit GNU property notes on assembly files.
Change cfi_window_save to the correct cfi_negate_ra_state unwind directive.

Reviewed-by: Matthieu Longo <matthieu.longo@arm.com>
2 months agoAArch64: Implement AdvSIMD and SVE atan2pi/f
Dylan Fleming [Mon, 19 May 2025 13:58:30 +0000 (13:58 +0000)] 
AArch64: Implement AdvSIMD and SVE atan2pi/f

Implement double and single precision variants of the C23 routine atan2pi
for both AdvSIMD and SVE.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoAArch64: Implement AdvSIMD and SVE atanpi/f
Dylan Fleming [Mon, 19 May 2025 12:44:20 +0000 (12:44 +0000)] 
AArch64: Implement AdvSIMD and SVE atanpi/f

Implement double and single precision variants of the C23 routine atanpi
for both AdvSIMD and SVE.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoAArch64: Implement AdvSIMD and SVE asinpi/f
Dylan Fleming [Mon, 19 May 2025 12:39:51 +0000 (12:39 +0000)] 
AArch64: Implement AdvSIMD and SVE asinpi/f

Implement double and single precision variants of the C23 routine asinpi
for both AdvSIMD and SVE.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoAArch64: Implement AdvSIMD and SVE acospi/f
Dylan Fleming [Mon, 19 May 2025 12:26:50 +0000 (12:26 +0000)] 
AArch64: Implement AdvSIMD and SVE acospi/f

Implement double and single precision variants of the C23 routine acospi
for both AdvSIMD and SVE.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoAArch64: Optimize inverse trig functions
Dylan Fleming [Mon, 19 May 2025 11:36:51 +0000 (11:36 +0000)] 
AArch64: Optimize inverse trig functions

Improve performance of Inverse trig functions by altering how coefficients are
loaded.

Performance improvement on Neoverse V1:
SVE     acos   14%
AdvSIMD acos   6%

AdvSIMD asin   6%
SVE     asin   5%
AdvSIMD asinf  2%

AdvSIMD atanf  22%
SVE     atanf  20%
SVE     atan   11%
AdvSIMD atan   5%

SVE     atan2  7%
SVE     atan2f 4%
AdvSIMD atan2f 3%
AdvSIMD atan2  2%

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoDocument CVE-2025-4802.
Carlos O'Donell [Thu, 15 May 2025 21:46:36 +0000 (17:46 -0400)] 
Document CVE-2025-4802.

This commit adds advisory data for the above CVE(s).

2 months agoctype: Fallback initialization of TLS using relocations (bug 19341, bug 32483)
Florian Weimer [Fri, 16 May 2025 17:53:09 +0000 (19:53 +0200)] 
ctype: Fallback initialization of TLS using relocations (bug 19341, bug 32483)

This ensures that the ctype data pointers in TLS are valid
in secondary namespaces even without initialization via
__ctype_init.

Reviewed-by: Frédéric Bérat <fberat@redhat.com>
2 months agoUse proper extern declaration for _nl_C_LC_CTYPE_{class,toupper,tolower}
Florian Weimer [Fri, 16 May 2025 17:53:09 +0000 (19:53 +0200)] 
Use proper extern declaration for _nl_C_LC_CTYPE_{class,toupper,tolower}

The existing initializers already contain explicit casts.  Keep them
due to int/uint32_t mismatch.

Reviewed-by: Frédéric Bérat <fberat@redhat.com>
2 months agoOptimize __libc_tsd_* thread variable access
Florian Weimer [Fri, 16 May 2025 17:53:09 +0000 (19:53 +0200)] 
Optimize __libc_tsd_* thread variable access

These variables are not exported, and libc.so TLS is initial-exec
anyway.  Declare these variables as hidden and use the initial-exec
TLS model.

Reviewed-by: Frédéric Bérat <fberat@redhat.com>
2 months agoRemove <libc-tsd.h>
Florian Weimer [Fri, 16 May 2025 17:53:09 +0000 (19:53 +0200)] 
Remove <libc-tsd.h>

Use __thread variables directly instead.  The macros do not save any
typing.  It seems unlikely that a future port will lack __thread
variable support.

Some of the __libc_tsd_* variables are referenced from assembler
files, so keep their names.  Previously, <libc-tls.h> included
<tls.h>, which in turn included <errno.h>, so a few direct includes
of <errno.h> are now required.

Reviewed-by: Frédéric Bérat <fberat@redhat.com>
2 months agomanual: add sched_getcpu()
DJ Delorie [Thu, 15 May 2025 20:38:11 +0000 (16:38 -0400)] 
manual: add sched_getcpu()

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 months agomanual: Clarifications for listing directories
Florian Weimer [Fri, 16 May 2025 14:47:02 +0000 (16:47 +0200)] 
manual: Clarifications for listing directories

Support for seeking is limited.  Using the d_off and d_reclen members
of struct dirent is discouraged, especially with readdir.  Concurrent
modification of directories during iteration may result in duplicate
or missing etnries.

2 months agomanual: add remaining CPU_* macros
DJ Delorie [Thu, 24 Apr 2025 22:03:21 +0000 (18:03 -0400)] 
manual: add remaining CPU_* macros

Adds remaining CPU_* macros, including the CPU_*_S macros
for dynamic-sized cpu sets.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 months agopowerpc: Remove check for -mabi=ibmlongdouble
Andreas Schwab [Tue, 1 Apr 2025 11:19:07 +0000 (13:19 +0200)] 
powerpc: Remove check for -mabi=ibmlongdouble

The -mabi=ibmlongdouble option has been added in gcc 4.2, thus can be
assumed to always exist.

2 months agoaarch64: update tests for SME
Yury Khrustalev [Tue, 29 Apr 2025 12:44:11 +0000 (13:44 +0100)] 
aarch64: update tests for SME

Add test that checks that ZA state is disabled after setjmp and sigsetjmp
Update existing SME test that uses setjmp

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoaarch64: Disable ZA state of SME in setjmp and sigsetjmp
Yury Khrustalev [Mon, 28 Apr 2025 14:12:04 +0000 (15:12 +0100)] 
aarch64: Disable ZA state of SME in setjmp and sigsetjmp

Due to the nature of the ZA state, setjmp() should clear it in the
same manner as it is already done by longjmp.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agobenchtest: malloc tcache hotpath benchtest
Cupertino Miranda [Thu, 15 May 2025 13:09:25 +0000 (13:09 +0000)] 
benchtest: malloc tcache hotpath benchtest

Existing benchtests for malloc infrastructure seem to be rather generic
to test global malloc implementation performance.  This new benchtest
focus on reducing any non tcache related side effects, allowing to more
realistically predict performance impacts of tcache code changes.
The test was inpired in bench-[cm]alloc-thread code, with severe
simplifications:
 - forces single thread execution, reducing concurrency side-effects,
   like cache incoherence penalties due simultaneous writes to the same
   cache pages;
 - Focus on allocating and deallocating a single size for all the
   duration of the benchmark. Since all it does is allocate and
   deallocate, it will measure the tcache hotpath without any
   side-effects.
 - Allows to specify the allocation size as input argument.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2 months agoImplement C23 rootn.
Joseph Myers [Wed, 14 May 2025 10:51:46 +0000 (10:51 +0000)] 
Implement C23 rootn.

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the rootn functions, which compute the Yth root of X for
integer Y (with a domain error if Y is 0, even if X is a NaN).  The
integer exponent has type long long int in C23; it was intmax_t in TS
18661-4, and as with other interfaces changed after their initial
appearance in the TS, I don't think we need to support the original
version of the interface.

As with pown and compoundn, I strongly encourage searching for worst
cases for ulps error for these implementations (necessarily
non-exhaustively, given the size of the input space).  I also expect a
custom implementation for a given format could be much faster as well
as more accurate, although the implementation is simpler than those
for pown and compoundn.

This completes adding to glibc those TS 18661-4 functions (ignoring
DFP) that are included in C23.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118592 regarding the C23
mathematical functions (not just the TS 18661-4 ones) missing built-in
functions in GCC, where such functions might usefully be added.

Tested for x86_64 and x86, and with build-many-glibcs.py.

2 months agomalloc: Improve performance of __libc_calloc
Wilco Dijkstra [Fri, 9 May 2025 16:02:14 +0000 (16:02 +0000)] 
malloc: Improve performance of __libc_calloc

Improve performance of __libc_calloc by splitting it into 2 parts: first handle
the tcache fastpath, then do the rest in a separate tailcalled function.
This results in significant performance gains since __libc_calloc doesn't need
to setup a frame.

On Neoverse V2, bench-calloc-simple improves by 5.0% overall.
Bench-calloc-thread 1 improves by 24%.

Reviewed-by: DJ Delorie <dj@redhat.com>
2 months agoS390: Use cfi_val_offset instead of cfi_escape.
Stefan Liebler [Tue, 13 May 2025 11:28:57 +0000 (13:28 +0200)] 
S390: Use cfi_val_offset instead of cfi_escape.

Due to raising the minimum binutils version to version >=2.28,
the used cfi_escape for cfi_val_offset can now be ommitted.

Checked with "objdump -WF" / "objdump -Wf" that the previous
cfi_escape and the new cfi_val_offset are equal.

2 months agopowerpc64le: Remove configure check for objcopy >= 2.26.
Stefan Liebler [Tue, 13 May 2025 11:28:56 +0000 (13:28 +0200)] 
powerpc64le: Remove configure check for objcopy >= 2.26.

Due to raising the minimum binutils version to >= 2.26, the configure
check for testing support of --update-section is not needed anymore.
Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
2 months agoRaise the minimum binutils version to 2.39
Stefan Liebler [Tue, 13 May 2025 11:28:55 +0000 (13:28 +0200)] 
Raise the minimum binutils version to 2.39

The recent commit 27b96e069aad17cefea9437542180bff448ac3a0 raises the minimum
GCC version to 12.1 which was released in 2022.

The current minimum bintuils version 2.25 was released end of 2014.  This patch
now raises the minimum binutils version to 2.39 which was also released in 2022.

The hint for ARC is not needed anymore.

In sysdeps/[alpha|hppa|csky]/configure.ac, PIE is unsupported with this comment:
PIE builds fail on binutils 2.37 and earlier, see:
https://sourceware.org/bugzilla/show_bug.cgi?id=28672
This patch keeps PIE unsupported and let the machine maintainers test and
enable it later.

In sysdeps/arm/configure.ac, there is a check whether TPOFF relocs with addends
are assembled correctly, which is known to be broken in binutils 2.24 and 2.25.
See: https://sourceware.org/bugzilla/show_bug.cgi?id=18383
This patch keeps the check as is and let the machine maintainers check if it
still required.

According to Florian Weimer:
Having at least binutils 2.38 will allow us to assume that this linker
bug is fixed:
Bug 28743 - -z relro creats holes in the process image on GNU/Linux
<https://sourceware.org/bugzilla/show_bug.cgi?id=28743>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoadded benchtest inputs for log2l
Paul Zimmermann [Fri, 2 May 2025 07:35:50 +0000 (09:35 +0200)] 
added benchtest inputs for log2l

2 months agoadded benchtest inputs for expl
Paul Zimmermann [Wed, 30 Apr 2025 16:12:53 +0000 (18:12 +0200)] 
added benchtest inputs for expl

2 months agoaarch64: fix unwinding in longjmp
Yury Khrustalev [Thu, 8 May 2025 12:53:38 +0000 (13:53 +0100)] 
aarch64: fix unwinding in longjmp

Previously, longjmp() on aarch64 was using CFI directives around the
call to __libc_arm_za_disable() after CFA was redefined at the start
of longjmp(). This may result in unwinding issues. Move the call and
surrounding CFI directives to the beginning of longjmp().

Suggested-by: Wilco Dijkstra <wilco.dijkstra@arm.com>
2 months agoadded benchtest inputs for powl
Paul Zimmermann [Fri, 2 May 2025 07:46:16 +0000 (09:46 +0200)] 
added benchtest inputs for powl

changes in v2:
* fixed the missing Makefile entry in the first version
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agoadded benchtest inputs for fmal
Paul Zimmermann [Fri, 2 May 2025 07:40:45 +0000 (09:40 +0200)] 
added benchtest inputs for fmal

2 months agomanual: fix typo for sched_[sg]etattr
DJ Delorie [Wed, 7 May 2025 23:23:06 +0000 (19:23 -0400)] 
manual: fix typo for sched_[sg]etattr

Originally added in 41a90f3f5f which says it's adding sched_getattr
and sched_setattr.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 months agomalloc: Improve malloc initialization
Wilco Dijkstra [Thu, 1 May 2025 19:58:38 +0000 (19:58 +0000)] 
malloc: Improve malloc initialization

Move malloc initialization to __libc_early_init.  Use a hidden __ptmalloc_init
for initialization and a weak call to avoid pulling in the system malloc in a
static binary.  All previous initialization checks can now be removed.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 months agoDocument all CLOCK_* values
Joseph Myers [Mon, 12 May 2025 14:56:07 +0000 (14:56 +0000)] 
Document all CLOCK_* values

The manual documents CLOCK_REALTIME and CLOCK_MONOTONIC but not other
CLOCK_* values.  Add documentation of the POSIX clocks
CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, along with a
reference to the Linux man pages for the semantics of the
Linux-specific clocks supported (as with some other functionality
coming direct from the Linux kernel where the man pages can be
considered the main documentation).

Note: CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE and
CLOCK_MONOTONIC_COARSE are also defined in the toplevel bits/time.h,
as used for Hurd.  Nevertheless, I see no sign that the Hurd code in
glibc actually has any support for those clocks, so I think it is
correct to document them as Linux-specific (and to refer only to the
Linux man pages for their semantics).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 months agomalloc: Improved double free detection in the tcache
David Lau [Mon, 12 May 2025 11:42:17 +0000 (11:42 +0000)] 
malloc: Improved double free detection in the tcache

The previous double free detection did not account for an attacker to
use a terminating null byte overflowing from the previous
chunk to change the size of a memory chunk is being sorted into.
So that the check in 'tcache_double_free_verify' would pass
even though it is a double free.

Solution:
Let 'tcache_double_free_verify' iterate over all tcache entries to
detect double frees.

This patch only protects from buffer overflows by one byte.
But I would argue that off by one errors are the most common
errors to be made.

Alternatives Considered:
  Store the size of a memory chunk in big endian and thus
  the chunk size would not get overwritten because entries in the
  tcache are not that big.

  Move the tcache_key before the actual memory chunk so that it
  does not have to be checked at all, this would work better in general
  but also it would increase the memory usage.

Signed-off-by: David Lau <david.lau@fau.de>
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2 months agoCorrect spelling mistake in test file
panzhe0328 [Tue, 6 May 2025 07:11:17 +0000 (15:11 +0800)] 
Correct spelling mistake in test file

There are some spelling mistakes in the test file. Fix them

Reviewed-by: guoce <guoce@kylinos.cn>
Signed-off-by: panzhe0328 <panzhe@kylinos.cn>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agohurd: Make rename refuse trailing slashes [BZ #32570]
Samuel Thibault [Sun, 11 May 2025 23:52:51 +0000 (01:52 +0200)] 
hurd: Make rename refuse trailing slashes [BZ #32570]

As tested by Gnulib's renameatu module.

Reported by Collin Funk on
https://sourceware.org/bugzilla/show_bug.cgi?id=32570

2 months agoImplement C23 compoundn
Joseph Myers [Fri, 9 May 2025 15:17:27 +0000 (15:17 +0000)] 
Implement C23 compoundn

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the compoundn functions, which compute (1+X) to the
power Y for integer Y (and X at least -1).  The integer exponent has
type long long int in C23; it was intmax_t in TS 18661-4, and as with
other interfaces changed after their initial appearance in the TS, I
don't think we need to support the original version of the interface.

Note that these functions are "compoundn" with a trailing "n", *not*
"compound" (CORE-MATH has the wrong name, for example).

As with pown, I strongly encourage searching for worst cases for ulps
error for these implementations (necessarily non-exhaustively, given
the size of the input space).  I also expect a custom implementation
for a given format could be much faster as well as more accurate (I
haven't tested or benchmarked the CORE-MATH implementation for
binary32); this is one of the more complicated and less efficient
functions to implement in a type-generic way.

As with exp2m1 and exp10m1, this showed up places where the
powerpc64le IFUNC setup is not as self-contained as one might hope (in
this case, without the changes specific to powerpc64le, there were
undefined references to __GI___expf128).

Tested for x86_64 and x86, and with build-many-glibcs.py.

2 months agohurd: Fix tst-stack2 test build on Hurd
Adhemerval Zanella [Fri, 9 May 2025 13:19:37 +0000 (10:19 -0300)] 
hurd: Fix tst-stack2 test build on Hurd

It requires $(shared-thread-library).  Fixes 0c342594237.

Checked on a i686-gnu build.

2 months agonss: remove undefined behavior and optimize getaddrinfo
Collin Funk [Mon, 5 May 2025 02:31:34 +0000 (19:31 -0700)] 
nss: remove undefined behavior and optimize getaddrinfo

On x86-64 and compiling with -O2 using stdc_leading_zeros compiles to
the bsr instruction.  The fls function removed by this patch is inlined
but still loops while checking each bit individually.

* nss/getaddrinfo.c: Include <stdbit.h>.
(fls): Remove function.  This function contains a left shift of 31 on an
'int' which is undefined.
(rfc3484_sort): Use stdc_leading_zeros instead of fls.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 months agopowerpc: Remove POWER7 strncasecmp optimization
Adhemerval Zanella [Fri, 2 May 2025 12:07:36 +0000 (09:07 -0300)] 
powerpc: Remove POWER7 strncasecmp optimization

These routines are not extensively used (gnulib documentation even
recommend use a replacement [1]), and there is already a POWER8
version that uses proper vectorized instructions.

[1] https://www.gnu.org/software/gnulib/manual/gnulib.html#C-strings

Checked with a build for some powerpc variations.
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
2 months agomanual: add more pthread functions
DJ Delorie [Sat, 3 May 2025 00:51:18 +0000 (20:51 -0400)] 
manual: add more pthread functions

Add stubs and partial docs for many undocumented pthreads functions.
While neither exhaustive nor complete, gives minimal usage docs
for many functions and expands the pthreads chapters, making it
easier to continue improving this section in the future.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
2 months agoS390: Add new s390 platform z17.
Stefan Liebler [Tue, 29 Apr 2025 11:28:58 +0000 (13:28 +0200)] 
S390: Add new s390 platform z17.

The glibc-hwcaps subdirectories are extended by "z17".  Libraries are loaded if
the z17 facility bits are active:
- Miscellaneous-instruction-extensions facility 4
- Vector-enhancements-facility 3
- Vector-Packed-Decimal-Enhancement Facility 3
- CPU: Concurrent-Functions Facility

tst-glibc-hwcaps.c is extended in order to test z17 via new marker6.
In case of running on a z17 with a kernel not recognizing z17 yet,
AT_PLATFORM will be z900 but vector-bit in AT_HWCAP is set.  This situation
is now recognized and this testcase does not fail.

A fatal glibc error is dumped if glibc was build with architecture
level set for z17, but run on an older machine (See dl-hwcap-check.h).
Note, you might get an SIGILL before this check if you don't use:
configure --with-rtld-early-cflags=-march=<older-machine>

ld.so --list-diagnostics now also dumps information about s390.cpu_features.

Independent from z17, the s390x kernel won't introduce new HWCAP-Bits if there
is no special handling needed in kernel itself.  For z17, we don't have new
HWCAP flags, but have to check the facility bits retrieved by
stfle-instruction.

Instead of storing all the stfle-bits (currently four 64bit values) in the
cpu_features struct, we now only store those bits, which are needed within
glibc itself.  Note that we have this list twice, one with original values and
the other one which can be filtered with GLIBC_TUNABLES=glibc.cpu.hwcaps.
Those new fields are stored in so far reserved space in cpu_features struct.
Thus processes started in between the update of glibc package and we e.g. have
a new ld.so and an old libc.so, won't crash. The glibc internal ifunc-resolvers
would not select the best optimized variant.

The users of stfle-bits are also updated:
- parsing of GLIBC_TUNABLES=glibc.cpu.hwcaps
- glibc internal ifunc-resolvers
- __libc_ifunc_impl_list
- sysconf

3 months agoCorrect test descriptors in libm-test-pown.inc
Joseph Myers [Thu, 1 May 2025 22:28:59 +0000 (22:28 +0000)] 
Correct test descriptors in libm-test-pown.inc

While working on implementing compoundn, I noticed that
libm-test-pown.inc was wrongly using TEST_ff_f and AUTO_TESTS_ff_f
when the actual types involved meant fL_f should be used instead of
ff_f; fix to use the correct descriptor strings for pown.  (These
strings affect how gen-libm-test.py generates a C file in some cases.
The structure type test_fL_f_data for expected results and the use of
RUN_TEST_LOOP_fL_f in the ALL_RM_TEST call were already correct.)

Tested for x86_64.  The generated libm-test-pown.c was actually
unchanged, but the old descriptor strings were still logically
incorrect.

3 months agomalloc: Inline tcache_try_malloc
Wilco Dijkstra [Wed, 16 Apr 2025 12:21:56 +0000 (12:21 +0000)] 
malloc: Inline tcache_try_malloc

Inline tcache_try_malloc into calloc since it is the only caller.  Also fix
usize2tidx and use it in __libc_malloc, __libc_calloc and _mid_memalign.
The result is simpler, cleaner code.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 months agomath: Fix UB on sinpif (BZ 32925)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:29 +0000 (17:54 -0300)] 
math: Fix UB on sinpif (BZ 32925)

The left shift overflows for 'int', use uint32_t instead.  It syncs
with CORE-MATH commit bbfabd99.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on erfcf (BZ 32924)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:28 +0000 (17:54 -0300)] 
math: Fix UB on erfcf (BZ 32924)

The left shift overflows for 'int', use uint64_t instead.  It syncs
with CORE-MATH commit d0a2be200cbc1344d800d9ef0ebee9ad67dd3ad8.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on cospif (BZ 32923)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:27 +0000 (17:54 -0300)] 
math: Fix UB on cospif (BZ 32923)

The left shift overflows for 'int', use uint32_t instead.  It syncs
with CORE-MATH commit bbfabd993a71b049c210b0febfd06d18369fadc1.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on cbrtf (BZ 32922)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:26 +0000 (17:54 -0300)] 
math: Fix UB on cbrtf (BZ 32922)

The left shift overflows for 'int64_t', use unsigned instead.  It syncs
with CORE-MATH commit f7c7408d1749ec2859ea249495af699359ae559b.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on sinhf (BZ 32921)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:25 +0000 (17:54 -0300)] 
math: Fix UB on sinhf (BZ 32921)

The left shift overflows for 'int', use uint64_t instead.  It syncs
with CORE-MATH commit bbfabd99.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on logf (BZ 32920)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:24 +0000 (17:54 -0300)] 
math: Fix UB on logf (BZ 32920)

The left shift overflows for 'int', use a literal instead.  It syncs
with OPTIMIZED-ROUTINES commit 0f87f607b976820ef41fe64d004fe67dc7af8236.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on coshf (BZ 32919)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:23 +0000 (17:54 -0300)] 
math: Fix UB on coshf (BZ 32919)

The left shift overflows for 'int', use uint64_t instead.  It syncs
with CORE-MATH commit 4d6192d2.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agomath: Fix UB on atanhf (BZ 32918)
Adhemerval Zanella [Fri, 25 Apr 2025 20:54:22 +0000 (17:54 -0300)] 
math: Fix UB on atanhf (BZ 32918)

The left shift overflows for 'int', use unsigned instead.  It syncs
with CORE-MATH commit 4d6192d2.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 months agonptl: Fix pthread_getattr_np when modules with execstack are allowed (BZ 32897)
Adhemerval Zanella [Thu, 24 Apr 2025 15:27:44 +0000 (12:27 -0300)] 
nptl: Fix pthread_getattr_np when modules with execstack are allowed (BZ 32897)

The BZ 32653 fix (12a497c716f0a06be5946cabb8c3ec22a079771e) kept the
stack pointer zeroing from make_main_stack_executable on
_dl_make_stack_executable.  However, previously the 'stack_endp'
pointed to temporary variable created before the call of
_dl_map_object_from_fd; while now we use the __libc_stack_end
directly.

Since pthread_getattr_np relies on correct __libc_stack_end, if
_dl_make_stack_executable is called (for instance, when
glibc.rtld.execstack=2 is set) __libc_stack_end will be set to zero,
and the call will always fail.

The __libc_stack_end zero was used a mitigation hardening, but since
52a01100ad011293197637e42b5be1a479a2f4ae it is used solely on
pthread_getattr_np code.  So there is no point in zeroing anymore.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Sam James <sam@gentoo.org>
3 months agoRISC-V: Use builtin for ffs and ffsll while supported extension available
Julian Zhu [Fri, 8 Nov 2024 13:41:43 +0000 (21:41 +0800)] 
RISC-V: Use builtin for ffs and ffsll while supported extension available

Hardware ctz instructions are available in the RISC-V Zbb and XTheadBb extension. With special `-march` flags defined, we can generate more simplified code compared to the generic implementation of `ffs`/`ffsll`.

Signed-off-by: Julian Zhu <julian.oerv@isrc.iscas.ac.cn>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agostdio: Remove UB on printf_fp
Adhemerval Zanella [Fri, 25 Apr 2025 21:06:33 +0000 (18:06 -0300)] 
stdio: Remove UB on printf_fp

The __printf_fp_buffer_1 issues count_leading_zeros with 0 argument,
which might leads to call __builtin_ctz depending of the ABI.
Replace with stdbit.h function instead.

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
3 months agobenchtest: Correct shell script related to bench-malloc-thread
Cupertino Miranda [Fri, 25 Apr 2025 14:38:25 +0000 (16:38 +0200)] 
benchtest: Correct shell script related to bench-malloc-thread

This patch changes the shell script that selects which arguments are used
for the execution of bench-malloc-thread.
The problem seems to have been introduced in commit:

  commit 2d6427a63cad8056ba6bcaaaa8df21977c8dde3d
  Author: Wangyang Guo <wangyang.guo@intel.com>
  Date:   Fri Nov 29 16:05:35 2024 +0800
  benchtests: Add calloc test

With current condition, the following error "/bin/sh: 3: [[: not found"
occurs when executing `make bench BENCHSET="malloc-thread"` and the else
path is taken, using incorrect arguments for bench test execution.

Error is reproducible in Debian based distros.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agolinux/termio: remove <termio.h> and struct termio
H. Peter Anvin [Fri, 25 Apr 2025 05:30:59 +0000 (07:30 +0200)] 
linux/termio: remove <termio.h> and struct termio

The <termio.h> interface is absolutely ancient: it was obsoleted by
<termios.h> already in the first version of POSIX (1988) and thus
predates the very first version of Linux. Unfortunately, some constant
macros are used both by <termio.h> and <termios.h>; particularly
problematic is the baud rate constants since the termio interface
*requires* that the baud rate is set via an enumeration as part of
c_cflag.

In preparation of revamping the termios interface to support the
arbitrary baud rate capability that the Linux kernel has supported
since 2008, remove <termio.h> in the hope that no one still uses this
archaic interface.

Note that there is no actual code in glibc to support termio: it is
purely an unabstracted ioctl() interface.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agoelf: tst-audit10: split AVX512F code into dedicated functions [BZ #32882]
Aurelien Jarno [Sat, 19 Apr 2025 18:45:07 +0000 (20:45 +0200)] 
elf: tst-audit10: split AVX512F code into dedicated functions [BZ #32882]

"Recent" GCC versions (since commit fc62716fe8d1, backported to stable
branches) emit a vzeroupper instruction at the end of functions
containing AVX instructions. This causes the tst-audit10 test to fail
on CPUs lacking AVX instructions, despite the AVX512F check. The crash
occurs in the pltenter function of tst-auditmod10b.c.

Fix that by moving the code guarded by the check_avx512 function into
specific functions using the target ("avx512f") attribute. Note that
since commit 5359c3bc91cc ("x86-64: Remove compiler -mavx512f check") it
is safe to assume that the compiler has AVX512F support, thus the
__AVX512F__ checks can be dropped.

Tested on non-AVX, AVX2 and AVX512F machines.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 months agoAdd NT_ARM_GCS and NT_RISCV_TAGGED_ADDR_CTRL from Linux 6.13 to elf.h
Joseph Myers [Tue, 22 Apr 2025 17:02:23 +0000 (17:02 +0000)] 
Add NT_ARM_GCS and NT_RISCV_TAGGED_ADDR_CTRL from Linux 6.13 to elf.h

Linux 6.13 adds new ELF note types NT_ARM_GCS and
NT_RISCV_TAGGED_ADDR_CTRL.  Add these to glibc's elf.h.

Tested for x86_64.

3 months agoAdd AT_* constants from Linux 6.12
Joseph Myers [Tue, 22 Apr 2025 17:00:34 +0000 (17:00 +0000)] 
Add AT_* constants from Linux 6.12

Linux 6.12 adds AT_RENAME_* aliases for RENAME_* flags for renameat2,
and also AT_HANDLE_MNT_ID_UNIQUE.  Add the first set of aliases to
stdio.h alongside the RENAME_* names, and AT_HANDLE_MNT_ID_UNIQUE to
bits/fcntl-linux.h.

Tested for x86_64.

3 months agohurd: Make symlink return EEXIST on existing target directory
Samuel Thibault [Mon, 21 Apr 2025 20:21:17 +0000 (22:21 +0200)] 
hurd: Make symlink return EEXIST on existing target directory

8ef17919509e ("hurd: Fix EINVAL error on linking to a slash-trailing path
[BZ #32569]) made symlink return ENOTDIR, but the gnulib testsuite does
not recognize it for such a situation, and EEXIST is indeed more
comprehensible to users.

3 months agohurd: Clear FP exceptions before calling signal handler
Samuel Thibault [Mon, 21 Apr 2025 17:58:04 +0000 (19:58 +0200)] 
hurd: Clear FP exceptions before calling signal handler

This avoids SIGFPE handlers (or code longjmp-ed to) getting disturbed by the
exception that generated it.

Note: gcc's unwinding depends on the rpc_wait_trampoline/trampoline exact
code, so we here avoid breaking it.

3 months agohurd: Do not check for xstate level if it was not initialized
Samuel Thibault [Mon, 21 Apr 2025 17:45:02 +0000 (19:45 +0200)] 
hurd: Do not check for xstate level if it was not initialized

If __thread_get_state failed, there is no xstate level to check.
ok is 0 already and the memory exists, but better not read uninitialized
memory.

3 months agohurd: Do not restore xstate when it is not initialized
Samuel Thibault [Mon, 21 Apr 2025 17:42:27 +0000 (19:42 +0200)] 
hurd: Do not restore xstate when it is not initialized

If the process has never used fp before getting a signal, xstate is set
(and thus the x87 state is not initialized) but xstate->initialized is still
0, and we should not restore anything.

3 months agohurd: Make *utime*s catch invalid times [BZ #32802, BZ #32803]
Samuel Thibault [Tue, 18 Mar 2025 17:49:21 +0000 (18:49 +0100)] 
hurd: Make *utime*s catch invalid times [BZ #32802, BZ #32803]

3 months agohurd: save xstate during signal handling
Luca Dariz [Wed, 19 Mar 2025 17:11:18 +0000 (18:11 +0100)] 
hurd: save xstate during signal handling

* hurd/Makefile: add new tests
* hurd/test-sig-rpc-interrupted.c: check xstate save and restore in
  the case where a signal is delivered to a thread which is waiting
  for an rpc. This test implements the rpc interruption protocol used
  by the hurd servers. It was so far passing on Debian thanks to the
  local-intr-msg-clobber.diff patch, which is now obsolete.
* hurd/test-sig-xstate.c: check xstate save and restore in the case
  where a signal is delivered to a running thread, making sure that
  the xstate is modified in the signal handler.
* hurd/test-xstate.h: add helpers to test xstate
* sysdeps/mach/hurd/i386/bits/sigcontext.h: add xstate to the
  sigcontext structure.
+ sysdeps/mach/hurd/i386/sigreturn.c: restore xstate from the saved
  context
* sysdeps/mach/hurd/x86/trampoline.c: save xstate if
  supported. Otherwise we fall back to the previous behaviour of
  ignoring xstate.
* sysdeps/mach/hurd/x86_64/bits/sigcontext.h: add xstate to the
  sigcontext structure.
* sysdeps/mach/hurd/x86_64/sigreturn.c: restore xstate from the saved
  context

Signed-off-by: Luca Dariz <luca@orpolo.org>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-ID: <20250319171118.142163-1-luca@orpolo.org>

3 months agohurd: Check return value of mach_port_mod_refs() in the dup routine of fcntl()
Zhaoming Luo [Mon, 10 Mar 2025 08:44:09 +0000 (16:44 +0800)] 
hurd: Check return value of mach_port_mod_refs() in the dup routine of fcntl()

Message-ID: <20250310084409.24177-1-zhmingluo@163.com>

3 months agomalloc: move tcache_init out of hot tcache paths
Cupertino Miranda [Wed, 16 Apr 2025 11:22:53 +0000 (11:22 +0000)] 
malloc: move tcache_init out of hot tcache paths

This patch moves any calls of tcache_init away after tcache hot paths.
Since there is no reason to initialize tcaches in the hot path and since
we need to be able to check tcache != NULL in any case, because of
tcache_thread_shutdown function, moving tcache_init away from hot path
can only be beneficial.
The patch also removes the initialization of tcaches within the
__libc_free call. It only makes sense to initialize tcaches for the
thread after it calls one of the allocation functions. Also the patch
removes the save/restore of errno from tcache_init code, as it is no
longer needed.

3 months agoaarch64: Add back non-temporal load/stores from oryon-1's memset
Andrew Pinski [Fri, 21 Feb 2025 23:13:53 +0000 (15:13 -0800)] 
aarch64: Add back non-temporal load/stores from oryon-1's memset

I misunderstood the recommendation from the hardware team about non-temporal
load/stores. It is still recommended to use them in memset for large sizes. It
was not recommended for their use with device memory and memset is already
not valid to be used with device memory.

This reverts commit e6590f0c86632c36c9a784cf96075f4be2e920d2.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agoaarch64: Add back non-temporal load/stores from oryon-1's memcpy
Andrew Pinski [Fri, 21 Feb 2025 23:10:18 +0000 (15:10 -0800)] 
aarch64: Add back non-temporal load/stores from oryon-1's memcpy

I misunderstood the recommendation from the hardware team about non-temporal
load/stores. It is still recommended to use them in memcpy for large sizes. It
was not recommended for their use with device memory and memcpy is already
not valid to be use with device memory.

This reverts commit eb5eeb47403e0a91de834868e501b4d62b8d2cb9.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 months agomalloc: Use tailcalls in __libc_free
Wilco Dijkstra [Mon, 31 Mar 2025 12:19:06 +0000 (12:19 +0000)] 
malloc: Use tailcalls in __libc_free

Use tailcalls to avoid the overhead of a frame on the free fastpath.
Move tcache initialization to _int_free_chunk().  Add malloc_printerr_tail()
which can be tailcalled without forcing a frame like no-return functions.
Change tcache_double_free_verify() to retry via __libc_free() after clearing
the key.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agomalloc: Inline tcache_free
Wilco Dijkstra [Mon, 31 Mar 2025 11:51:44 +0000 (11:51 +0000)] 
malloc: Inline tcache_free

Inline tcache_free since it's only used by __libc_free.  Add __glibc_likely
for the tcache checks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agomalloc: Improve free checks
Wilco Dijkstra [Mon, 31 Mar 2025 11:44:02 +0000 (11:44 +0000)] 
malloc: Improve free checks

The checks on size can be merged and use __builtin_add_overflow.  Since
tcache only handles small sizes (and rejects sizes < MINSIZE), delay this
check until after tcache.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agomalloc: Inline _int_free_check
Wilco Dijkstra [Mon, 31 Mar 2025 11:28:14 +0000 (11:28 +0000)] 
malloc: Inline _int_free_check

Inline _int_free_check since it is only used by __libc_free.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agomalloc: Inline _int_free
Wilco Dijkstra [Mon, 31 Mar 2025 11:24:58 +0000 (11:24 +0000)] 
malloc: Inline _int_free

Inline _int_free since it is a small function and only really used by
__libc_free.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agomalloc: Move mmap code out of __libc_free hotpath
Wilco Dijkstra [Mon, 24 Mar 2025 18:23:37 +0000 (18:23 +0000)] 
malloc: Move mmap code out of __libc_free hotpath

Currently __libc_free checks for a freed mmap chunk in the fast path.
Also errno is always saved and restored to preserve it.  Since mmap chunks
are larger than the largest tcache chunk, it is safe to delay this and
handle tcache, smallbin and medium bin blocks first.  Move saving of errno
to cases that actually need it.  Remove a safety check that fails on mmap
chunks and a check that mmap chunks cannot be added to tcache.

Performance of bench-malloc-thread improves by 9.2% for 1 thread and
6.9% for 32 threads on Neoverse V2.

Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
3 months agomanual/tunables: fix a trivial typo
Aurelien Jarno [Sun, 13 Apr 2025 15:33:23 +0000 (17:33 +0200)] 
manual/tunables: fix a trivial typo

Fixes: 12a497c716f0 ("elf: Extend glibc.rtld.execstack tunable to force executable stack (BZ 32653)"
Reviewed-by: Florian Weimer <fweimer@redhat.com>