Commit Graph

13756 Commits

Author SHA1 Message Date
Florian Weimer
97e42bd482 nptl: Use <unwind-link.h> for accessing the libgcc_s unwinder
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 16:00:22 +01:00
Florian Weimer
6b7efa3d87 Implement _Unwind_Resume in libc on top of <unwind-link.h>
Temporarily move the arm _Unwind_Resume implementation to the file
used by libpthread.  It will be ported to <unwind-link.h> along with
the rest of nptl.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 16:00:03 +01:00
Florian Weimer
d14624825a Move sysdeps/gnu/unwind-resume.c to sysdeps/generic/unwind-resume.c
This change allows architecture-specific sysdeps directories to override
it.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:49 +01:00
Florian Weimer
7cf18db482 __frame_state_for: Use <unwind-link.h> for unwinder access
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:36 +01:00
Florian Weimer
600fe89cb1 sparc: Implement backtrace on top <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:25 +01:00
Florian Weimer
6563d544db m68k: Implement backtrace on top of <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:12 +01:00
Florian Weimer
fd19b84640 i386: Implement backtrace on top of <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:58 +01:00
Florian Weimer
fac75a690e arm: Implement backtrace on top of <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:45 +01:00
Florian Weimer
9fc813e1a3 Implement <unwind-link.h> for dynamically loading the libgcc_s unwinder
This will be used to consolidate the libgcc_s access for backtrace
and pthread_cancel.

Unlike the existing backtrace implementations, it provides some
hardening based on pointer mangling.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:01 +01:00
Szabolcs Nagy
9fb07fd4e1 aarch64: update ulps.
For new test cases in
commit 5a051454a9
2021-03-01 12:29:42 +00:00
Paul Zimmermann
5a051454a9 Add inputs that generate larger error bounds
(Using values from https://members.loria.fr/PZimmermann/papers/accuracy.pdf)
2021-02-27 06:32:11 +01:00
Florian Weimer
035c012e32 Reduce the statically linked startup code [BZ #23323]
It turns out the startup code in csu/elf-init.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A
New Method to Bypass 64-bit Linux ASLR").  These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker.  However, the dynamic
linker skipped the main program for some reason.  For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.

For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.

A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues.
2021-02-25 12:13:02 +01:00
Florian Weimer
5a664d7ae8 nptl: Move elision implementations into libc
The elision interfaces are closely aligned between the targets that
implement them, so declare them in the generic <lowlevellock.h>
file.

Empty .c stubs are provided, so that fewer makefile updates
under sysdeps are needed.  Also simplify initialization via
__libc_early_init.

The symbols __lll_clocklock_elision, __lll_lock_elision,
__lll_trylock_elision, __lll_unlock_elision, __pthread_force_elision
move into libc.  For the time being, non-hidden references are used
from libpthread to access them, but once that part of libpthread
is moved into libc, hidden symbols will be used again.  (Hidden
references seem desirable to reduce the likelihood of transactions
aborts.)
2021-02-23 14:59:34 +01:00
H.J. Lu
89de9d3958 x86: Use x86/nptl/pthreaddef.h
1. Move sysdeps/i386/nptl/pthreaddef.h to sysdeps/x86/nptl/pthreaddef.h.
2. Remove sysdeps/x86_64/nptl/pthreaddef.h.

Reviewed-by: DJ Delorie <dj@redhat.com>
2021-02-22 15:52:56 -08:00
Florian Weimer
b5be9ae77e nptl: Move futex-internal into libc
This moves  __futex_abstimed_wait64 and
__futex_abstimed_wait_cancelable64 and exports these functions as
GLIBC_PRIVATE.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-02-22 18:30:52 +01:00
Florian Weimer
2f4019de81 nptl: Move lowlevellock into libc [BZ #15648]
And export __lll_lock_wait and __lll_lock_wait_private as
GLIBC_PRIVATE.  This should eliminate the need for the previous
riscv kludge.
2021-02-22 18:30:52 +01:00
Florian Weimer
541e53c9dd nptl: Move futex-internal.c into main nptl directory
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-02-22 18:30:52 +01:00
Florian Weimer
feb741bb81 x86: Remove unused variables for raw cache sizes from cacheinfo.h 2021-02-22 17:36:03 +01:00
H.J. Lu
ba230b6387 <bits/platform/x86.h>: Correct x86_cpu_TBM
x86_cpu_TBM should be x86_cpu_index_80000001_ecx + 21.
2021-02-22 04:31:51 -08:00
H.J. Lu
ebbb8c9f64 x86_64/clone.S: Upate comments 2021-02-22 04:30:38 -08:00
H.J. Lu
f8ff5a3cc2 i386/clone.S: Remove redundant EBX load
There is no neeed for

	call	L(here)
L(here):
	popl	%ebx
	addl	$_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ebx

before

	movl	%eax, %ebx
2021-02-22 04:29:19 -08:00
Szabolcs Nagy
fb37ef6960 aarch64: Remove the unused __read_tp symbol
This was likely a mistake in the original aarch64 port copied over
from arm: on aarch64 tpidr_el0 register is always available.

The __read_tp symbol is visible with static linking, but it's not
part of the public ABI so it should be safe to remove.
2021-02-22 09:17:12 +00:00
Joseph Myers
83908b3a1e Update syscall lists for Linux 5.11.
Linux 5.11 has one new syscall, epoll_pwait2.  Update
syscall-names.list and regenerate the arch-syscall.h headers with
build-many-glibcs.py update-syscalls.

Tested with build-many-glibcs.py.
2021-02-19 21:16:27 +00:00
John David Anglin
96b8038f12 Correct hppa EFD_NONBLOCK, IN_NONBLOCK, SFD_NONBLOCK and TFD_NONBLOCK defines. 2021-02-19 17:08:47 +00:00
Stefan Liebler
25251c0707 S390: Add new hwcap values.
The new hwcap values indicate support for arch14 architecture.
2021-02-16 16:31:20 +01:00
Szabolcs Nagy
fb1905eed8 aarch64: Fix sys/ptrace.h if linux headers are included
If the linux asm/ptrace.h is included before sys/ptrace.h that
breaks the newly added declarations there, so undef the names
that may be defined as macros in the linux header.
2021-02-15 13:42:01 +00:00
H.J. Lu
ce4a94b12e x86: Remove the extra space between "# endif"
Remove the extra space between "# endif" left over from

commit f380868f6d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Dec 24 15:43:34 2020 -0800

    Remove _ISOMAC check from <cpu-features.h>
2021-02-12 07:50:29 -08:00
Adhemerval Zanella
4458eb1257 hurd: Fix fstatfs build failure
It was added by 1bfbaf7130 where it added a libc_hidden_proto for
__fstatfs but it didn't update the Hurd version as well.

Checked with a build for i686-gnu.
2021-02-11 17:45:24 -03:00
Adhemerval Zanella
7eb3000f9f linux: Remove stat-check.c
The check is moved to LFS fstatat implementation (since it is the
code that actually implements the syscall).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 08:02:16 -03:00
Adhemerval Zanella
d2fa24f239 linux: Remove overflow.h
The header is not used anywhere.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 08:01:10 -03:00
Adhemerval Zanella
1566d3c43f linux: Consolidate internal_statvfs
Remove the internal_statvfs64.c and open code the implementation
on internal_statvfs.c.  The alpha is now unrequired, the generic
implementation also handles it.

Also, remove unused includes on internal_statvfs.c, and remove
unused arguments on __internal_statvfs{64}.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 08:00:48 -03:00
Adhemerval Zanella
52f527d6f1 linux: Consolidate statvfs implementations
There is no need to handle ENOSYS on fstatfs64 call, required only
for alpha (where is already fallbacks to fstatfs).

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 08:00:41 -03:00
Adhemerval Zanella
6ea1603d65 linux: Consolidate fstatvfs implementations
There is no need to handle ENOSYS on fstatfs64 call, required only
for alpha (where is already fallbacks to fstatfs).  The wordsize
internal_statvfs64.c is removed, since how the LFS support is
provided by fstatvfs64.c (used on 64-bit architectures as well).

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 08:00:28 -03:00
Adhemerval Zanella
f6e616435d linux: Consolidate statfs implementations
The __NR_statfs64 syscall is supported on all architectures but
aarch64, mips64, riscv64, and x86_64.  And newer ABIs also uses
the new statfs64 interface (where the struct size is used as
second argument).

So the default implementation now uses:

  1. __NR_statfs64 for non-LFS call and handle overflow directly
     There is no need to handle __NR_statfs since all architectures
     that only support are LFS only.

  2. __NR_statfs if defined or __NR_statfs64 otherwise for LFS
     call.

Alpha is the only outlier, since it is a 64-bit architecture which
provides non-LFS interface and only provides __NR_statfs64 on
newer kernels (v5.1+).

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 08:00:11 -03:00
Adhemerval Zanella
1bfbaf7130 linux: Consolidate fstatfs implementations
The __NR_fstatfs64 syscall is supported on all architectures but
aarch64, mips64, riscv64, and x86_64.  And newer ABIs also uses
the new fstatfs64 interface (where the struct size is used as
first argument).

So the default implementation now uses:

  1. __NR_fstatfs64 for non-LFS call and handle overflow directly
     There is no need to handle __NR_fstatfs since all architectures
     that only support are LFS only.

  2. __NR_fstatfs if defined or __NR_fstatfs64 otherwise for LFS
     call.

Alpha is the only outlier, it is a 64-bit architecture which
provides non-LFS interface and only provides __NR_fstatfs64 on
newer kernels (5.1+).

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 07:58:31 -03:00
Adhemerval Zanella
e7702cb56e linux: Set LFS statfs as default
Currently glibc has three different struct statfs{64} definitions:

  1. Non-LFS support where non-LFS and LFS struct have different
     size: alpha, arm, hppa, i686, m68k, microblaze, mips (all abis),
     powerpc32, s390, sh4, and sparc.

  2. Non-LFS support where non-LFS and LFS struct have the same
     size: csky and nios2.

  3. Only LFS support (where both struct have the same size): arc,
     ia64, powerpc64 (including LE), riscv (both 32 and 64 bits),
     s390x, sparc64, and x86 (including x32).

The STATFS_IS_STATFS64/__STATFS_MATCHES_STATFS64 does not tell apart
between 1. and 2. since for both the only difference is the struct
size (for 2. both non-LFS and LFS uses the same syscall, where for
1. the old non-LFS is used for [f]statfs).

This patch move the generic statfs.h for both csky and nios2, and
make the default definitions for newer ABIs to assume that only
LFS will be support (so there is no need to keep no-LFS and LFS
struct statfs with the same size, it will be implicit).

This patch does not change the code generation.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 07:58:09 -03:00
Adhemerval Zanella
36260d5035 linux: Set default kernel_stat.h to LFS
The XSTAT_IS_XSTAT64 and STAT_IS_KERNEL_STAT flags are now set to 1 and
STATFS_IS_STATFS64 is set to __STATFS_MATCHES_STATFS64.  This makes the
default ABI for newer ports to provide only LFS calls.

A copy of non-LFS support is provided to 32-bit ABIS with non-LFS
support (arm, csky, i386, m68k, nios2, s390, and sh).  Is also allows
to remove the 64-bit ports, which already uses the default values.

This patch does not change the code generation.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 07:58:05 -03:00
Adhemerval Zanella
4b221ec9ee linux: Fix STATFS_IS_STATFS64 definition
aarch64, arc, ia64, mips64, powerpc64, riscv32, riscv64, s390x, sparc64,
and x86_64 defines STATFS_IS_STATFS64 to 0, but all of them alias
statfs to statfs64 and the struct statfs has the same and layout of
struct statfs64.

The correct definition will be used on the [f]statfs[64] consolidation.

This patch does not change code generation since the symbols are
implemented using the auto-generation syscall for all the aforementioned
ABIs.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-11 07:57:57 -03:00
Siddhesh Poyarekar
a1b8b06a55 x86: Use SIZE_MAX instead of (long int)-1 for tunable range value
The tunable types are SIZE_T, so set the ranges to the correct maximum
value, i.e. SIZE_MAX.
2021-02-10 19:08:33 +05:30
Siddhesh Poyarekar
61117bfa1b tunables: Simplify TUNABLE_SET interface
The TUNABLE_SET interface took a primitive C type argument, which
resulted in inconsistent type conversions internally due to incorrect
dereferencing of types, especialy on 32-bit architectures.  This
change simplifies the TUNABLE setting logic along with the interfaces.

Now all numeric tunable values are stored as signed numbers in
tunable_num_t, which is intmax_t.  All calls to set tunables cast the
input value to its primitive type and then to tunable_num_t for
storage.  This relies on gcc-specific (although I suspect other
compilers woul also do the same) unsigned to signed integer conversion
semantics, i.e. the bit pattern is conserved.  The reverse conversion
is guaranteed by the standard.
2021-02-10 19:08:33 +05:30
Adhemerval Zanella
7dd416491e linux: Fix __sem_check_add_mapping search_sem
Similar to __sem_check_add_mapping fix, take in consideration the
trailling NULL.

Checked x86_64-linux-gnu.
2021-02-09 16:09:51 -03:00
Adhemerval Zanella
e99156816d linux: Fix __sem_check_add_mapping name length
Take in consideration the trailling NULL since sem_search uses
strcmp to compare entries.

Checked on x86_64-linux-gnu and powerpc-linux-gnu (where it triggered
a nptl/tst-sem7 regression).
2021-02-09 14:42:55 -03:00
Joseph Myers
0ff786226c Add more ptrace constants for AArch64 and PowerPC.
Linux 5.10 adds PTRACE_PEEKMTETAGS and PTRACE_POKEMTETAGS for AArch64.
Adding those shows up that glibc is also missing PTRACE_SYSEMU and
PTRACE_SYSEMU_SINGLESTEP, for AArch64 (where they were added to Linux
in 5.3) and for PowerPC (where they were added in Linux 4.20); it
already has those two defines for x86.  Add all those defines to
glibc's headers.

Tested with build-many-glibcs.py for aarch64-linux-gnu and
powerpc-linux-gnu.
2021-02-08 22:47:04 +00:00
noah
1f745ecc21 x86-64: Refactor and improve performance of strchr-avx2.S
No bug. Just seemed the performance could be improved a bit. Observed
and expected behavior are unchanged. Optimized body of main
loop. Updated page cross logic and optimized accordingly. Made a few
minor instruction selection modifications. No regressions in test
suite. Both test-strchrnul and test-strchr passed.
2021-02-08 11:21:33 -08:00
Adhemerval Zanella
c1f46f9db7 pthread: Remove alloca usage from __sem_check_add_mapping
sem_open already returns EINVAL for input names larger than NAME_MAX,
so it can assume the largest name length with tfind.

Checked on x86_64-linux-gnu.
2021-02-08 14:10:42 -03:00
Adhemerval Zanella
da4aea0b5e pthread: Refactor semaphore code
The internal semaphore list code is moved to a specific file,
sem_routine.c, and the internal usage is simplified to only two
functions (one to insert a new semaphore and one to remove it
from the internal list).  There is no need to expose the
internal locking, neither how the semaphore mapping is implemented.

No functional or semantic change is expected, tested on
x86_64-linux-gnu.
2021-02-08 14:10:42 -03:00
Florian Weimer
e9fed2438a linux: Require /dev/shm as the shared memory file system
Previously, glibc would pick an arbitrary tmpfs file system from
/proc/mounts if /dev/shm was not available.  This could lead to
an unsuitable file system being picked for the backing storage for
shm_open, sem_open, and related functions.

This patch introduces a new function, __shm_get_name, which builds
the file name under the appropriate (now hard-coded) directory.  It is
called from the various shm_* and sem_* function.  Unlike the
SHM_GET_NAME macro it replaces, the callers handle the return values
and errno updates.  shm-directory.c is moved directly into the posix
subdirectory because it can be implemented directly using POSIX
functionality.  It resides in libc because it is needed by both
librt and nptl/htl.

In the sem_open implementation, tmpfname is initialized directly
from a string constant.  This happens to remove one alloca call.

Checked on x86_64-linux-gnu.
2021-02-08 14:10:42 -03:00
Lukasz Majewski
e2c0794d13 tst: Provide test for ppoll
This change adds new test to assess ppoll()'s timeout related
functionality (the struct pollfd does not provide valid fd to wait
for - just wait for timeout).

To be more specific - two use cases are checked:
- if ppoll() times out immediately when passed struct timespec has zero
values of tv_nsec and tv_sec.
- if ppoll() times out after timeout specified in passed argument
2021-02-08 09:20:03 +01:00
Lukasz Majewski
5692abd13d tst: Provide test for timerfd related functions
This change adds new test to assess functionality of timerfd_*
functions.
It creates new timer (operates on its file descriptor) and checks
if time before and after sleep is between expected values.
2021-02-08 09:19:44 +01:00
H.J. Lu
5ab25c8875 x86: Add PTWRITE feature detection [BZ #27346]
1. Add CPUID_INDEX_14_ECX_0 for CPUID leaf 0x14 to detect PTWRITE feature
in EBX of CPUID leaf 0x14 with ECX == 0.
2. Add PTWRITE detection to CPU feature tests.
3. Add 2 static CPU feature tests.
2021-02-07 08:01:14 -08:00