]> sourceware.org Git - glibc.git/log
glibc.git
3 years agomalloc: Ensure mtag code path in checked_request2size is cold nsz/mtag-2
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.

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.)

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.

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.

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.

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.

3 years agoaarch64: Optimize __libc_mtag_tag_zero_region nsz/mtag
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 agoRemove PR_TAGGED_ADDR_ENABLE from sys/prctl.h
Szabolcs Nagy [Tue, 2 Feb 2021 15:02:09 +0000 (15:02 +0000)]
Remove PR_TAGGED_ADDR_ENABLE from sys/prctl.h

The value of PR_TAGGED_ADDR_ENABLE was incorrect in the installed
headers and the prctl command macros were missing that are needed
for it to be useful (PR_SET_TAGGED_ADDR_CTRL).  Linux headers have
the definitions since 5.4 so it's widely available, we don't need
to repeat these definitions.  The remaining definitions are from
Linux 5.10.

To build glibc with --enable-memory-tagging, Linux 5.4 headers and
binutils 2.33.1 or newer is needed.

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.

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 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

3 years agotest-container: Always copy test-specific support files [BZ #27537]
DJ Delorie [Thu, 11 Mar 2021 17:50:02 +0000 (12:50 -0500)]
test-container: Always copy test-specific support files [BZ #27537]

There's a small chance that a fresh checkout will result in some of
the test-specific container files will have the same timestamp and
size, which breaks the rsync logic in test-container, resulting in
tests running with the wrong support files.

This patch changes the rsync logic to always copy the test-specific
files, which normally would always be copied anyway.  The rsync logic
for the testroot itself is unchanged.

3 years agomath: Remove mpa files (part 2) [BZ #15267]
Wilco Dijkstra [Thu, 11 Mar 2021 15:36:14 +0000 (15:36 +0000)]
math: Remove mpa files (part 2) [BZ #15267]

Previous commit was missing deleted files in sysdeps/ieee754/dbl-64.

Finally remove all mpa related files, headers, declarations, probes, unused
tables and update makefiles.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agomath: Remove mpa files [BZ #15267]
Wilco Dijkstra [Wed, 10 Mar 2021 12:41:47 +0000 (12:41 +0000)]
math: Remove mpa files [BZ #15267]

Finally remove all mpa related files, headers, declarations, probes, unused
tables and update makefiles.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agomath: Remove slow paths from atan2 [BZ #15267]
Wilco Dijkstra [Wed, 10 Mar 2021 12:41:20 +0000 (12:41 +0000)]
math: Remove slow paths from atan2 [BZ #15267]

Remove slow paths from atan2. Add ULP annotations.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agomath: Remove slow paths from atan [BZ #15267]
Wilco Dijkstra [Wed, 10 Mar 2021 12:40:56 +0000 (12:40 +0000)]
math: Remove slow paths from atan [BZ #15267]

Remove slow paths from atan. Add ULP annotations.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agomath: Remove slow paths in tan [BZ #15267]
Wilco Dijkstra [Wed, 10 Mar 2021 12:40:26 +0000 (12:40 +0000)]
math: Remove slow paths in tan [BZ #15267]

Remove slow paths in tan. Add ULP annotations. Merge 'number' into 'mynumber'.
Remove unused entries from tan constants.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agomath: Remove slow paths from asin and acos [BZ #15267]
Wilco Dijkstra [Wed, 10 Mar 2021 12:39:56 +0000 (12:39 +0000)]
math: Remove slow paths from asin and acos [BZ #15267]

This patch series removes all remaining slow paths and related code.
First asin/acos, tan, atan, atan2 implementations are updated, and the final
patch removes the unused mpa files, headers and probes. Passes buildmanyglibc.

Remove slow paths from asin/acos. Add ULP annotations based on previous slow
path checks (which are approximate). Update AArch64 and x86_64 libm-test-ulps.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agoio: Return EBAFD for negative file descriptor on fstat (BZ #27559)
Adhemerval Zanella [Thu, 11 Mar 2021 11:21:06 +0000 (08:21 -0300)]
io: Return EBAFD for negative file descriptor on fstat (BZ #27559)

Now that fstat is implemented on top fstatat we need to handle negative
inputs.  The implementation now rejects AT_FDCWD, which would otherwise
be accepted by the kernel.

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

3 years agoAllow gdb version 10 in pretty printer tests.
Stefan Liebler [Thu, 11 Mar 2021 09:45:15 +0000 (10:45 +0100)]
Allow gdb version 10 in pretty printer tests.

With gdb 10, the pretty printer tests are UNSUPPORTED::
The gdb version string (gdb -v) is incorrectly formatted.

This is observable in:
nptl/test-cond-printers, nptl/test-condattr-printers,
nptl/test-mutex-printers, nptl/test-mutexattr-printers,
nptl/test-rwlock-printers, nptl/test-rwlockattr-printers

After updating the regexp and building with debug-info,
all those tests are passing.

3 years agoUpdate kernel version to 5.11 in tst-mman-consts.py.
Joseph Myers [Wed, 10 Mar 2021 14:26:57 +0000 (14:26 +0000)]
Update kernel version to 5.11 in tst-mman-consts.py.

This patch updates the kernel version in the test tst-mman-consts.py
to 5.11.  (There are no new MAP_* constants covered by this test in
5.11 that need any other header changes.)

Tested with build-many-glibcs.py.

3 years agoLinux: misc/tst-ofdlocks-compat can be a regular test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
Linux: misc/tst-ofdlocks-compat can be a regular test

Now that compat_symbol_reference works in non-internal tests.
Also do not build and run the test at all on architectures which
do not have the pre-2.28 symbol version of fcntl.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: dirent/tst-readdir64-compat can be a regular test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
Linux: dirent/tst-readdir64-compat can be a regular test

compat_symbol_reference works in non-internal tests now.  Also
avoid building the test for unsupported configurations at all.
I verified by building with build-many-glibcs.py that GLIBC_2.1.3
works as the predecessor of GLIBC_2.2.  (Symbol versions in
the early days are complex.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agosunrpc: tst-svc_register can be a regular test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
sunrpc: tst-svc_register can be a regular test

Now that compat_symbol_reference is not restricted to internal tests
anymore.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoresolv: tst-p_secstodate can be a regular test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
resolv: tst-p_secstodate can be a regular test

Now that compat_symbol_reference works for non-internal tests, too.
Also do not build and run the tests on architectures which lack the
__p_secstodate compatibility symbol.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoposix: tst-spawn4-compat can be a regular test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
posix: tst-spawn4-compat can be a regular test

compat_symbol_reference now works for non-internal tests, too.
Also stop building and running the tests on those architectures
that lack the test symbol versions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoposix: tst-glob_lstat_compat no longer needs to be an internal test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
posix: tst-glob_lstat_compat no longer needs to be an internal test

compat_symbol_reference is now available for regular tests as well.
Also avoid building and running the tests in case the pre-2.27
symbol version of glob is not available.  This avoids a spurious
UNSUPPORTED result.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agomath: test-matherr and test-matherr-2 can be regular tests
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
math: test-matherr and test-matherr-2 can be regular tests

compat_symbol_reference is now available without tests-internal.
Do not build the test at all on glibc versions that lack the symbols,
to avoid spurious UNSUPPORTED results.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agomath: $(libm-tests-compat) can be regular tests
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
math: $(libm-tests-compat) can be regular tests

tests-internal is no longer needed because compat_symbol_reference
now works in regular tests.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agomalloc: Turn tst-mallocstate into a non-internal test
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
malloc: Turn tst-mallocstate into a non-internal test

compat_symbol_reference no longer needs tests-internal.  Do not build
the test at all for newer targets, so that no spurious UNSUPPORTED
result is generated.  Use compat_symbol_reference for
__malloc_initialize_hook as well, eliminating the need for -rdynamic.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years ago<shlib-compat.h>: Support compat_symbol_reference for _ISOMAC
Florian Weimer [Tue, 9 Mar 2021 20:07:24 +0000 (21:07 +0100)]
<shlib-compat.h>: Support compat_symbol_reference for _ISOMAC

This is helpful for testing compat symbols in cases where _ISOMAC
is activated implicitly due to -DMODULE_NAME=testsuite and cannot
be disabled easily.

3 years agonss: fix nss_database_lookup2's alternate handling [BZ #27416]
DJ Delorie [Tue, 16 Feb 2021 02:34:23 +0000 (21:34 -0500)]
nss: fix nss_database_lookup2's alternate handling [BZ #27416]

__nss_database_lookup2's extra arguments were left unused in the
nsswitch reloading patch set; this broke compat (default config
ignored) and shadow files (secondary name ignored) which relies on
these fallbacks.

This patch adds in the previous behavior by correcting the
initialization of the database list to reflect the fallbacks.  This
means that the nss_database_lookup2 interface no longer needs to be
passed the fallback info, so API and callers were adjusted.

Since all callers needed to be edited anyway, the calls were changed
from __nss_database_lookup2 to the faster __nss_database_get.  This
was an intended optimization which was deferred during the initial
lookup changes to avoid touching so many files.

The test case verifies that compat targets work (passwd) and that the
default configuration works (group).  Tested on x86-64.

3 years agoNEWS: Add entry for CVE-2021-27645
DJ Delorie [Wed, 3 Mar 2021 19:52:57 +0000 (14:52 -0500)]
NEWS: Add entry for CVE-2021-27645

3 years agotst: Add test for settimeofday
Lukasz Majewski [Sun, 7 Mar 2021 12:11:55 +0000 (13:11 +0100)]
tst: Add test for settimeofday

This code brings test to check if time on target machine is properly set.
To avoid any issues with altering the time:

- The time, which was set before the test was executed is restored.

- The time is altered only when cross-test-ssh.sh is executed with
  --allow-time-setting flag

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Add test for ntp_adjtime
Lukasz Majewski [Sun, 28 Feb 2021 22:26:21 +0000 (23:26 +0100)]
tst: Add test for ntp_adjtime

This test is a wrapper on tst-clock_adjtime test.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Add test for adjtimex
Lukasz Majewski [Sun, 28 Feb 2021 22:03:48 +0000 (23:03 +0100)]
tst: Add test for adjtimex

This test is a wrapper on tst-clock_adjtime test.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Modify tst-clock_adjtime to allow reuse of its code
Lukasz Majewski [Sun, 28 Feb 2021 22:02:54 +0000 (23:02 +0100)]
tst: Modify tst-clock_adjtime to allow reuse of its code

The tst-clock_adjtime can be adjusted to be reused for also testing
adjtimex.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Add test for clock_adjtime
Lukasz Majewski [Wed, 20 Jan 2021 11:10:42 +0000 (12:10 +0100)]
tst: Add test for clock_adjtime

This code privides test to check if time on target machine is properly
adjusted.
The time is altered only when cross-test-ssh.sh is executed with
--allow-time-setting flag.
As the delta added to CLOCK_REALTIME is only 1 sec the original time is
not restored and further tests are executed with this bias.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Add test for clock_settime
Lukasz Majewski [Mon, 18 Jan 2021 15:59:23 +0000 (16:59 +0100)]
tst: Add test for clock_settime

This code brings test to check if time on target machine is properly set.
To avoid any issues with altering the time:

- The time, which was set before the test was executed is restored.

- The time is altered only when cross-test-ssh.sh is executed with
  --allow-time-setting flag

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agosupport: Provide xclock_settime test helper function
Lukasz Majewski [Mon, 18 Jan 2021 15:53:26 +0000 (16:53 +0100)]
support: Provide xclock_settime test helper function

The xclock_settime is a wrapper function on the clock_settime syscall
to be used in the test code.

It checks if the GLIBC_TEST_ALLOW_TIME_SETTING env variable is defined
in the environment in which test is executed. If it is not - the test
ends as unsupported. Otherwise, the clock-settime is executed and return
value is assessed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotst: Extend cross-test-ssh.sh to specify if target date can be altered
Lukasz Majewski [Fri, 15 Jan 2021 15:40:39 +0000 (16:40 +0100)]
tst: Extend cross-test-ssh.sh to specify if target date can be altered

This code adds new flag - '--allow-time-setting' to cross-test-ssh.sh
script to indicate if it is allowed to alter the date on the system
on which tests are executed. This change is supposed to be used with
test systems, which use virtual machines for testing.

The GLIBC_TEST_ALLOW_TIME_SETTING env variable is exported to the
remote environment on which the eligible test is run and brings no
functional change when it is not.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoUpdate hppa libm-test-ulps
John David Anglin [Sun, 7 Mar 2021 17:23:34 +0000 (17:23 +0000)]
Update hppa libm-test-ulps

3 years agox86: Set minimum x86-64 level marker [BZ #27318]
H.J. Lu [Tue, 2 Feb 2021 21:45:58 +0000 (13:45 -0800)]
x86: Set minimum x86-64 level marker [BZ #27318]

Since the full ISA set used in an ELF binary is unknown to compiler,
an x86-64 ISA level marker indicates the minimum, not maximum, ISA set
required to run such an ELF binary.  We never guarantee a library with
an x86-64 ISA level v3 marker doesn't contain other ISAs beyond x86-64
ISA level v3, like AVX VNNI.  We check the x86-64 ISA level marker for
the minimum ISA set.  Since -march=sandybridge enables only some ISAs
in x86-64 ISA level v3, we should set the needed ISA marker to v2.
Otherwise, libc is compiled with -march=sandybridge will fail to run on
Sandy Bridge:

$ ./elf/ld.so ./libc.so
./libc.so: (p) CPU ISA level is lower than required: needed: 7; got: 3

Set the minimum, instead of maximum, x86-64 ISA level marker should have
no impact on the glibc-hwcaps directory assignment logic in ldconfig nor
ld.so.

3 years agoposix: glob, glob64 should not be declared __THROW [BZ #27522]
Florian Weimer [Fri, 5 Mar 2021 11:02:20 +0000 (12:02 +0100)]
posix: glob, glob64 should not be declared __THROW [BZ #27522]

These functions invoke callbacks with GLOB_ALTDIRFUNC, so they
are not leaf functions (as implied by _THROW).  Use __THROWNL
and __REDIRECT_NTHNL to express this.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Fix __pthread_clockjoin_np64 __pthread_timedjoin_np64 hidden proto
Adhemerval Zanella [Wed, 17 Feb 2021 14:10:52 +0000 (11:10 -0300)]
nptl: Fix __pthread_clockjoin_np64 __pthread_timedjoin_np64 hidden proto

They are both implemented in libpthread instead of libc.

3 years agolinux: Fix __thrd_sleep64 hidden definition
Adhemerval Zanella [Thu, 25 Feb 2021 23:43:13 +0000 (20:43 -0300)]
linux: Fix __thrd_sleep64 hidden definition

The symbol is exported by libc.

3 years agoUpdate arm libm-test-ulps
Adhemerval Zanella [Thu, 4 Mar 2021 19:12:42 +0000 (19:12 +0000)]
Update arm libm-test-ulps

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