]> sourceware.org Git - glibc.git/log
glibc.git
3 years agolinux: Use statx for MIPSn64
Adhemerval Zanella [Fri, 19 Mar 2021 12:51:29 +0000 (09:51 -0300)]
linux: Use statx for MIPSn64

MIPSn64 kernel ABI for legacy stat uses unsigned 32 bit for second
timestamp, which limits the maximum value to y2106.  This patch
make mips64 use statx as for 32-bit architectures.

Thie __cp_stat64_t64_statx is open coded, its usage is solely on
fstatat64 and it avoid the need to redefine the name for mips64
(which will call __cp_stat64_statx since its does not use
__stat64_t64 internally).

3 years agolinux: Disable fstatat64 fallback if __ASSUME_STATX is defined
Adhemerval Zanella [Thu, 18 Mar 2021 19:30:23 +0000 (22:30 +0300)]
linux: Disable fstatat64 fallback if __ASSUME_STATX is defined

If the minimum kernel supports statx there is no need to call the
fallback stat legacy syscalls.

The statx is also called on compat xstat syscall, but different
than the fstatat it calls no fallback and it is assumed to be
always present.

Checked on powerpc-linux-gnu (with and without --enable-kernel=4.11)
and on powerpc64-linux-gnu.

3 years agolinux: Implement fstatat with __fstatat64_time64
Adhemerval Zanella [Thu, 18 Mar 2021 17:30:13 +0000 (20:30 +0300)]
linux: Implement fstatat with __fstatat64_time64

It makes fstatat use __NR_statx, which fix the s390 issue with
missing nanoxsecond support on compat stat syscalls (at least
on recent kernels) and limits the statx call to only one function
(which simplifies the __ASSUME_STATX support).

Checked on i686-linux-gnu and on powerpc-linux-gnu.

3 years agox86: Properly disable XSAVE related features [BZ #27605]
H.J. Lu [Fri, 19 Mar 2021 13:15:37 +0000 (06:15 -0700)]
x86: Properly disable XSAVE related features [BZ #27605]

1. Support GLIBC_TUNABLES=glibc.cpu.hwcaps=-XSAVE.
2. Disable all features which depend on XSAVE:
   a. If OSXSAVE is disabled by glibc tunables.  Or
   b. If both XSAVE and XSAVEC aren't usable.

3 years agotest-strnlen.c: Check that strnlen won't go beyond the maximum length
H.J. Lu [Sat, 27 Mar 2021 16:06:39 +0000 (09:06 -0700)]
test-strnlen.c: Check that strnlen won't go beyond the maximum length

Place strings ending at page boundary without the null byte.  If an
implementation goes beyond EXP_LEN, it will trigger the segfault.

3 years agotest-strnlen.c: Initialize wchar_t string with wmemset [BZ #27655]
H.J. Lu [Sat, 27 Mar 2021 16:15:00 +0000 (09:15 -0700)]
test-strnlen.c: Initialize wchar_t string with wmemset [BZ #27655]

Use wmemset to initialize wchar_t string.

3 years agonptl: Remove unused rules
Adhemerval Zanella [Thu, 18 Mar 2021 17:53:22 +0000 (14:53 -0300)]
nptl: Remove unused rules

The wrapper are not exported by libpthread.

3 years agonptl: Remove __libc_allocate_rtsig, __libc_current_sigrtmax, and __libc_current_sigrtmin
Adhemerval Zanella [Mon, 15 Mar 2021 20:22:15 +0000 (17:22 -0300)]
nptl: Remove __libc_allocate_rtsig, __libc_current_sigrtmax, and __libc_current_sigrtmin

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Move sigaction to libc
Adhemerval Zanella [Mon, 15 Mar 2021 18:34:42 +0000 (15:34 -0300)]
nptl: Move sigaction to libc

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove pthread raise implementation
Adhemerval Zanella [Thu, 3 Dec 2020 19:45:53 +0000 (16:45 -0300)]
nptl: Remove pthread raise implementation

The Linux version already target the current thread by using tgkill
along with getpid and gettid.

For arm, libpthread does not do a intra PLT since it will call the
raise from libc.

Checked on x86_64-linux-gnu.

3 years agonptl: Move pthread_kill to libc
Adhemerval Zanella [Thu, 3 Dec 2020 14:43:25 +0000 (11:43 -0300)]
nptl: Move pthread_kill to libc

A new 2.34 version is also provided.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove sigsuspend from pthread-compat-wrappers
Adhemerval Zanella [Thu, 18 Mar 2021 17:48:58 +0000 (14:48 -0300)]
nptl: Remove sigsuspend from pthread-compat-wrappers

The symbol is not exported by libpthread.

3 years agonptl: Remove msgrcv from pthread-compat-wrappers
Adhemerval Zanella [Thu, 18 Mar 2021 17:47:47 +0000 (14:47 -0300)]
nptl: Remove msgrcv from pthread-compat-wrappers

The symbol is not exported by libpthread.

3 years agonptl: Remove msgsnd from pthread-compat-wrappers
Adhemerval Zanella [Thu, 18 Mar 2021 17:46:45 +0000 (14:46 -0300)]
nptl: Remove msgsnd from pthread-compat-wrappers

The symbol is not exported by libpthread.

3 years agonptl: Remove pwrite from libpthread
Adhemerval Zanella [Sat, 13 Mar 2021 22:47:44 +0000 (19:47 -0300)]
nptl: Remove pwrite from libpthread

The libc version is identical and built with same flags, it is also
uses as the default version.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove pread from libpthread
Adhemerval Zanella [Sat, 13 Mar 2021 21:12:55 +0000 (18:12 -0300)]
nptl: Remove pread from libpthread

The libc version is identical and built with same flags, it is also
uses as the default version.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove open from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 23:54:13 +0000 (20:54 -0300)]
nptl: Remove open from libpthread

The libc version is identical and built with same flags.  The libc
version is set as the default version.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove lseek from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 20:08:00 +0000 (17:08 -0300)]
nptl: Remove lseek from libpthread

The libc version is identical and built with same flags.  The libc
version is set as the default version.

The libpthread compat symbol requires to mask it when building the
loader object otherwise ld might complain about a missing
versioned symbol (as for alpha).

Checked on x86_64-linux-gnu.

3 years agonptl: Remove send from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:42:39 +0000 (16:42 -0300)]
nptl: Remove send from libpthread

The libc version is identical and built with same flags.  Both aarch64
and nios2 also requires to export __send and tt was done previously with
the HAVE_INTERNAL_SEND_SYMBOL (which forced the symbol creation).

All __send callers are internal to libc and the original issue that
required the symbol export was due a missing libc_hidden_def.  So
a compat symbol is added for __send and the libc_hidden_def is
defined regardless.

Checked on x86_64-linux-gnu and i686-linux-gnu.

3 years agoAdd OTHER_SHLIB_COMPAT
Adhemerval Zanella [Fri, 19 Mar 2021 17:21:05 +0000 (17:21 +0000)]
Add OTHER_SHLIB_COMPAT

It is similar to SHLIB_COMPAT, but allows to check versions from
other libraries.  It is used to move compat symbol from other libraries
to libc.

3 years agomisc: Fix tst-select timeout handling (BZ#27648)
Adhemerval Zanella [Thu, 25 Mar 2021 19:57:45 +0000 (16:57 -0300)]
misc: Fix tst-select timeout handling (BZ#27648)

Instead of polling the stderr, create two pipes and fork to check
if child timeout as expected similar to tst-pselect.c.  Also lower
the timeout value.

Checked on x86_64-linux-gnu.

3 years agomalloc: Ensure mtag code path in checked_request2size is cold
Szabolcs Nagy [Mon, 15 Mar 2021 11:44:32 +0000 (11:44 +0000)]
malloc: Ensure mtag code path in checked_request2size is cold

This is a workaround (hack) for a gcc optimization issue (PR 99551).
Without this the generated code may evaluate the expression in the
cold path which causes performance regression for small allocations
in the memory tagging disabled (common) case.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Remove unnecessary tagging around _mid_memalign
Szabolcs Nagy [Fri, 12 Mar 2021 14:30:10 +0000 (14:30 +0000)]
malloc: Remove unnecessary tagging around _mid_memalign

The internal _mid_memalign already returns newly tagged memory.
(__libc_memalign and posix_memalign already relied on this, this
patch fixes the other call sites.)

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Rename chunk2rawmem
Szabolcs Nagy [Thu, 11 Mar 2021 14:49:45 +0000 (14:49 +0000)]
malloc: Rename chunk2rawmem

The previous patch ensured that all chunk to mem computations use
chunk2rawmem, so now we can rename it to chunk2mem, and in the few
cases where the tag of mem is relevant chunk2mem_tag can be used.

Replaced tag_at (chunk2rawmem (x)) with chunk2mem_tag (x).
Renamed chunk2rawmem to chunk2mem.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Use chunk2rawmem throughout
Szabolcs Nagy [Tue, 9 Mar 2021 14:04:49 +0000 (14:04 +0000)]
malloc: Use chunk2rawmem throughout

The difference between chunk2mem and chunk2rawmem is that the latter
does not get the memory tag for the returned pointer.  It turns out
chunk2rawmem almost always works:

The input of chunk2mem is a chunk pointer that is untagged so it can
access the chunk header. All memory that is not user allocated heap
memory is untagged, which in the current implementation means that it
has the 0 tag, but this patch does not rely on the tag value. The
patch relies on that chunk operations are either done on untagged
chunks or without doing memory access to the user owned part.

Internal interface contracts:

sysmalloc: Returns untagged memory.
_int_malloc: Returns untagged memory.
_int_free: Takes untagged memory.
_int_memalign: Returns untagged memory.
_int_realloc: Takes and returns tagged memory.

So only _int_realloc and functions outside this list need care.
Alignment checks do not need the right tag and tcache works with
untagged memory.

tag_at was kept in realloc after an mremap, which is not strictly
necessary, since the pointer is only used to retag the memory, but this
way the tag is guaranteed to be different from the old tag.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Use different tag after mremap
Szabolcs Nagy [Fri, 12 Mar 2021 09:46:15 +0000 (09:46 +0000)]
malloc: Use different tag after mremap

The comment explained why different tag is used after mremap, but
for that correctly tagged pointer should be passed to tag_new_usable.
Use chunk2mem to get the tag.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Use memsize instead of CHUNK_AVAILABLE_SIZE
Szabolcs Nagy [Mon, 8 Mar 2021 12:59:05 +0000 (12:59 +0000)]
malloc: Use memsize instead of CHUNK_AVAILABLE_SIZE

This is a pure refactoring change that does not affect behaviour.

The CHUNK_AVAILABLE_SIZE name was unclear, the memsize name tries to
follow the existing convention of mem denoting the allocation that is
handed out to the user, while chunk is its internally used container.

The user owned memory for a given chunk starts at chunk2mem(p) and
the size is memsize(p).  It is not valid to use on dumped heap chunks.

Moved the definition next to other chunk and mem related macros.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoaarch64: Optimize __libc_mtag_tag_zero_region
Szabolcs Nagy [Tue, 9 Feb 2021 17:59:11 +0000 (17:59 +0000)]
aarch64: Optimize __libc_mtag_tag_zero_region

This is a target hook for memory tagging, the original was a naive
implementation. Uses the same algorithm as __libc_mtag_tag_region,
but with instructions that also zero the memory.  This was not
benchmarked on real cpu, but expected to be faster than the naive
implementation.

3 years agoaarch64: Optimize __libc_mtag_tag_region
Szabolcs Nagy [Tue, 9 Feb 2021 17:56:02 +0000 (17:56 +0000)]
aarch64: Optimize __libc_mtag_tag_region

This is a target hook for memory tagging, the original was a naive
implementation. The optimized version relies on "dc gva" to tag 64
bytes at a time for large allocations and optimizes small cases without
adding too many branches. This was not benchmarked on real cpu, but
expected to be faster than the naive implementation.

3 years agoaarch64: inline __libc_mtag_new_tag
Szabolcs Nagy [Thu, 4 Feb 2021 17:05:28 +0000 (17:05 +0000)]
aarch64: inline __libc_mtag_new_tag

This is a common operation when heap tagging is enabled, so inline the
instructions instead of using an extern call.

3 years agoaarch64: inline __libc_mtag_address_get_tag
Szabolcs Nagy [Thu, 4 Feb 2021 10:04:07 +0000 (10:04 +0000)]
aarch64: inline __libc_mtag_address_get_tag

This is a common operation when heap tagging is enabled, so inline the
instruction instead of using an extern call.

The .inst directive is used instead of the name of the instruction (or
acle intrinsics) because malloc.c is not compiled for armv8.5-a+memtag
architecture, runtime cpu support detection is used.

Prototypes are removed from the comments as they were not always
correct.

3 years agomalloc: Use mtag_enabled instead of USE_MTAG
Szabolcs Nagy [Wed, 17 Feb 2021 10:15:18 +0000 (10:15 +0000)]
malloc: Use mtag_enabled instead of USE_MTAG

Use the runtime check where possible: it should not cause slow down in
the !USE_MTAG case since then mtag_enabled is constant false, but it
allows compiling the tagging logic so it's less likely to break or
diverge when developers only test the !USE_MTAG case.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Use branches instead of mtag_granule_mask
Szabolcs Nagy [Mon, 8 Feb 2021 12:39:01 +0000 (12:39 +0000)]
malloc: Use branches instead of mtag_granule_mask

The branches may be better optimized since mtag_enabled is widely used.

Granule size larger than a chunk header is not supported since then we
cannot have both the chunk header and user area granule aligned.  To
fix that for targets with large granule, the chunk layout has to change.

So code that attempted to handle the granule mask generally was changed.
This simplified CHUNK_AVAILABLE_SIZE and the logic in malloc_usable_size.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Change calloc when tagging is disabled
Szabolcs Nagy [Tue, 16 Feb 2021 17:02:44 +0000 (17:02 +0000)]
malloc: Change calloc when tagging is disabled

When glibc is built with memory tagging support (USE_MTAG) but it is not
enabled at runtime (mtag_enabled) then unconditional memset was used
even though that can be often avoided.

This is for performance when tagging is supported but not enabled.
The extra check should have no overhead: tag_new_zero_region already
had a runtime check which the compiler can now optimize away.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Only support zeroing and not arbitrary memset with mtag
Szabolcs Nagy [Fri, 29 Jan 2021 17:07:28 +0000 (17:07 +0000)]
malloc: Only support zeroing and not arbitrary memset with mtag

The memset api is suboptimal and does not provide much benefit. Memory
tagging only needs a zeroing memset (and only for memory that's sized
and aligned to multiples of the tag granule), so change the internal
api and the target hooks accordingly.  This is to simplify the
implementation of the target hook.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Use global flag instead of function pointer dispatch for mtag
Szabolcs Nagy [Wed, 27 Jan 2021 15:45:43 +0000 (15:45 +0000)]
malloc: Use global flag instead of function pointer dispatch for mtag

A flag check can be faster than function pointers because of how
branch prediction and speculation works and it can also remove a layer
of indirection when there is a mismatch between the malloc internal
tag_* api and __libc_mtag_* target hooks.

Memory tagging wrapper functions are moved to malloc.c from arena.c and
the logic now checks mmap_enabled.  The definition of tag_new_usable is
moved after chunk related definitions.

This refactoring also allows using mtag_enabled checks instead of
USE_MTAG ifdefs when memory tagging support only changes code logic
when memory tagging is enabled at runtime. Note: an "if (false)" code
block is optimized away even at -O0 by gcc.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Refactor TAG_ macros to avoid indirection
Szabolcs Nagy [Tue, 16 Feb 2021 14:12:25 +0000 (14:12 +0000)]
malloc: Refactor TAG_ macros to avoid indirection

This does not change behaviour, just removes one layer of indirection
in the internal memory tagging logic.

Use tag_ and mtag_ prefixes instead of __tag_ and __mtag_ since these
are all symbols with internal linkage, private to malloc.c, so there
is no user namespace pollution issue.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Ensure the generic mtag hooks are not used
Szabolcs Nagy [Wed, 17 Feb 2021 10:39:37 +0000 (10:39 +0000)]
malloc: Ensure the generic mtag hooks are not used

Use inline functions instead of macros, because macros can cause unused
variable warnings and type conversion issues.  We assume these functions
may appear in the code but only in dead code paths (hidden by a runtime
check), so it's important that they can compile with correct types, but
if they are actually used that should be an error.

Currently the hooks are only used when USE_MTAG is true which only
happens on aarch64 and then the aarch64 specific code is used not this
generic header.  However followup refactoring will allow the hooks to
be used with !USE_MTAG.

Note: the const qualifier in the comment was wrong: changing tags is a
write operation.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Avoid taggig mmaped memory on free
Szabolcs Nagy [Thu, 4 Feb 2021 11:52:14 +0000 (11:52 +0000)]
malloc: Avoid taggig mmaped memory on free

Either the memory belongs to the dumped area, in which case we don't
want to tag (the dumped area has the same tag as malloc internal data
so tagging is unnecessary, but chunks there may not have the right
alignment for the tag granule), or the memory will be unmapped
immediately (and thus tagging is not useful).

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Simplify __mtag_tag_new_usable
Szabolcs Nagy [Thu, 4 Feb 2021 11:38:23 +0000 (11:38 +0000)]
malloc: Simplify __mtag_tag_new_usable

The chunk cannot be a dumped one here.  The only non-obvious cases
are free and realloc which may be called on a dumped area chunk,
but in both cases it can be verified that tagging is already
avoided for dumped area chunks.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Move MTAG_MMAP_FLAGS definition
Szabolcs Nagy [Thu, 28 Jan 2021 17:34:36 +0000 (17:34 +0000)]
malloc: Move MTAG_MMAP_FLAGS definition

This is only used internally in malloc.c, the extern declaration
was wrong, __mtag_mmap_flags has internal linkage.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Fix a potential realloc issue with memory tagging
Szabolcs Nagy [Thu, 11 Mar 2021 14:09:56 +0000 (14:09 +0000)]
malloc: Fix a potential realloc issue with memory tagging

At an _int_free call site in realloc the wrong size was used for tag
clearing: the chunk header of the next chunk was also cleared which
in practice may work, but logically wrong.

The tag clearing is moved before the memcpy to save a tag computation,
this avoids a chunk2mem.  Another chunk2mem is removed because newmem
does not have to be recomputed. Whitespaces got fixed too.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agomalloc: Fix a realloc crash with heap tagging [BZ 27468]
Szabolcs Nagy [Thu, 25 Feb 2021 14:49:58 +0000 (14:49 +0000)]
malloc: Fix a realloc crash with heap tagging [BZ 27468]

_int_free must be called with a chunk that has its tag reset. This was
missing in a rare case that could crash when heap tagging is enabled:
when in a multi-threaded process the current arena runs out of memory
during realloc, but another arena still has space to finish the realloc
then _int_free was called without clearing the user allocation tags.

Fixes bug 27468.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoS390: Also check vector support in memmove ifunc-selector [BZ #27511]
Stefan Liebler [Tue, 23 Mar 2021 16:29:26 +0000 (17:29 +0100)]
S390: Also check vector support in memmove ifunc-selector [BZ #27511]

The arch13 memmove variant is currently selected by the ifunc selector
if the Miscellaneous-Instruction-Extensions Facility 3 facility bit
is present, but the function is also using vector instructions.
If the vector support is not present, one is receiving an operation
exception.

Therefore this patch also checks for vector support in the ifunc
selector and in ifunc-impl-list.c.

Just to be sure, the configure check is now also testing an arch13
vector instruction and an arch13 Miscellaneous-Instruction-Extensions
Facility 3 instruction.

3 years agoS390: Don't test nanoseconds in io/tst-stat.c
Stefan Liebler [Wed, 17 Mar 2021 13:03:52 +0000 (14:03 +0100)]
S390: Don't test nanoseconds in io/tst-stat.c

Both new tests io/tst-stat and io/tst-stat-lfs (_FILE_OFFSET_BITS=64)
are comparing the nanosecond fields with the statx result.  Unfortunately
on s390(31bit) those fields are always zero if old KABI with non-LFS
support is used.  With _FILE_OFFSET_BITS=64 stat is using statx internally.

As suggested by Adhemerval this patch disables the nanosecond check for
s390(31bit).
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoSupport for multiple versions in versioned_symbol, compat_symbol
Florian Weimer [Thu, 25 Mar 2021 10:05:37 +0000 (11:05 +0100)]
Support for multiple versions in versioned_symbol, compat_symbol

This essentially folds compat_symbol_unique functionality into
compat_symbol.

This change eliminates the need for intermediate aliases for defining
multiple symbol versions, for both compat_symbol and versioned_symbol.
Some binutils versions do not suport multiple versions per symbol on
some targets, so aliases are automatically introduced, similar to what
compat_symbol_unique did.  To reduce symbol table sizes, a configure
check is added to avoid these aliases if they are not needed.

The new mechanism works with data symbols as well as function symbols,
due to the way an assembler-level redirect is used.  It is not
compatible with weak symbols for old binutils versions, which is why
the definition of __malloc_initialize_hook had to be changed.  This
is not a loss of functionality because weak symbols do not matter
to dynamic linking.

The placeholder symbol needs repeating in nptl/libpthread-compat.c
now that compat_symbol is used, but that seems more obvious than
introducing yet another macro.

A subtle difference was that compat_symbol_unique made the symbol
global automatically.  compat_symbol does not do this, so static
had to be removed from the definition of
__libpthread_version_placeholder.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agolocale: Use compat_symbol_reference in _nl_postload_ctype
Florian Weimer [Thu, 25 Mar 2021 10:05:37 +0000 (11:05 +0100)]
locale: Use compat_symbol_reference in _nl_postload_ctype

These symbol usages are not definitions, so compat_symbol_reference is
more appropriate than compat_symbol.  compat_symbol_reference is also
safe to emit multiple times (in case the inline assembly is
duplicated; this is possible because it is nested in a function).
compat_symbol does not necessarily have this property because it is
intended to provide a symbol definition.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoChange how the symbol_version_reference macro is defined
Florian Weimer [Thu, 25 Mar 2021 10:05:37 +0000 (11:05 +0100)]
Change how the symbol_version_reference macro is defined

A subsequent change will require including <config.h> for defining
symbol_version_reference.  <libc-symbol.h> should not include
<config.h> for _ISOMAC, so it cannot define symbol_version_reference
anymore, but symbol_version_reference is needed <shlib-compat.h> even
for _ISOMAC.  Moving the definition of symbol_version_reference to a
separate file <libc-symver.h> makes it possible to use a single
definition for both cases.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agostdlib: Fix BZ #26241 testcase on GNU/Hurd
Samuel Thibault [Wed, 24 Mar 2021 00:36:20 +0000 (01:36 +0100)]
stdlib: Fix BZ #26241 testcase on GNU/Hurd

GNU/Hurd's readlink system call is partly implemented in userspace, which
also allocates a buffer on the stack for the result, and thus needs one
more path.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Fix not compiling ifunc tests that need gcc ifunc support
Samuel Thibault [Wed, 24 Mar 2021 00:10:38 +0000 (01:10 +0100)]
elf: Fix not compiling ifunc tests that need gcc ifunc support

3 years agohtl: Add missing fork.h
Samuel Thibault [Wed, 24 Mar 2021 00:18:17 +0000 (00:18 +0000)]
htl: Add missing fork.h

2b47727c68b6 ("posix: Consolidate register-atfork") introduced a fork.h
header to declare the atfork unregister hook, but was missing adding it
for htl.

This fixes tst-atfork2.

3 years agohurd: handle EINTR during critical sections
Samuel Thibault [Tue, 23 Mar 2021 22:38:54 +0000 (22:38 +0000)]
hurd: handle EINTR during critical sections

During critical sections, signal handling is deferred and thus RPCs return
EINTR, even if SA_RESTART is set. We thus have to restart the whole critical
section in that case.

This also adds HURD_CRITICAL_UNLOCK in the cases where one wants to
break the section in the middle.

3 years agotst: Add test for sigtimedwait
Lukasz Majewski [Mon, 15 Mar 2021 11:14:22 +0000 (12:14 +0100)]
tst: Add test for sigtimedwait

This change adds new test to assess sigtimedwait's timeout related
functionality - the sigset_t is configured for SIGUSR1, which will
not be triggered, so sigtimedwait just waits for timeout.

To be more specific - two use cases are checked:
- if sigtimedwait times out immediately when passed struct timespec has
  zero values of tv_nsec and tv_sec.
- if sigtimedwait times out after timeout specified in passed argument

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Provide test for select
Lukasz Majewski [Sat, 13 Mar 2021 22:34:21 +0000 (23:34 +0100)]
tst: Provide test for select

This change adds new test to assess select()'s timeout related
functionality (the rdfs set provides valid fd - stderr - but during
normal program operation there is no data to be read, so one just
waits for timeout).

To be more specific - two use cases are checked:
- if select() times out immediately when passed struct timeval has
  zero values of tv_usec and tv_sec.
- if select() times out after timeout specified in passed argument

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Add test for ntp_gettimex
Lukasz Majewski [Tue, 9 Mar 2021 10:38:05 +0000 (11:38 +0100)]
tst: Add test for ntp_gettimex

This test is a wrapper on tst-ntp_gettime test.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Add test for ntp_gettime
Lukasz Majewski [Tue, 9 Mar 2021 10:33:34 +0000 (11:33 +0100)]
tst: Add test for ntp_gettime

This code provides test to check if time on target machine is properly
read via ntp_gettime syscall.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agofix: Always export ntp_gettimex function
Lukasz Majewski [Tue, 23 Mar 2021 10:37:01 +0000 (11:37 +0100)]
fix: Always export ntp_gettimex function

After this patch applied the ntp_gettimex function is always declared
in the sys/timex.h header. Currently it is not when __REDIRECT_NTH is
defined (i.e. in ARM 32 bit port).

3 years agonptl: Remove MULTI_PAGE_ALIASING [BZ #23554]
H.J. Lu [Fri, 19 Mar 2021 19:53:40 +0000 (12:53 -0700)]
nptl: Remove MULTI_PAGE_ALIASING [BZ #23554]

MULTI_PAGE_ALIASING was introduced to mitigate an aliasing issue on
Pentium 4.  It is no longer needed for processors after Pentium 4.

3 years agoelf: Add EM_INTELGT for Intel Graphics Technology
H.J. Lu [Fri, 19 Mar 2021 17:39:32 +0000 (10:39 -0700)]
elf: Add EM_INTELGT for Intel Graphics Technology

Add EM_INTELGT (205) for Intel Graphics Technology which has been added
to gABI:

https://groups.google.com/g/generic-abi/c/ofBevXA48dM

3 years agosupport: Use syscall function instead of INLINE_SYSCALL_CALL
Adhemerval Zanella [Thu, 18 Mar 2021 20:52:09 +0000 (17:52 -0300)]
support: Use syscall function instead of INLINE_SYSCALL_CALL

It fixes the build on ARM in thumb mode that requires an out of the
line helper (__libc_do_syscall) to issue the syscall.

3 years agosignal: Add __libc_sigaction
Adhemerval Zanella [Mon, 15 Mar 2021 18:23:40 +0000 (15:23 -0300)]
signal: Add __libc_sigaction

The generic implementation basically handle the system agnostic logic
(filtering out the invalid signals) while the __libc_sigaction is
the function with implements the system and architecture bits.

Checked on x86_64-linux-gnu and i686-linux-gnu.

3 years agonptl: Move system to libc
Adhemerval Zanella [Mon, 15 Mar 2021 14:02:21 +0000 (11:02 -0300)]
nptl: Move system to libc

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Move fcntl from libpthread
Adhemerval Zanella [Sun, 14 Mar 2021 12:52:16 +0000 (09:52 -0300)]
nptl: Move fcntl from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove sendmsg from libpthread
Adhemerval Zanella [Sun, 14 Mar 2021 12:28:25 +0000 (09:28 -0300)]
nptl: Remove sendmsg from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove recvmsg from libpthread
Adhemerval Zanella [Sat, 13 Mar 2021 23:15:55 +0000 (20:15 -0300)]
nptl: Remove recvmsg from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove sigwait from libpthread
Adhemerval Zanella [Sat, 13 Mar 2021 23:11:50 +0000 (20:11 -0300)]
nptl: Remove sigwait from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove tcdrain from libpthread
Adhemerval Zanella [Sat, 13 Mar 2021 23:04:18 +0000 (20:04 -0300)]
nptl: Remove tcdrain from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove pause from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 23:57:52 +0000 (20:57 -0300)]
nptl: Remove pause from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove msync from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 23:29:57 +0000 (20:29 -0300)]
nptl: Remove msync from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove fsync from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:47:45 +0000 (16:47 -0300)]
nptl: Remove fsync from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove sendto from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:45:29 +0000 (16:45 -0300)]
nptl: Remove sendto from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove recvfrom from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:42:05 +0000 (16:42 -0300)]
nptl: Remove recvfrom from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove recv from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:33:38 +0000 (16:33 -0300)]
nptl: Remove recv from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove connect from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:31:17 +0000 (16:31 -0300)]
nptl: Remove connect from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove accept from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:29:32 +0000 (16:29 -0300)]
nptl: Remove accept from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove close from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:26:53 +0000 (16:26 -0300)]
nptl: Remove close from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove read from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:22:44 +0000 (16:22 -0300)]
nptl: Remove read from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agonptl: Remove write from libpthread
Adhemerval Zanella [Fri, 12 Mar 2021 19:13:26 +0000 (16:13 -0300)]
nptl: Remove write from libpthread

The libc version is identical and built with same flags.

Checked on x86_64-linux-gnu.

3 years agobenchtests: Add ilogb* tests
Raphael Moreira Zinsly [Thu, 3 Dec 2020 13:41:02 +0000 (10:41 -0300)]
benchtests: Add ilogb* tests

Add a benchtest to ilogb, ilogbf and ilogbf128 based on the logb* benchtests.

3 years agopowerpc: Add optimized llogb* for POWER9
Raphael Moreira Zinsly [Thu, 25 Feb 2021 12:58:52 +0000 (09:58 -0300)]
powerpc: Add optimized llogb* for POWER9

The POWER9 builtins used to improve the ilogb* functions can be
used in the llogb* functions as well.

3 years agopowerpc: Add optimized ilogb* for POWER9
Raphael Moreira Zinsly [Tue, 23 Feb 2021 17:14:37 +0000 (14:14 -0300)]
powerpc: Add optimized ilogb* for POWER9

The instructions xsxexpdp and xsxexpqp introduced on POWER9 extract
the exponent from a double-precision and quad-precision floating-point
respectively, thus they can be used to improve ilogb, ilogbf and ilogbf128.

3 years agoglibcymbols.read_abilist: Add check for duplicate symbols
Florian Weimer [Tue, 16 Mar 2021 14:56:50 +0000 (15:56 +0100)]
glibcymbols.read_abilist: Add check for duplicate symbols

This detects some bogus abilist files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoscripts/glibcsymbols.py: Extract from scripts/move-symbol-to-libc.py
Florian Weimer [Tue, 16 Mar 2021 14:56:50 +0000 (15:56 +0100)]
scripts/glibcsymbols.py: Extract from scripts/move-symbol-to-libc.py

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLegacy unwinder: Remove definition of _Unwind_GetCFA
Florian Weimer [Tue, 16 Mar 2021 14:33:09 +0000 (15:33 +0100)]
Legacy unwinder: Remove definition of _Unwind_GetCFA

It is not actually used by the legacy unwinder linked into
libc.so, and it conflicts with the unwind-link functionality
in libpthread.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agosupport: Pass environ to child process
Siddhesh Poyarekar [Mon, 15 Mar 2021 11:53:30 +0000 (17:23 +0530)]
support: Pass environ to child process

Pass environ to posix_spawn so that the child process can inherit
environment of the test.

3 years agopowerpc: Update libm-test-ulps
Matheus Castanho [Mon, 1 Mar 2021 20:07:27 +0000 (14:07 -0600)]
powerpc: Update libm-test-ulps

Generated with 'make regen-ulps' on POWER8.

Tested on powerpc, powerpc64, and powerpc64le

3 years agoBuild libc-start with stack protector for SHARED
Siddhesh Poyarekar [Mon, 15 Mar 2021 14:55:00 +0000 (20:25 +0530)]
Build libc-start with stack protector for SHARED

This does not change the emitted code since __libc_start_main does not
return, but is important for formal flags compliance.

This also cleans up the cosmetic inconsistency in the stack protector
flags in csu, especially the incorrect value of STACK_PROTECTOR_LEVEL.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoBuild get-cpuid-feature-leaf.c without stack-protector [BZ #27555]
Siddhesh Poyarekar [Mon, 15 Mar 2021 14:54:45 +0000 (20:24 +0530)]
Build get-cpuid-feature-leaf.c without stack-protector [BZ #27555]

__x86_get_cpuid_feature_leaf is called during early startup, before
the stack check guard is initialized and is hence not safe to build
with stack-protector.

Additionally, IFUNC resolvers for static tst-ifunc-isa tests get
called too early for stack protector to be useful, so fix them to
disable stack protector for the resolver functions.

This fixes all failures seen with --enable-stack-protector=all
configuration.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoAdd inhibit_stack_protector to ifuncmain9 [BZ #25680]
David Hughes [Mon, 15 Mar 2021 14:53:39 +0000 (20:23 +0530)]
Add inhibit_stack_protector to ifuncmain9 [BZ #25680]

Enabling --enable-stack-protector=all causes the following tests to fail:

    FAIL: elf/ifuncmain9picstatic
    FAIL: elf/ifuncmain9static

Nick Alcock (who committed the stack protector code) marked the IFUNC
resolvers with inhibit_stack_protector when he done the original work and
suggested doing so again @ BZ #25680. This patch adds
inhibit_stack_protector to ifuncmain9.

After patch is applied, --enable-stack-protector=all does not fail the
above tests.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agosupport: Typo and formatting fixes
Siddhesh Poyarekar [Mon, 15 Mar 2021 10:30:06 +0000 (16:00 +0530)]
support: Typo and formatting fixes

- Add a newline to the end of error messages in transfer().
- Fixed the name of support_subprocess_init().

3 years agoelf: ld.so --help calls _dl_init_paths without a main map [BZ #27577]
Florian Weimer [Mon, 15 Mar 2021 09:33:43 +0000 (10:33 +0100)]
elf: ld.so --help calls _dl_init_paths without a main map [BZ #27577]

In this case, use the link map of the dynamic loader itself as
a replacement.  This is more than just a hack: if we ever support
DT_RUNPATH/DT_RPATH for the dynamic loader, reporting it for
ld.so --help (without further command line arguments) would be the
right thing to do.

Fixes commit 332421312576bd7095e70589154af99b124dd2d1 ("elf: Always
set l in _dl_init_paths (bug 23462)").

3 years agox86: Handle _SC_LEVEL1_ICACHE_LINESIZE [BZ #27444]
H.J. Lu [Sat, 6 Mar 2021 18:19:32 +0000 (10:19 -0800)]
x86: Handle _SC_LEVEL1_ICACHE_LINESIZE [BZ #27444]

commit 2d651eb9265d1366d7b9e881bfddd46db9c1ecc4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 18 07:55:14 2020 -0700

    x86: Move x86 processor cache info to cpu_features

missed _SC_LEVEL1_ICACHE_LINESIZE.

1. Add level1_icache_linesize to struct cpu_features.
2. Initialize level1_icache_linesize by calling handle_intel,
handle_zhaoxin and handle_amd with _SC_LEVEL1_ICACHE_LINESIZE.
3. Return level1_icache_linesize for _SC_LEVEL1_ICACHE_LINESIZE.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoelf: Always set l in _dl_init_paths (bug 23462)
Carlos O'Donell [Fri, 12 Mar 2021 15:44:47 +0000 (16:44 +0100)]
elf: Always set l in _dl_init_paths (bug 23462)

After d1d5471579eb0426671bf94f2d71e61dfb204c30 ("Remove dead
DL_DST_REQ_STATIC code.") we always setup the link map l to make the
static and shared cases the same.  The bug is that in elf/dl-load.c
(_dl_init_paths) we conditionally set l only in the #ifdef SHARED
case, but unconditionally use it later.  The simple solution is to
remove the #ifdef SHARED conditional, because it's no longer needed,
and unconditionally setup l for both the static and shared cases. A
regression test is added to run a static binary with
LD_LIBRARY_PATH='$ORIGIN' which crashes before the fix and runs after
the fix.

Co-Authored-By: Florian Weimer <fweimer@redhat.com>
3 years agos390x: Regenerate ULPs.
Stefan Liebler [Fri, 12 Mar 2021 13:31:49 +0000 (14:31 +0100)]
s390x: Regenerate ULPs.

Updates needed after recent commit:
db3f7bb5586392d9809fc6397c7184983aed6008
"math: Remove slow paths from asin and acos [BZ #15267]"
Compre to the required ulps update for x86_64.

3 years agosupport: Add xpthread_kill
Adhemerval Zanella [Wed, 20 Jan 2021 17:32:23 +0000 (14:32 -0300)]
support: Add xpthread_kill

Checked on x86_64-linux-gnu.

3 years agonptl: Move fork into libc
Adhemerval Zanella [Tue, 19 Jan 2021 12:18:46 +0000 (09:18 -0300)]
nptl: Move fork into libc

This is part of the libpthread removal project:

   <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Checked on x86_64-linux-gnu.

3 years agolinux: Use __libc_single_threaded on fork
Adhemerval Zanella [Mon, 18 Jan 2021 18:32:02 +0000 (15:32 -0300)]
linux: Use __libc_single_threaded on fork

Checked on x86_64-linux-gnu.

3 years agoposix: Consolidate register-atfork
Adhemerval Zanella [Mon, 18 Jan 2021 18:10:02 +0000 (15:10 -0300)]
posix: Consolidate register-atfork

Both htl and nptl uses a different data structure to implement atfork
handlers.  The nptl one was refactored by 27761a1042d to use a dynarray
which simplifies the code.

This patch moves the nptl one to be the generic implementation and
replace Hurd linked one.  Different than previous NPTL, Hurd also uses
a global lock, so performance should be similar.

Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for
i686-gnu.

3 years agonptl: Move Linux pthread_kill to nptl
Adhemerval Zanella [Thu, 3 Dec 2020 14:28:58 +0000 (11:28 -0300)]
nptl: Move Linux pthread_kill to nptl

The nptl already expects a Linux syscall internally.  Also
__is_internal_signal is used and the DEBUGGING_P check is removed.

Checked on x86_64-linux-gnu.

3 years agoio: Return UNSUPPORTED if filesystem do not support 64 bit timestamps
Adhemerval Zanella [Thu, 11 Mar 2021 12:30:33 +0000 (09:30 -0300)]
io: Return UNSUPPORTED if filesystem do not support 64 bit timestamps

Some Linux filesystems might not fully support 64 bit timestamps [1],
which make some Linux specific tests to fail when they check for the
functionality.

This patch adds a new libsupport function, support_path_support_time64,
that returns whether the target file supports or not 64 bit timestamps.
The support is checked by issuing a utimensat and verifying both the
last access and last modification time against a statx call.

The tests that might fail are also adjusted to check the file support
as well:

  $ dd if=/dev/zero of=loopbackfile.img bs=100M count=1
  1+0 records in
  1+0 records out
  104857600 bytes (105 MB, 100 MiB) copied, 0,0589568 s, 1,8 GB/s
  $ sudo losetup -fP loopbackfile.img
  $ mkfs.xfs loopbackfile.img
  meta-data=loopbackfile.img       isize=512    agcount=4, agsize=6400 blks
           =                       sectsz=512   attr=2, projid32bit=1
           =                       crc=1        finobt=1, sparse=1, rmapbt=0
           =                       reflink=1
  data     =                       bsize=4096   blocks=25600, imaxpct=25
           =                       sunit=0      swidth=0 blks
  naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
  log      =internal log           bsize=4096   blocks=1368, version=2
           =                       sectsz=512   sunit=0 blks, lazy-count=1
  realtime =none                   extsz=4096   blocks=0, rtextents=0
  $ mkdir loopfs
  $ sudo mount -o loop /dev/loop0 loopfs/
  $ sudo chown -R azanella:azanella loopfs
  $ TMPDIR=loopfs/ ./testrun.sh misc/tst-utimes
  error: ../sysdeps/unix/sysv/linux/tst-utimes.c:55: File loopfs//utimesfECsK1 does not support 64-bit timestamps

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1795576

This page took 0.083171 seconds and 5 git commands to generate.