]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 months agoMakefile: Clean up pthread_atfork integration
Florian Weimer [Wed, 12 Mar 2025 10:29:10 +0000 (11:29 +0100)] 
Makefile: Clean up pthread_atfork integration

Do not add the pthread_atfork routine again in nptl/Makefile,
instead rely on sysdeps/pthread/Makefile for the integration
(as this is the directory that contains the source file).

In sysdeps/pthread/Makefile, add to static-only-routines.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
4 months agonptl: Include <stdbool.h> in tst-pthread_gettid_np.c
Florian Weimer [Wed, 12 Mar 2025 10:10:14 +0000 (11:10 +0100)] 
nptl: Include <stdbool.h> in tst-pthread_gettid_np.c

The test uses the while (true) construct.

4 months agoLinux: Add new test misc/tst-sched_setattr-thread
Florian Weimer [Wed, 12 Mar 2025 09:23:47 +0000 (10:23 +0100)] 
Linux: Add new test misc/tst-sched_setattr-thread

The straightforward sched_getattr call serves as a test for
bug 32781, too.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
4 months agoLinux: Remove attribute access from sched_getattr (bug 32781)
Florian Weimer [Wed, 12 Mar 2025 09:23:47 +0000 (10:23 +0100)] 
Linux: Remove attribute access from sched_getattr (bug 32781)

The GCC attribute expects an element count, not bytes.

4 months agoLinux: Add the pthread_gettid_np function (bug 27880)
Florian Weimer [Wed, 12 Mar 2025 09:16:31 +0000 (10:16 +0100)] 
Linux: Add the pthread_gettid_np function (bug 27880)

Current Bionic has this function, with enhanced error checking
(the undefined case terminates the process).

Reviewed-by: Joseph Myers <josmyers@redhat.com>
4 months agoelf: Test dlopen (NULL, RTLD_LAZY) from an ELF constructor
Florian Weimer [Tue, 11 Mar 2025 14:30:52 +0000 (15:30 +0100)] 
elf: Test dlopen (NULL, RTLD_LAZY) from an ELF constructor

This call must not complete initialization of all shared objects
in the global scope because the ELF constructor which makes the call
likely has not finished initialization.  Calling more constructors
at this point would expose those to a partially constructed
dependency.

This completes the revert of commit 9897ced8e78db5d813166a7ccccfd5a
("elf: Run constructors on cyclic recursive dlopen (bug 31986)").

4 months agos390x: Regenerate ULPs.
Stefan Liebler [Tue, 11 Mar 2025 10:24:59 +0000 (11:24 +0100)] 
s390x: Regenerate ULPs.

Needed due to:
"Implement C23 rsqrt"
commit ID 77261698b4e938020a1b2032709a54d942ba330f

Same max ulps as used for x86_64 in the mentioned commit.

4 months agomath: Remove an extra semicolon in math function declarations
Aurelien Jarno [Thu, 6 Mar 2025 18:34:15 +0000 (19:34 +0100)] 
math: Remove an extra semicolon in math function declarations

Commit 6bc301672bfbd ("math: Remove __XXX math functions from installed
math.h [BZ #32418]") left an extra semicolon after macro expansion. For
instance the ceil declaration after expansion is:

  extern double ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));;

This chokes very naive parsers like gauche c-wrapper. Fix that by
removing that extra semicolon in the macro.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agonptl: extend test coverage for sched_yield
Sergey Kolosov [Tue, 28 Jan 2025 22:56:26 +0000 (23:56 +0100)] 
nptl: extend test coverage for sched_yield

We add sched_yield() API testing to the existing thread affinity
test case because it allows us to test sched_yield() operation
in the following scenarios:

  * On a main thread.
  * On multiple threads simultaneously.
  * On every CPU the system reports simultaneously.

The ensures we exercise sched_yield() in as many scenarios as
we would exercise calls to the affinity functions.

Additionally, the test is improved by adding a semaphore to coordinate
all the threads running, so that an early starter thread won't consume
cpu resources that could be used to start the other threads.

Co-authored-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 months agoposix: Move environ helper variables next to environ definition (bug 32541)
Florian Weimer [Fri, 7 Mar 2025 20:40:55 +0000 (21:40 +0100)] 
posix: Move environ helper variables next to environ definition (bug 32541)

This helps with statically interposing getenv.

Updates commit 7a61e7f557a97ab597d6fca5e2d1f13f65685c61
("stdlib: Make getenv thread-safe in more cases").

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
4 months agoImplement C23 rsqrt
Joseph Myers [Fri, 7 Mar 2025 19:15:26 +0000 (19:15 +0000)] 
Implement C23 rsqrt

C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the rsqrt functions (1/sqrt(x)).  The test inputs are
taken from those for sqrt.

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

4 months agoUse binutils 2.44 branch and Linux 6.13 in build-many-glibcs.py
Joseph Myers [Fri, 7 Mar 2025 17:38:38 +0000 (17:38 +0000)] 
Use binutils 2.44 branch and Linux 6.13 in build-many-glibcs.py

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

4 months agoelf: Fix handling of symbol versions which hash to zero (bug 29190)
Florian Weimer [Fri, 7 Mar 2025 16:37:50 +0000 (17:37 +0100)] 
elf: Fix handling of symbol versions which hash to zero (bug 29190)

This was found through code inspection.  No application impact is
known.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agoconfigure: Fix spelling of -Wl,--no-error-execstack option
Florian Weimer [Fri, 7 Mar 2025 06:52:11 +0000 (07:52 +0100)] 
configure: Fix spelling of -Wl,--no-error-execstack option

BFD ld recognizes all -no-* options (with a single leading dash)
unconditionally.

Fixes commit a2bd5008a99032830add3e4005c25b61e3207112
("Pass -Wl,--no-error-execstack for tests where -Wl,-z,execstack
is used [PR32717]").

4 months agomanual: Mark perror as MT-unsafe and update check-safety.sh
Carlos O'Donell [Thu, 20 Feb 2025 19:26:45 +0000 (14:26 -0500)] 
manual: Mark perror as MT-unsafe and update check-safety.sh

The manual marked perror as MT-safe, but then listed a remark
indicating that it was unsafe because of a race between the function
and access to stderr.  The function is indeed MT-unsafe because
of the unlocked access to stderr internals and bug 32730 has been
filed to address this issue.

The script manual/check-safety.sh should have caught this issue,
but a missed escaping of "?" along with searching of all inputs
again via "$@" resulted in a non-functional regexp.

In order to avoid regressions we also update check-safety.sh.

The script manual/check-safety.sh is updated in the following ways:

 * The MT-unsafe remarks in MT-safe context check is fixed.
   - It now detects the perror safety note mistake.

 * Comments updated indicating that we allow MT context marks
   to count for other contexts if they are related.
   - This is why commit ad9c4c536115ba38be3e63592a632709ec8209b4
     failed and the failure is now understood as expected.

 * All checks now have verbose output.

 * Back reference based duplicate checks are removed.
   - They are too complex and don't cover all cases.

No regressions on x86_64.

4 months agoelf: Check if __attribute__ ((aligned (65536))) is supported
H.J. Lu [Fri, 7 Mar 2025 00:58:47 +0000 (08:58 +0800)] 
elf: Check if __attribute__ ((aligned (65536))) is supported

The BZ #32763 tests fail to build for MicroBlaze (which defines
MAX_OFILE_ALIGNMENT to (32768*8) in GCC, so __attribute__ ((aligned
(65536))) is unsupported).  Add a configure-time check to enable BZ #32763
tests only if __attribute__ ((aligned (65536))) is supported.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
4 months agohtl: Make __pthread_create_internal directly call __pthread_sigmask
Samuel Thibault [Wed, 5 Mar 2025 23:15:25 +0000 (00:15 +0100)] 
htl: Make __pthread_create_internal directly call __pthread_sigmask

__pthread_sigmask will already know to pass our current ss to
__sigthreadmask.

4 months agohtl: Make __pthread_sigmask directly call __sigthreadmask
Samuel Thibault [Wed, 5 Mar 2025 23:14:06 +0000 (00:14 +0100)] 
htl: Make __pthread_sigmask directly call __sigthreadmask

If no thread was created yet, __pthread_sigstate will not find our ss
because self->kernel_thread is still nul, and then change the global
sigstate instead of our sigstate! We can directly call __sigthreadmask and
skip the (bogus) lookup step.

4 months agohurd: Consolidate signal mask change
Samuel Thibault [Wed, 5 Mar 2025 23:10:40 +0000 (00:10 +0100)] 
hurd: Consolidate signal mask change

__pthread_sigstate and __sigprocmask were already the same, except for
clear_pending.

4 months agostatic-pie: Skip the empty PT_LOAD segment at offset 0 [BZ #32763]
H.J. Lu [Wed, 5 Mar 2025 02:19:59 +0000 (10:19 +0800)] 
static-pie: Skip the empty PT_LOAD segment at offset 0 [BZ #32763]

As shown in

https://sourceware.org/bugzilla/show_bug.cgi?id=25237

linker may generate an empty PT_LOAD segments at offset 0:

Elf file type is EXEC (Executable file)
Entry point 0x4000e8
There are 3 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x00000000000000f0 0x00000000000000f0  R E    0x1000
  LOAD           0x0000000000000000 0x0000000000410000 0x0000000000410000
                 0x0000000000000000 0x0000000000b5dce8  RW     0x10000
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10

 Section to Segment mapping:
  Segment Sections...
   00     .text
   01     .bss
   02

Skip the empty PT_LOAD segment at offset 0 to support such binaries.
This fixes BZ #32763.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
4 months agosysdeps: linux: Add BTRFS_SUPER_MAGIC to pathconf
Ronan Pigott [Thu, 6 Feb 2025 22:47:57 +0000 (15:47 -0700)] 
sysdeps: linux: Add BTRFS_SUPER_MAGIC to pathconf

btrfs has a 65535 maximum link count. Include this value in pathconf to
give the real max link count for this filesystem.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agolinux: Prefix AT_HWCAP with 0x on LD_SHOW_AUXV
Adhemerval Zanella [Wed, 26 Feb 2025 18:50:05 +0000 (15:50 -0300)] 
linux: Prefix AT_HWCAP with 0x on LD_SHOW_AUXV

Suggested-by: Stefan Liebler <stli@linux.ibm.com>
Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
4 months agoRemove dl-procinfo.h
Adhemerval Zanella [Wed, 26 Feb 2025 17:11:44 +0000 (17:11 +0000)] 
Remove dl-procinfo.h

powerpc was the only architecture with arch-specific hooks for
LD_SHOW_AUXV, and with the information moved to ld diagnostics there
is no need to keep the _dl_procinfo hook.

Checked with a build for all affected ABIs.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
4 months agopowerpc: Remove unused dl-procinfo.h
Adhemerval Zanella [Wed, 26 Feb 2025 17:09:50 +0000 (17:09 +0000)] 
powerpc: Remove unused dl-procinfo.h

The _dl_string_platform is moved to hwcapinfo.h, since it is only used
by hwcapinfo.c and test-get_hwcap internal test.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
4 months agopowerpc: Move cache geometry information to ld diagnostics
Adhemerval Zanella [Wed, 26 Feb 2025 16:28:41 +0000 (16:28 +0000)] 
powerpc: Move cache geometry information to ld diagnostics

From LD_SHOW_AUXV output.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
4 months agopowerpc: Move AT_HWCAP descriptions to ld diagnostics
Adhemerval Zanella [Wed, 26 Feb 2025 15:54:17 +0000 (12:54 -0300)] 
powerpc: Move AT_HWCAP descriptions to ld diagnostics

The ld.so diagnostics already prints AT_HWCAP values, but only in
hexadecimal.  To avoid duplicating the strings, consolidate the
hwcap_names from cpu-features.h on a new file, dl-hwcap-info.h
(and it also improves the hwcap string description with more
values).

For future AT_HWCAP3/AT_HWCAP4 extensions, it is just a matter
to add them on dl-hwcap-info.c so both ld diagnostics and
tunable filtering will parse the new values.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
4 months agobenchtests: Add random strlen benchmark
Wilco Dijkstra [Mon, 29 Jul 2024 12:48:56 +0000 (12:48 +0000)] 
benchtests: Add random strlen benchmark

Add a new randomized strlen test similar to bench-random-memcpy.  Instead of
repeating the same call to strlen over and over again, it times a large number
of different strings.  The distribution of the string length and alignment is
based on SPEC2017.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
4 months agobenchtests: Improve large memcpy/memset benchmarks
Wilco Dijkstra [Mon, 18 Mar 2024 15:05:38 +0000 (15:05 +0000)] 
benchtests: Improve large memcpy/memset benchmarks

Adjust sizes between 64KB and 16MB and iterations based on length.
Remove incorrect uses of alloc_bufs since we're not interested in measuring
Linux clear_page time.  Use getpagesize() - 1 instead of 4095 when
aligning within a page.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
4 months agomanual: Explain sched_yield semantics with different schedulers
Siddhesh Poyarekar [Thu, 30 Jan 2025 15:05:17 +0000 (10:05 -0500)] 
manual: Explain sched_yield semantics with different schedulers

The manual entry for sched_yield mentions that the function call could
be a nop if there are no other tasks with the same absolute priority.
Expand the explanation to include example schedulers on Linux so that
it's clear that sched_yield may not always result in a different task
being scheduled.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Joseph Myers <josmyers@redhat.com>
4 months agoPass -Wl,--no-error-execstack for tests where -Wl,-z,execstack is used [PR32717]
Sam James [Tue, 18 Feb 2025 18:49:09 +0000 (18:49 +0000)] 
Pass -Wl,--no-error-execstack for tests where -Wl,-z,execstack is used [PR32717]

When GNU Binutils is configured with --enable-error-execstack=yes, a handful
of our tests which rely on -Wl,-z,execstack fail. Pass --Wl,--no-error-execstack
to override the behaviour and get a warning instead.

Bug: https://sourceware.org/PR32717
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 months agomalloc: Add integrity check to largebin nextsizes
Ben Kallus [Fri, 14 Feb 2025 05:34:54 +0000 (00:34 -0500)] 
malloc: Add integrity check to largebin nextsizes

If attacker overwrites the bk_nextsize link in the first chunk of a
largebin that later has a smaller chunk inserted into it, malloc will
write a heap pointer into an attacker-controlled address [0].

This patch adds an integrity check to mitigate this attack.

[0]: https://github.com/shellphish/how2heap/blob/master/glibc_2.39/large_bin_attack.c

Signed-off-by: Ben Kallus <benjamin.p.kallus.gr@dartmouth.edu>
Reviewed-by: DJ Delorie <dj@redhat.com>
4 months agolibio: Clean up fputc/putc comments
Samuel Zeter [Fri, 28 Feb 2025 02:05:20 +0000 (12:05 +1000)] 
libio: Clean up fputc/putc comments

Remove duplicate comments in stdio.h

Signed-off-by: Samuel Zeter <samuelzeter@gmail.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
4 months agohtl: move pthread_once into libc
Samuel Thibault [Sun, 2 Mar 2025 14:16:45 +0000 (15:16 +0100)] 
htl: move pthread_once into libc

5 months agoRemove unused dl-procinfo.h
Wilco Dijkstra [Fri, 28 Feb 2025 16:52:25 +0000 (16:52 +0000)] 
Remove unused dl-procinfo.h

Remove unused _dl_hwcap_string defines.  As a result many dl-procinfo.h headers
can be removed.  This also removes target specific _dl_procinfo implementations
which only printed HWCAP strings using dl_hwcap_string.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoLoongArch: Optimize f{max,min}imum_mag_num{,f}
Xi Ruoyao [Mon, 24 Feb 2025 12:49:18 +0000 (20:49 +0800)] 
LoongArch: Optimize f{max,min}imum_mag_num{,f}

Following the logic of the previous commits.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
5 months agoLoongArch: Optimize f{max,min}imum_num{,f}
Xi Ruoyao [Mon, 24 Feb 2025 12:49:17 +0000 (20:49 +0800)] 
LoongArch: Optimize f{max,min}imum_num{,f}

Following the logic of the previous commits.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
5 months agoLoongArch: Optimize f{max,min}imum_mag{,f}
Xi Ruoyao [Mon, 24 Feb 2025 12:49:16 +0000 (20:49 +0800)] 
LoongArch: Optimize f{max,min}imum_mag{,f}

Following the logic of the previous commit.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
5 months agoLoongArch: Optimize f{max,min}imum{,f}
Xi Ruoyao [Mon, 24 Feb 2025 12:49:15 +0000 (20:49 +0800)] 
LoongArch: Optimize f{max,min}imum{,f}

The code now looks like:

fclass.s        $fa2, $fa0
movfr2gr.s      $t0, $fa2
slli.w          $t0, $t0, 0x0
fclass.s        $fa2, $fa1
movfr2gr.s      $t1, $fa2
or              $t0, $t0, $t1
andi            $t0, $t0, 0x3
bnez            $t0, 1f
fmin.s          $fa0, $fa0, $fa1
ret
1:
fmul.s $fa0, $fa0, $fa1
ret

This looks really bad, with expensive movfr2gr instructions, redundant
sign-extensions and masking (arguably it's a compiler
missed-optimzation), and a branch.  Rewrite it with inline assembly:

fcmp.cor.s      $fcc0, $fa0, $fa0
fcmp.cor.s      $fcc1, $fa1, $fa1
fsel            $fa2, $fa0, $fa1, $fcc0
fsel            $fa0, $fa1, $fa0, $fcc1
fmax.s          $fa0, $fa2, $fa0
ret

Note that we cannot make it more readable with
"double a = __builtin_isnanf (x) ? y : x" because this C statement only
happens to produce what we want with https://gcc.gnu.org/PR66462, if
this bug is fixed in the future the generated code may change.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
5 months agoAArch64: Use prefer_sve_ifuncs for SVE memset
Wilco Dijkstra [Thu, 27 Feb 2025 16:28:52 +0000 (16:28 +0000)] 
AArch64: Use prefer_sve_ifuncs for SVE memset

Use prefer_sve_ifuncs for SVE memset just like memcpy.

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
5 months agosysdeps/ieee754: Fix remainder sign of zero for FE_DOWNWARD (BZ #32711)
Sergei Zimmerman [Tue, 25 Feb 2025 18:05:40 +0000 (18:05 +0000)] 
sysdeps/ieee754: Fix remainder sign of zero for FE_DOWNWARD (BZ #32711)

Single-precision remainderf() and quad-precision remainderl()
implementation derived from Sun is affected by an issue when the result
is +-0. IEEE754 requires that if remainder(x, y) = 0, its sign shall be
that of x regardless of the rounding direction.

The implementation seems to have assumed that x - x = +0 in all
rounding modes, which is not the case. When rounding direction is
roundTowardNegative the sign of an exact zero sum (or difference) is −0.

Regression tests that triggered this erroneous behavior are added to
math/libm-test-remainder.inc.

Tested for cross riscv64 and powerpc.

Original fix by: Bruce Evans <bde@FreeBSD.org> in FreeBSD's
a2ddfa5ea726c56dbf825763ad371c261b89b7c7.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agomath: Add optimization barrier to ensure a1 + u.d is not reused [BZ #30664]
John David Anglin [Tue, 25 Feb 2025 20:57:53 +0000 (15:57 -0500)] 
math: Add optimization barrier to ensure a1 + u.d is not reused [BZ #30664]

A number of fma tests started to fail on hppa when gcc was changed to
use Ranger rather than EVRP.  Eventually I found that the value of
a1 + u.d in this is block of code was being computed in FE_TOWARDZERO
mode and not the original rounding mode:

    if (TININESS_AFTER_ROUNDING)
      {
        w.d = a1 + u.d;
        if (w.ieee.exponent == 109)
          return w.d * 0x1p-108;
      }

This caused the exponent value to be wrong and the wrong return path
to be used.

Here we add an optimization barrier after the rounding mode is reset
to ensure that the previous value of a1 + u.d is not reused.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
5 months agoRISC-V: Fix IFUNC resolver cannot access gp pointer
Yangyu Chen [Mon, 24 Feb 2025 17:12:19 +0000 (01:12 +0800)] 
RISC-V: Fix IFUNC resolver cannot access gp pointer

In some cases, an IFUNC resolver may need to access the gp pointer to
access global variables. Such an object may have l_relocated == 0 at
this time. In this case, an IFUNC resolver will fail to access a global
variable and cause a SIGSEGV.

This patch fixes this issue by relaxing the check of l_relocated in
elf_machine_runtime_setup, but added a check for SHARED case to avoid
using this code in static-linked executables. Such object have already
set up the gp pointer in load_gp function and l->l_scope will be NULL if
it is a pie object. So if we use these code to set up the gp pointer
again for static-pie, it will causing a SIGSEGV in glibc as original bug
on BZ #31317.

I have also reproduced and checked BZ #31317 using the mold commit
bed5b1731b ("illumos: Treat absolute symbols specially"), this patch can
fix the issue.

Also, we used the wrong gp pointer previously because ref->st_value is
not the relocated address but just the offset from the base address of
ELF. An edge case may happen if we reference gp pointer in a IFUNC
resolver in a PIE object, but it will not happen in compiler-generated
codes since -pie will disable relax to gp. In this case, the GP will be
initialized incorrectly since the ref->st_value is not the address after
relocation. This patch fixes this issue by adding the l->l_addr to
ref->st_value to get the relocated address for the gp pointer. We don't
use SYMBOL_ADDRESS macro here because __global_pointer$ is a special
symbol that has SHN_ABS type, but it will use PC-relative addressing in
the load_gp function using lla.

Closes: BZ #32269
Fixes: 96d1b9ac23 ("RISC-V: Fix the static-PIE non-relocated object check")
Co-authored-by: Vivian Wang <dramforever@live.com>
Signed-off-by: Yangyu Chen <cyy@cyyself.name>
5 months agoAArch64: Remove LP64 and ILP32 ifdefs
Wilco Dijkstra [Thu, 2 Jan 2025 19:46:39 +0000 (19:46 +0000)] 
AArch64: Remove LP64 and ILP32 ifdefs

Remove LP64 and ILP32 ifdefs.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoAArch64: Simplify lrint
Wilco Dijkstra [Thu, 2 Jan 2025 19:46:07 +0000 (19:46 +0000)] 
AArch64: Simplify lrint

Simplify lrint.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoAArch64: Remove AARCH64_R macro
Wilco Dijkstra [Thu, 2 Jan 2025 18:35:28 +0000 (18:35 +0000)] 
AArch64: Remove AARCH64_R macro

Remove AArch64_R relocation macro.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoAArch64: Cleanup pointer mangling
Wilco Dijkstra [Thu, 2 Jan 2025 17:31:39 +0000 (17:31 +0000)] 
AArch64: Cleanup pointer mangling

Cleanup pointer mangling.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoAArch64: Remove PTR_REG defines
Wilco Dijkstra [Thu, 2 Jan 2025 14:39:39 +0000 (14:39 +0000)] 
AArch64: Remove PTR_REG defines

Remove PTR_REG defines.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoAArch64: Remove PTR_ARG/SIZE_ARG defines
Wilco Dijkstra [Tue, 31 Dec 2024 18:07:36 +0000 (18:07 +0000)] 
AArch64: Remove PTR_ARG/SIZE_ARG defines

This series removes various ILP32 defines that are now
no longer needed.

Remove PTR_ARG/SIZE_ARG.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agostdlib: Add single-threaded fast path to rand()
Wilco Dijkstra [Mon, 18 Mar 2024 15:18:20 +0000 (15:18 +0000)] 
stdlib: Add single-threaded fast path to rand()

Improve performance of rand() and __random() by adding a single-threaded
fast path.  Bench-random-lock shows about 5x speedup on Neoverse V1.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
5 months agoIncrease the amount of data tested in stdio-common/tst-fwrite-pipe.c
Stefan Liebler [Mon, 24 Feb 2025 13:13:00 +0000 (14:13 +0100)] 
Increase the amount of data tested in stdio-common/tst-fwrite-pipe.c

The number of iterations and the length of the string are not high
enough on some systems causing the test to return false-positives.

Testcase stdio-common/tst-fwrite-bz29459.c was fixed in the same way in
1b6f868625403d6b7683af840e87d2b18d5d7731
(Increase the amount of data tested in stdio-common/tst-fwrite-bz29459.c, 2025-02-14)

Testcases stdio-common/tst-fwrite-bz29459.c and stdio-common/tst-fwrite-pipe.c
were introcued in 596a61cf6b51ce2d58b8ca4e1d1f4fdfe1440dbc
(libio: Start to return errors when flushing fwrite's buffer [BZ #29459], 2025-01-28)

5 months agoposix: Rewrite cpuset tests
Frédéric Bérat [Fri, 29 Nov 2024 13:50:27 +0000 (14:50 +0100)] 
posix: Rewrite cpuset tests

Rewriting the cpuset macros test to cover more use cases and port the
tests to the new test infrastructure.

The use cases include bad actor access attempts, before and after the
CPU set structure.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
5 months agosupport: Add support_next_to_fault_before support function
Frédéric Bérat [Fri, 29 Nov 2024 13:48:43 +0000 (14:48 +0100)] 
support: Add support_next_to_fault_before support function

Refactor the support_next_to_fault and add the
support_next_to_fault_before method returns a buffer with a protected
page before it, to be able to test buffer underflow accesses.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
5 months agomath: Fix `unknown type name '__float128'` for clang 3.4 to 3.8.1 (bug 32694)
koraynilay [Sat, 22 Feb 2025 14:55:59 +0000 (15:55 +0100)] 
math: Fix `unknown type name '__float128'` for clang 3.4 to 3.8.1 (bug 32694)

When compiling a program that includes <bits/floatn.h> using a clang version
between 3.4 (included) and 3.8.1 (included), clang will fail with `unknown type
name '__float128'; did you mean '__cfloat128'?`. This changes fixes the clang
prerequirements macro call in floatn.h to check for clang 3.9 instead of 3.4,
since support for __float128 was actually enabled in 3.9 by:

commit 50f29e06a1b6a38f0bba9360cbff72c82d46cdd4
Author: Nemanja Ivanovic <nemanja.i.ibm@gmail.com>
Date:   Wed Apr 13 09:49:45 2016 +0000

    Enable support for __float128 in Clang

This fixes bug 32694.

Signed-off-by: koraynilay <koray.fra@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
5 months agonptl: clear the whole rseq area before registration
Michael Jeanson [Fri, 14 Feb 2025 18:54:22 +0000 (13:54 -0500)] 
nptl: clear the whole rseq area before registration

Due to the extensible nature of the rseq area we can't explictly
initialize fields that are not part of the ABI yet. It was agreed with
upstream that all new fields will be documented as zero initialized by
userspace. Future kernels configured with CONFIG_DEBUG_RSEQ will
validate the content of all fields during registration.

Replace the explicit field initialization with a memset of the whole
rseq area which will cover fields as they are added to future kernels.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
5 months agoaarch64: Add GCS test with signal handler
Yury Khrustalev [Thu, 23 Jan 2025 10:36:36 +0000 (10:36 +0000)] 
aarch64: Add GCS test with signal handler

Test that when we return from a function that enabled GCS at runtime
we get SIGSEGV. Also test that ucontext contains GCS block with the
GCS pointer.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoaarch64: Add GCS tests for dlopen
Yury Khrustalev [Wed, 22 Jan 2025 17:21:26 +0000 (17:21 +0000)] 
aarch64: Add GCS tests for dlopen

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoaarch64: Add GCS tests for transitive dependencies
Yury Khrustalev [Wed, 22 Jan 2025 15:06:18 +0000 (15:06 +0000)] 
aarch64: Add GCS tests for transitive dependencies

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoaarch64: Add tests for Guarded Control Stack
Yury Khrustalev [Tue, 21 Jan 2025 13:33:20 +0000 (13:33 +0000)] 
aarch64: Add tests for Guarded Control Stack

These tests validate that GCS tunable works as expected depending
on the GCS markings in the test binaries.

Tests validate both static and dynamically linked binaries.

These new tests are AArch64 specific. Moreover, they are included only
if linker supports the "-z gcs=<value>" option. If built, these tests
will run on systems with and without HWCAP_GCS. In the latter case the
tests will be reported as UNSUPPORTED.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoaarch64: Add configure checks for GCS support
Yury Khrustalev [Tue, 28 Jan 2025 16:13:51 +0000 (16:13 +0000)] 
aarch64: Add configure checks for GCS support

 - Add check that linker supports -z gcs=...
 - Add checks that main and test compiler support
   -mbranch-protection=gcs

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agomanual: Mark setlogmask as AS-unsafe and AC-unsafe.
Carlos O'Donell [Thu, 20 Feb 2025 01:52:14 +0000 (20:52 -0500)] 
manual: Mark setlogmask as AS-unsafe and AC-unsafe.

This fixes the check-safety.sh failure with commit
ad9c4c536115ba38be3e63592a632709ec8209b4, and correctly marks
the function AS-unsafe and AC-unsafe due to the use of the
non-recursive lock.

Tested on x86_64 without regressions.
Reviewed-by: Frédéric Bérat <fberat@redhat.com>
5 months agoAArch64: Add SVE memset
Wilco Dijkstra [Tue, 24 Dec 2024 18:01:59 +0000 (18:01 +0000)] 
AArch64: Add SVE memset

Add SVE memset based on the generic memset with predicated load for sizes < 16.
Unaligned memsets of 128-1024 are improved by ~20% on average by using aligned
stores for the last 64 bytes.  Performance of random memset benchmark improves
by ~2% on Neoverse V1.

Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
5 months agox86 (__HAVE_FLOAT128): Defined to 0 for Intel SYCL compiler [BZ #32723]
H.J. Lu [Wed, 19 Feb 2025 23:08:26 +0000 (07:08 +0800)] 
x86 (__HAVE_FLOAT128): Defined to 0 for Intel SYCL compiler [BZ #32723]

Intel compiler always defines __INTEL_LLVM_COMPILER.  When SYCL is
enabled by -fsycl, it also defines SYCL_LANGUAGE_VERSION.  Since Intel
SYCL compiler doesn't support _Float128:

https://github.com/intel/llvm/issues/16903

define __HAVE_FLOAT128 to 0 for Intel SYCL compiler.

This fixes BZ #32723.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
5 months agomanual: Document setlogmask as MT-safe.
Carlos O'Donell [Thu, 13 Feb 2025 19:27:55 +0000 (14:27 -0500)] 
manual: Document setlogmask as MT-safe.

setlogmask(3) was made MT-safe in glibc-2.33 with the fix for
bug 26100.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
5 months agomath: Consolidate acosf and asinf internal tables
Adhemerval Zanella [Thu, 13 Feb 2025 19:35:45 +0000 (16:35 -0300)] 
math: Consolidate acosf and asinf internal tables

The libm size improvement built with gcc-14, "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":

Before:

 582292     844      12  583148   8e5ec aarch64-linux-gnu/math/libm.so
 975133    1076      12  976221   ee55d x86_64-linux-gnu/math/libm.so
1203586    5608     368 1209562  1274da powerpc64le-linux-gnu/math/libm.so

After:

 581972     844      12  582828   8e4ac aarch64-linux-gnu/math/libm.so
 974941    1076      12  976029   ee49d x86_64-linux-gnu/math/libm.so
1203394    5608     368 1209370  12741a powerpc64le-linux-gnu/math/libm.so
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
5 months agomath: Consolidate acospif and asinpif internal tables
Adhemerval Zanella [Thu, 13 Feb 2025 19:35:44 +0000 (16:35 -0300)] 
math: Consolidate acospif and asinpif internal tables

The libm size improvement built with gcc-14, "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":

Before:

   text    data     bss     dec     hex filename
 583444     844      12  584300   8ea6c aarch64-linux-gnu/math/libm.so
 976349    1076      12  977437   eea1d x86_64-linux-gnu/math/libm.so
1204738    5608     368 1210714  12795a powerpc64le-linux-gnu/math/libm.so

After:

 582292     844      12  583148   8e5ec aarch64-linux-gnu/math/libm.so
 975133    1076      12  976221   ee55d x86_64-linux-gnu/math/libm.so
1203586    5608     368 1209562  1274da powerpc64le-linux-gnu/math/libm.so
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
5 months agomath: Consolidate cospif and sinpif internal tables
Adhemerval Zanella [Thu, 13 Feb 2025 19:35:43 +0000 (16:35 -0300)] 
math: Consolidate cospif and sinpif internal tables

The libm size improvement built with gcc-14, "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":

Before:

   text    data     bss     dec     hex filename
 584500     844      12  585356   8ee8c aarch64-linux-gnu/math/libm.so
 977341    1076      12  978429   eedfd x86_64-linux-gnu/math/libm.so
1205762    5608     368 1211738  127d5a powerpc64le-linux-gnu/math/libm.so

After:

   text    data     bss     dec     hex filename
 583444     844      12  584300   8ea6c aarch64-linux-gnu/math/libm.so
 976349    1076      12  977437   eea1d x86_64-linux-gnu/math/libm.so
1204738    5608     368 1210714  12795a powerpc64le-linux-gnu/math/libm.so
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
5 months agohtl: don't export __pthread_default_rwlockattr anymore.
gfleury [Sun, 16 Feb 2025 14:54:34 +0000 (16:54 +0200)] 
htl: don't export __pthread_default_rwlockattr anymore.

since now all symbloy that use it are in libc
Message-ID: <20250216145434.7089-11-gfleury@disroot.org>

5 months agohtl: move pthread_rwlock_init into libc.
gfleury [Sun, 16 Feb 2025 14:54:33 +0000 (16:54 +0200)] 
htl: move pthread_rwlock_init into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-10-gfleury@disroot.org>

5 months agohtl: move pthread_rwlock_destroy into libc.
gfleury [Sun, 16 Feb 2025 14:54:32 +0000 (16:54 +0200)] 
htl: move pthread_rwlock_destroy into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-9-gfleury@disroot.org>

5 months agohtl: move pthread_rwlock_{rdlock, timedrdlock, timedwrlock, wrlock, clockrdlock,...
gfleury [Sun, 16 Feb 2025 14:54:31 +0000 (16:54 +0200)] 
htl: move pthread_rwlock_{rdlock, timedrdlock, timedwrlock, wrlock, clockrdlock, clockwrlock} into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-8-gfleury@disroot.org>

5 months agohtl: move pthread_rwlock_unlock into libc.
gfleury [Sun, 16 Feb 2025 14:54:30 +0000 (16:54 +0200)] 
htl: move pthread_rwlock_unlock into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-7-gfleury@disroot.org>

5 months agohtl: move pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock into libc.
gfleury [Sun, 16 Feb 2025 14:54:29 +0000 (16:54 +0200)] 
htl: move pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-6-gfleury@disroot.org>

5 months agohtl: move pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared into libc.
gfleury [Sun, 16 Feb 2025 14:54:28 +0000 (16:54 +0200)] 
htl: move pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-5-gfleury@disroot.org>

5 months agohtl: move pthread_rwlockattr_destroy into libc.
gfleury [Sun, 16 Feb 2025 14:54:27 +0000 (16:54 +0200)] 
htl: move pthread_rwlockattr_destroy into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-4-gfleury@disroot.org>

5 months agohtl: move pthread_rwlockattr_init into libc.
gfleury [Sun, 16 Feb 2025 14:54:26 +0000 (16:54 +0200)] 
htl: move pthread_rwlockattr_init into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-3-gfleury@disroot.org>

5 months agohtl: move __pthread_default_rwlockattr into libc.
gfleury [Sun, 16 Feb 2025 14:54:25 +0000 (16:54 +0200)] 
htl: move __pthread_default_rwlockattr into libc.

Signed-off-by: gfleury <gfleury@disroot.org>
Message-ID: <20250216145434.7089-2-gfleury@disroot.org>

5 months agoFix tst-aarch64-pkey to handle ENOSPC as not supported
Aurelien Jarno [Sat, 15 Feb 2025 10:08:33 +0000 (11:08 +0100)] 
Fix tst-aarch64-pkey to handle ENOSPC as not supported

The syscall pkey_alloc can return ENOSPC to indicate either that all
keys are in use or that the system runs in a mode in which memory
protection keys are disabled. In such case the test should not fail and
just return unsupported.

This matches the behaviour of the generic tst-pkey.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
5 months agoIncrease the amount of data tested in stdio-common/tst-fwrite-bz29459.c
Tulio Magno Quites Machado Filho [Wed, 5 Feb 2025 20:20:34 +0000 (17:20 -0300)] 
Increase the amount of data tested in stdio-common/tst-fwrite-bz29459.c

The number of iterations and the length of the string are not high
enough on some systems causing the test to return false-positives.

Fixes: 596a61cf6b (libio: Start to return errors when flushing fwrite's buffer [BZ #29459], 2025-01-28)
Reported-by: Florian Weimer <fweimer@redhat.com>
5 months agoelf: Keep using minimal malloc after early DTV resize (bug 32412)
Florian Weimer [Thu, 13 Feb 2025 20:56:52 +0000 (21:56 +0100)] 
elf: Keep using minimal malloc after early DTV resize (bug 32412)

If an auditor loads many TLS-using modules during startup, it is
possible to trigger DTV resizing.  Previously, the DTV was marked
as allocated by the main malloc afterwards, even if the minimal
malloc was still in use.  With this change, _dl_resize_dtv marks
the resized DTV as allocated with the minimal malloc.

The new test reuses TLS-using modules from other auditing tests.

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agolibio: Initialize _total_written for all kinds of streams
Tulio Magno Quites Machado Filho [Fri, 31 Jan 2025 13:26:22 +0000 (10:26 -0300)] 
libio: Initialize _total_written for all kinds of streams

Move the initialization code to a general place instead of keeping it
specific to file-backed streams.

Fixes: 596a61cf6b (libio: Start to return errors when flushing fwrite's buffer [BZ #29459], 2025-01-28)
Reported-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
5 months agomalloc: Add size check when moving fastbin->tcache
Ben Kallus [Tue, 11 Feb 2025 19:29:51 +0000 (14:29 -0500)] 
malloc: Add size check when moving fastbin->tcache

By overwriting a forward link in a fastbin chunk that is subsequently
moved into the tcache, it's possible to get malloc to return an
arbitrary address [0].

When a chunk is fetched from a fastbin, its size is checked against the
expected chunk size for that fastbin (see malloc.c:3991). This patch
adds a similar check for chunks being moved from a fastbin to tcache,
which renders obsolete the exploitation technique described above.

Now updated to use __glibc_unlikely instead of __builtin_expect, as
requested.

[0]: https://github.com/shellphish/how2heap/blob/master/glibc_2.39/fastbin_reverse_into_tcache.c

Signed-off-by: Ben Kallus <benjamin.p.kallus.gr@dartmouth.edu>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agonss: Improve network number parsers (bz 32573, 32575)
Tobias Stoeckmann [Wed, 12 Feb 2025 18:46:06 +0000 (19:46 +0100)] 
nss: Improve network number parsers (bz 32573, 32575)

Make sure that numbers never overflow uint32_t in inet_network to
properly validate octets encountered in IPv4 addresses.

Avoid malloca in NSS networks file code because /etc/networks lines
can be arbitrarily long. Instead of handcrafting the input for
inet_network by adding ".0" octets if they are missing, just left shift
the result. Also, do not accept invalid entries, but ignore the line
instead.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
5 months agonptl: Remove unused __g_refs comment.
Carlos O'Donell [Fri, 7 Feb 2025 18:01:36 +0000 (13:01 -0500)] 
nptl: Remove unused __g_refs comment.

In the block comment for __pthread_cond_wait_common we mention
__g_refs, but the implementation no longer uses group references.

5 months agoadvisories: Fix up GLIBC-SA-2025-0001
Siddhesh Poyarekar [Thu, 13 Feb 2025 17:37:48 +0000 (12:37 -0500)] 
advisories: Fix up GLIBC-SA-2025-0001

Add ref for the test case as well as backports.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
5 months agoAArch64: Improve codegen for SVE powf
Yat Long Poon [Thu, 13 Feb 2025 18:03:04 +0000 (18:03 +0000)] 
AArch64: Improve codegen for SVE powf

Improve memory access with indexed/unpredicated instructions.
Eliminate register spills.  Speedup on Neoverse V1: 3%.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 months agoAArch64: Improve codegen for SVE pow
Yat Long Poon [Thu, 13 Feb 2025 18:02:01 +0000 (18:02 +0000)] 
AArch64: Improve codegen for SVE pow

Move constants to struct.  Improve memory access with indexed/unpredicated
instructions.  Eliminate register spills.  Speedup on Neoverse V1: 24%.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 months agoAArch64: Improve codegen for SVE erfcf
Yat Long Poon [Thu, 13 Feb 2025 18:00:50 +0000 (18:00 +0000)] 
AArch64: Improve codegen for SVE erfcf

Reduce number of MOV/MOVPRFXs and use unpredicated FMUL.
Replace MUL with LSL.  Speedup on Neoverse V1: 6%.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 months agoAarch64: Improve codegen in SVE exp and users, and update expf_inline
Luna Lamb [Thu, 13 Feb 2025 17:54:46 +0000 (17:54 +0000)] 
Aarch64: Improve codegen in SVE exp and users, and update expf_inline

Use unpredicted muls, and improve memory access.
7%, 3% and 1% improvement in throughput microbenchmark on Neoverse V1,
for exp, exp2 and cosh respectively.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 months agoAarch64: Improve codegen in SVE asinh
Luna Lamb [Thu, 13 Feb 2025 17:52:09 +0000 (17:52 +0000)] 
Aarch64: Improve codegen in SVE asinh

Use unpredicated muls, use lanewise mla's and improve memory access.
1% regression in throughput microbenchmark on Neoverse V1.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
5 months agomath: Improve layout of exp/exp10 data
Wilco Dijkstra [Fri, 13 Dec 2024 15:43:07 +0000 (15:43 +0000)] 
math: Improve layout of exp/exp10 data

GCC aligns global data to 16 bytes if their size is >= 16 bytes.  This patch
changes the exp_data struct slightly so that the fields are better aligned
and without gaps.  As a result on targets that support them, more load-pair
instructions are used in exp.  Exp10 is improved by moving invlog10_2N later
so that neglog10_2hiN and neglog10_2loN can be loaded using load-pair.

The exp benchmark improves 2.5%, "144bits" by 7.2%, "768bits" by 12.7% on
Neoverse V2.  Exp10 improves by 1.5%.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agoassert: Add test for CVE-2025-0395
Siddhesh Poyarekar [Fri, 31 Jan 2025 17:16:30 +0000 (12:16 -0500)] 
assert: Add test for CVE-2025-0395

Use the __progname symbol to override the program name to induce the
failure that CVE-2025-0395 describes.

This is related to BZ #32582

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
5 months agomath: Consolidate coshf and sinhf internal tables
Adhemerval Zanella [Mon, 3 Feb 2025 21:24:19 +0000 (18:24 -0300)] 
math: Consolidate coshf and sinhf internal tables

The libm size improvement built with "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":

Before:

   text    data     bss     dec     hex filename
 585192     860      12  586064   8f150 aarch64-linux-gnu/math/libm.so
 960775    1068      12  961855   ead3f x86_64-linux-gnu/math/libm.so
1189174    5544     368 1195086  123c4e powerpc64le-linux-gnu/math/libm.so

After:

   text    data     bss     dec     hex filename
 584952     860      12  585824   8f060 aarch64-linux-gnu/math/libm.so
 960615    1068      12  961695   eac9f x86_64-linux-gnu/math/libm.so
1189078    5544     368 1194990  123bee powerpc64le-linux-gnu/math/libm.so

The are small code changes for x86_64 and powerpc64le, which do not
affect performance; but on aarch64 with gcc-14 I see a slight better
code generation due the usage of ldq for floating point constant loading.
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
5 months agomath: Consolidate acoshf and asinhf internal tables
Adhemerval Zanella [Mon, 3 Feb 2025 21:24:18 +0000 (18:24 -0300)] 
math: Consolidate acoshf and asinhf internal tables

The libm size improvement built with "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":

Before:

   text    data     bss     dec     hex filename
 587304     860      12  588176   8f990 aarch64-linux-gnu-master/math/libm.so
 962855    1068      12  963935   eb55f x86_64-linux-gnu-master/math/libm.so
1191222    5544     368 1197134  12444e powerpc64le-linux-gnu-master/math/libm.so

After:

   text    data     bss     dec     hex filename
 585192     860      12  586064   8f150 aarch64-linux-gnu/math/libm.so
 960775    1068      12  961855   ead3f x86_64-linux-gnu/math/libm.so
1189174    5544     368 1195086  123c4e powerpc64le-linux-gnu/math/libm.so

The are small code changes for x86_64 and powerpc64le, which do not
affect performance; but on aarch64 with gcc-14 I see a slight better
code generation due the usage of ldq for floating point constant loading.
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
5 months agomath: Use tanpif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 16:38:40 +0000 (13:38 -0300)] 
math: Use tanpif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic tanpif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                      master        patched   improvement
x86_64                      85.1683        47.7990        43.88%
x86_64v2                    76.8219        41.4679        46.02%
x86_64v3                    73.7775        37.7734        48.80%
aarch64 (Neoverse)          35.4514        18.0742        49.02%
power8                      22.7604        10.1054        55.60%
power10                     22.1358         9.9553        55.03%

reciprocal-throughput        master        patched   improvement
x86_64                      41.0174        19.4718        52.53%
x86_64v2                    34.8565        11.3761        67.36%
x86_64v3                    34.0325         9.6989        71.50%
aarch64 (Neoverse)          25.4349         9.2017        63.82%
power8                      13.8626         3.8486        72.24%
power10                     11.7933         3.6420        69.12%

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agomath: Use sinpif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 16:31:56 +0000 (13:31 -0300)] 
math: Use sinpif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic sinpif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                      master        patched   improvement
x86_64                      47.5710        38.4455        19.18%
x86_64v2                    46.8828        40.7563        13.07%
x86_64v3                    44.0034        34.1497        22.39%
aarch64 (Neoverse)          19.2493        14.1968        26.25%
power8                      23.5312        16.3854        30.37%
power10                     22.6485        10.2888        54.57%

reciprocal-throughput        master        patched   improvement
x86_64                      21.8858        11.6717        46.67%
x86_64v2                    22.0620        11.9853        45.67%
x86_64v3                    21.5653        11.3291        47.47%
aarch64 (Neoverse)          13.0615         6.5499        49.85%
power8                      16.2030         6.9580        57.06%
power10                     12.8911         4.2858        66.75%

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agomath: Use cospif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 16:25:39 +0000 (13:25 -0300)] 
math: Use cospif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic cospif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                    master        patched   improvement
x86_64                    47.4679        38.4157        19.07%
x86_64v2                  46.9686        38.3329        18.39%
x86_64v3                  43.8929        31.8510        27.43%
aarch64 (Neoverse)        18.8867        13.2089        30.06%
power8                    22.9435         7.8023        65.99%
power10                   15.4472        7.77505        49.67%

reciprocal-throughput      master        patched   improvement
x86_64                    20.9518        11.4991        45.12%
x86_64v2                  19.8699        10.5921        46.69%
x86_64v3                  19.3475         9.3998        51.42%
aarch64 (Neoverse)        12.5767         6.2158        50.58%
power8                    15.0566         3.2654        78.31%
power10                    9.2866         3.1147        66.46%

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agomath: Use atanpif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 16:18:32 +0000 (13:18 -0300)] 
math: Use atanpif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic atanpif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                     master        patched   improvement
x86_64                     66.3296        52.7558        20.46%
x86_64v2                   66.0429        51.4007        22.17%
x86_64v3                   60.6294        48.7876        19.53%
aarch64 (Neoverse)         24.3163        20.9110        14.00%
power8                     16.5766        13.3620        19.39%
power10                    16.5115        13.4072        18.80%

reciprocal-throughput       master        patched   improvement
x86_64                     30.8599        16.0866        47.87%
x86_64v2                   29.2286        15.4688        47.08%
x86_64v3                   23.0960        12.8510        44.36%
aarch64 (Neoverse)         15.4619        10.6752        30.96%
power8                      7.9200         5.2483        33.73%
power10                     6.8539         4.6262        32.50%

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agomath: Use atan2pif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 16:01:20 +0000 (13:01 -0300)] 
math: Use atan2pif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic atan2pif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                 master        patched   improvement
x86_64                 79.4006        70.8726        10.74%
x86_64v2               77.5136        69.1424        10.80%
x86_64v3               71.8050        68.1637         5.07%
aarch64 (Neoverse)     27.8363        24.7700        11.02%
power8                 39.3893        17.2929        56.10%
power10                19.7200        16.8187        14.71%

reciprocal-throughput   master        patched   improvement
x86_64                 38.3457        30.9471        19.29%
x86_64v2               37.4023        30.3112        18.96%
x86_64v3               33.0713        24.4891        25.95%
aarch64 (Neoverse)     19.3683        15.3259        20.87%
power8                 19.5507        8.27165        57.69%
power10                9.05331        7.63775        15.64%

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agomath: Use asinpif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 14:10:53 +0000 (11:10 -0300)] 
math: Use asinpif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic asinpif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                 master        patched   improvement
x86_64                 46.4996        41.6126        10.51%
x86_64v2               46.7551        38.8235        16.96%
x86_64v3               42.6235        33.7603        20.79%
aarch64 (Neoverse)     17.4161        14.3604        17.55%
power8                 10.7347         9.0193        15.98%
power10                10.6420         9.0362        15.09%

reciprocal-throughput   master        patched   improvement
x86_64                 24.7208        16.5544        33.03%
x86_64v2               24.2177        14.8938        38.50%
x86_64v3               20.5617        10.5452        48.71%
aarch64 (Neoverse)     13.4827        7.17613        46.78%
power8                 6.46134        3.56089        44.89%
power10                5.79007        3.49544        39.63%

Reviewed-by: DJ Delorie <dj@redhat.com>
5 months agomath: Use acospif from CORE-MATH
Adhemerval Zanella [Fri, 20 Dec 2024 13:42:35 +0000 (10:42 -0300)] 
math: Use acospif from CORE-MATH

The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic acospif.

The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).

Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):

latency                  master        patched   improvement
x86_64                  54.8281        42.9070        21.74%
x86_64v2                54.1717        42.7497        21.08%
x86_64v3                49.3552        34.1512        30.81%
aarch64 (Neoverse)      17.9395        14.3733        19.88%
power8                  20.3110         8.8609        56.37%
power10                 11.3113        8.84067        21.84%

reciprocal-throughput    master        patched   improvement
x86_64                  21.2301        14.4803        31.79%
x86_64v2                20.6858        13.9506        32.56%
x86_64v3                16.1944        11.3377        29.99%
aarch64 (Neoverse)      11.4474        7.13282        37.69%
power8                  10.6916        3.57547        66.56%
power10                 4.64269        3.54145        23.72%

Reviewed-by: DJ Delorie <dj@redhat.com>