]> sourceware.org Git - glibc.git/log
glibc.git
3 years agoposix: Add glob64 with 64-bit time_t support
Adhemerval Zanella [Tue, 2 Mar 2021 23:17:07 +0000 (20:17 -0300)]
posix: Add glob64 with 64-bit time_t support

The glob might pass a different stat struct for gl_stat and gl_lstat
when GLOB_ALTDIRFUNC is used.  This requires add a new 64-bit time
version that also uses 64-bit time stat functions.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Add support for 64-bit time on legacy ABIs
Adhemerval Zanella [Wed, 17 Feb 2021 16:35:19 +0000 (13:35 -0300)]
y2038: Add support for 64-bit time on legacy ABIs

A new build flag, _TIME_BITS, enables the usage of the newer 64-bit
time symbols for legacy ABI (where 32-bit time_t is default).  The 64
bit time support is only enabled if LFS (_FILE_OFFSET_BITS=64) is
also used.

Different than LFS support, the y2038 symbols are added only for the
required ABIs (armhf, csky, hppa, i386, m68k, microblaze, mips32,
mips64-n32, nios2, powerpc32, sparc32, s390-32, and sh).  The ABIs with
64-bit time support are unchanged, both for symbol and types
redirection.

On Linux the full 64-bit time support requires a minimum of kernel
version v5.1.  Otherwise, the 32-bit fallbacks are used and might
results in error with overflow return code (EOVERFLOW).

The i686-gnu does not yet support 64-bit time.

This patch exports following rediretions to support 64-bit time:

  * libc:
    adjtime
    adjtimex
    clock_adjtime
    clock_getres
    clock_gettime
    clock_nanosleep
    clock_settime
    cnd_timedwait
    ctime
    ctime_r
    difftime
    fstat
    fstatat
    futimens
    futimes
    futimesat
    getitimer
    getrusage
    gettimeofday
    gmtime
    gmtime_r
    localtime
    localtime_r
    lstat_time
    lutimes
    mktime
    msgctl
    mtx_timedlock
    nanosleep
    nanosleep
    ntp_gettime
    ntp_gettimex
    ppoll
    pselec
    pselect
    pthread_clockjoin_np
    pthread_cond_clockwait
    pthread_cond_timedwait
    pthread_mutex_clocklock
    pthread_mutex_timedlock
    pthread_rwlock_clockrdlock
    pthread_rwlock_clockwrlock
    pthread_rwlock_timedrdlock
    pthread_rwlock_timedwrlock
    pthread_timedjoin_np
    recvmmsg
    sched_rr_get_interval
    select
    sem_clockwait
    semctl
    semtimedop
    sem_timedwait
    setitimer
    settimeofday
    shmctl
    sigtimedwait
    stat
    thrd_sleep
    time
    timegm
    timerfd_gettime
    timerfd_settime
    timespec_get
    utime
    utimensat
    utimes
    utimes
    wait3
    wait4

  * librt:
    aio_suspend
    mq_timedreceive
    mq_timedsend
    timer_gettime
    timer_settime

  * libanl:
    gai_suspend

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agotime: Add 64-bit time support for getdate
Adhemerval Zanella [Tue, 2 Mar 2021 12:02:02 +0000 (09:02 -0300)]
time: Add 64-bit time support for getdate

The getdate is basically a wrapper localtime and mktime.  The 64-bit
time support is done calling the 64-bit internal functions, there is
no need to add a new symbol version.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Add __USE_TIME_BITS64 support for socket-constants.h
Adhemerval Zanella [Wed, 24 Feb 2021 13:37:02 +0000 (13:37 +0000)]
y2038: Add __USE_TIME_BITS64 support for socket-constants.h

It is only used for !__USE_MISC, the default way uses the kernel
headers.  The patch also adds the SO_TIMESTAMP, SO_TIMESTAMPNS, and
SO_TIMESTAMPING which uses new values for 64-bit time_t kernel
interfaces.

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Use a common definition for shmid_ds
Adhemerval Zanella [Wed, 17 Feb 2021 21:38:09 +0000 (18:38 -0300)]
y2038: Use a common definition for shmid_ds

Instead of replicate the same definitions from struct_shmid64_ds.h
on the multiple struct_shmid_ds.h, use a common header which is included
when required (struct_shmid64_ds_helper.h).

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit semctl implementation.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Use a common definition for semid_ds
Adhemerval Zanella [Wed, 17 Feb 2021 21:30:08 +0000 (18:30 -0300)]
y2038: Use a common definition for semid_ds

Instead of replicate the same definitions from struct_semid64_ds.h
on the multiple struct_semid_ds.h, use a common header which is included
when required (struct_semid64_ds_helper.h).

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit semctl implementation.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Use a common definition for msqid_ds
Lukasz Majewski [Thu, 22 Oct 2020 10:04:40 +0000 (12:04 +0200)]
y2038: Use a common definition for msqid_ds

Instead of replicate the same definitions from struct_msqid64_ds.h
on the multiple struct_msqid_ds.h, use a common header which is included
when required (struct_msqid64_ds_helper.h).

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Use a common definition for stat
Lukasz Majewski [Thu, 15 Oct 2020 07:30:59 +0000 (09:30 +0200)]
y2038: Use a common definition for stat

Instead of replicate the same definitions from struct_stat_time64.h
on the multiple struct_stat.h, use a common header which is included
when required (struct_stat_time64_helper.h).  The 64-bit time support
is added only for LFS support.

The __USE_TIME_BITS64 is not defined internally yet, although the
internal header is used when building the 64-bit stat implementations.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: linux: Add __USE_TIME_BITS64 support for struct timex
Adhemerval Zanella [Wed, 17 Feb 2021 19:20:43 +0000 (16:20 -0300)]
y2038: linux: Add __USE_TIME_BITS64 support for struct timex

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Add __USE_TIME_BITS64 support for struct utimbuf
Adhemerval Zanella [Wed, 17 Feb 2021 19:20:18 +0000 (16:20 -0300)]
y2038: Add __USE_TIME_BITS64 support for struct utimbuf

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Add __USE_TIME_BITS64 support for struct timespec
Adhemerval Zanella [Wed, 17 Feb 2021 19:19:45 +0000 (16:19 -0300)]
y2038: Add __USE_TIME_BITS64 support for struct timespec

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Add __USE_TIME_BITS64 support for struct timeval
Adhemerval Zanella [Wed, 17 Feb 2021 19:19:23 +0000 (16:19 -0300)]
y2038: Add __USE_TIME_BITS64 support for struct timeval

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoy2038: Add __USE_TIME_BITS64 support for time_t
Adhemerval Zanella [Wed, 17 Feb 2021 19:18:42 +0000 (16:18 -0300)]
y2038: Add __USE_TIME_BITS64 support for time_t

The __USE_TIME_BITS64 is not defined internally yet.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: Add recvvmsg fallback for 64-bit time_t SO_TIMESTAMP{NS}
Adhemerval Zanella [Tue, 8 Sep 2020 12:08:10 +0000 (09:08 -0300)]
linux: Add recvvmsg fallback for 64-bit time_t SO_TIMESTAMP{NS}

Handle the SO_TIMESTAMP{NS} similar to recvmsg: for
!__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP
or SO_TIMESTAMPNS and appends it to the control buffer if has extra
space or returns MSG_CTRUNC otherwise.  The 32-bit time field is kept
as-is.

Also for !__ASSUME_TIME64_SYSCALLS it limits the maximum number of
'struct mmsghdr *' to IOV_MAX (and also increases the stack size
requirement to IOV_MAX times sizeof (socklen_t)).  The Linux imposes
a similar limit to sendmmsg, so bound the array size on recvmmsg is not
unreasonable.  And this will be used only on older when building with
32-bit time support.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}
Adhemerval Zanella [Mon, 7 Sep 2020 20:08:46 +0000 (17:08 -0300)]
linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS}

The recvmsg handling is more complicated because it requires check the
returned kernel control message and make some convertions.  For
!__ASSUME_TIME64_SYSCALLS it converts the first 32-bit time SO_TIMESTAMP
or SO_TIMESTAMPNS and appends it to the control buffer if has extra
space or returns MSG_CTRUNC otherwise.  The 32-bit time field is kept
as-is.

Calls with __TIMESIZE=32 will see the converted 64-bit time control
messages as spurious control message of unknown type.  Calls with
__TIMESIZE=64 running on pre-time64 kernels will see the original
message as a spurious control ones of unknown typ while running on
kernel with native 64-bit time support will only see the time64 version
of the control message.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO
Adhemerval Zanella [Mon, 7 Sep 2020 17:13:58 +0000 (14:13 -0300)]
linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO

The constant values will be changed for __TIMESIZE=64, so binaries built
with 64-bit time support might fail to work properly on old kernels.
Both {get,set}sockopt will retry the syscall with the old constant
values and the timeout value adjusted when kernel returns ENOTPROTOPT.

It also adds an internal only SO_{RCV,SND}TIMEO where
COMPAT_SO_{RCV,SND}TIMEO_OLD indicates pre 32-bit time support and
COMPAT_SO_{RCV,SND}TIMEO_NEW indicates time64 support.  It allows to
refer to constant independently of the time_t ABI and kernel version
used.

Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15
kernel).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: s390: Add libanl.abilist in s390 and s390x
Adhemerval Zanella [Mon, 22 Feb 2021 21:11:35 +0000 (21:11 +0000)]
linux: s390: Add libanl.abilist in s390 and s390x

The s390 will require the 64-bit time symbols for y2038 support.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: mips: Split libanl.abilist in n32 and n64
Adhemerval Zanella [Mon, 22 Feb 2021 21:10:28 +0000 (21:10 +0000)]
linux: mips: Split libanl.abilist in n32 and n64

The n32 will require the 64-bit time symbols for y2038 support.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: mips: Split librt.abilist in n32 and n64
Adhemerval Zanella [Mon, 22 Mar 2021 18:18:41 +0000 (15:18 -0300)]
linux: mips: Split librt.abilist in n32 and n64

The n32 will require the 64-bit time symbols for y2038 support.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoReinstate gconv-modules as the default configuration file
Siddhesh Poyarekar [Mon, 14 Jun 2021 05:39:56 +0000 (11:09 +0530)]
Reinstate gconv-modules as the default configuration file

Reinstate gconv-modules as the main file so that the configuration
files in gconv-modules.d/ become add-on configuration.  With this, the
effective user visible change is that GCONV_PATH can now have
supplementary configuration in GCONV_PATH/gconv-modules.d/ in addition
to the main GCONV_PATH/gconv-modules file.

3 years agoAdd build option to disable usage of scv on powerpc
Matheus Castanho [Fri, 9 Apr 2021 17:47:27 +0000 (14:47 -0300)]
Add build option to disable usage of scv on powerpc

Commit 68ab82f56690ada86ac1e0c46bad06ba189a10ef added support for the scv
syscall ABI on powerpc.  Since then systems that have kernel and processor
support started using scv.  However adding the proper support for a new syscall
ABI requires changes to several other projects (e.g. qemu, valgrind, strace,
kernel), which are gradually receiving support.

Meanwhile, having a way to disable scv on glibc at build time can be useful for
distros that may encounter conflicts with projects that still do not support the
scv ABI, buying time until proper support is added.

This commit adds a --disable-scv option that disables scv support and uses sc
for all syscalls, like before commit 68ab82f56690ada86ac1e0c46bad06ba189a10ef.

Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
3 years agoio: Fix sporadic test failures in io/tst-stat
Florian Weimer [Thu, 10 Jun 2021 08:09:51 +0000 (10:09 +0200)]
io: Fix sporadic test failures in io/tst-stat

support_stat_nanoseconds cannot restore the ctime time, and
this may lead to sporadic test failures.  Therefore, probe for
nanoseconds support before the initial statx call.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Avoid async cancellation to wrongly update __nptl_nthreads (BZ #19366)
Adhemerval Zanella [Thu, 27 May 2021 15:42:13 +0000 (12:42 -0300)]
nptl: Avoid async cancellation to wrongly update __nptl_nthreads (BZ #19366)

The testcase provided on BZ#19366 may update __nptl_nthreads in a wrong
order, triggering an early process exit because the thread decrement
the value twice.

The issue is once the thread exits without acting on cancellation,
it decreaments '__nptl_nthreads' and then atomically set
 'cancelhandling' with EXITING_BIT (thus preventing further cancellation
handler to act).  The issue happens if a SIGCANCEL is received between
checking '__ntpl_nthreads' and setting EXITING_BIT.  To avoid it, the
'__nptl_nthreads' decrement is moved after EXITING_BIT.

It does fully follow the POSIX XSH 2.9.5 Thread Cancellation under
the heading Thread Cancellation Cleanup Handlers that states that
when a cancellation request is acted upon, or when a thread calls
pthread_exit(), the thread first disables cancellation by setting its
cancelability state to PTHREAD_CANCEL_DISABLE and its cancelability type
to PTHREAD_CANCEL_DEFERRED.  The issue is '__pthread_enable_asynccancel'
explicit enabled assynchrnous cancellation, so an interrupted syscall
within the cancellation cleanup handlers might see an invalid cancelling
type (a possible fix might be possible with my proposed solution to
BZ#12683).

Trying to come up with a test is quite hard since it requires to
mimic the timing issue described below, however I see that the
bug report reproducer does not early exit anymore.

Checked on x86_64-linux-gnu.

3 years agonptl: Use pthread_kill on pthread_cancel
Adhemerval Zanella [Mon, 7 Dec 2020 20:17:24 +0000 (17:17 -0300)]
nptl: Use pthread_kill on pthread_cancel

It consolidates the tgkill call and it is the first step of making
pthread_cancel async-signal-safe.  It also fix a possible issue
where the 'struct pthread' tid is not read atomically, which might
send an invalid cancellation signal (similar to what
db988e50a87f613cb6b9e98a2fc66a4848bc3546 fixed for pthread_join).

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

3 years agonptl: Implement raise in terms of pthread_kill
Adhemerval Zanella [Mon, 7 Dec 2020 19:21:55 +0000 (16:21 -0300)]
nptl: Implement raise in terms of pthread_kill

Now that pthread_kill is provided by libc.so it is possible to
implement the generic POSIX implementation as
'pthread_kill(pthread_self(), sig)'.

For Linux implementation, pthread_kill read the targeting TID from
the TCB.  For raise, this it not possible because it would make raise
fail when issue after vfork (where creates the resulting process
has a different TID from the parent, but its TCB is not updated as
for pthread_create).  To make raise use pthread_kill, it is make
usable from vfork by getting the target thread id through gettid
syscall.

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

3 years agonptl: Move cancel type out of cancelhandling
Adhemerval Zanella [Tue, 31 Mar 2020 20:24:39 +0000 (17:24 -0300)]
nptl: Move cancel type out of cancelhandling

Now that the thread cancellation type is not accessed concurrently
anymore, it is possible to move it out the cancelhandling.

By removing the cancel state out of the internal thread cancel handling
state there is no need to check if cancelled bit was set in CAS
operation.

It allows simplifing the cancellation wrappers and the
CANCEL_CANCELED_AND_ASYNCHRONOUS is removed.

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

3 years agonptl: Move cancel state out of cancelhandling
Adhemerval Zanella [Tue, 31 Mar 2020 18:43:25 +0000 (15:43 -0300)]
nptl: Move cancel state out of cancelhandling

Now that thread cancellation state is not accessed concurrently anymore,
it is possible to move it out the 'cancelhandling'.

The code is also simplified: CANCELLATION_P is replaced with a
internal pthread_testcancel call and the CANCELSTATE_BIT{MASK} is
removed.

With this behavior pthread_setcancelstate does not require to act on
cancellation if cancel type is asynchronous (is already handled either
by pthread_setcanceltype or by the signal handler).

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

3 years agonptl: Remove CANCELING_BITMASK
Adhemerval Zanella [Tue, 25 May 2021 17:31:30 +0000 (14:31 -0300)]
nptl: Remove CANCELING_BITMASK

The CANCELING_BITMASK is used as an optimization to avoid sending
the signal when pthread_cancel is called in a concurrent manner.

This requires then to put both the cancellation state and type on a
shared state (cancelhandling), since 'pthread_cancel' checks whether
cancellation is enabled and asynchrnous to either cancel itself of
 sending the signal.

It also requires handle the CANCELING_BITMASK on
__pthread_disable_asynccancel, however this incurs in the same issues
described on BZ#12683: the cancellation is acted upon even *after*
syscall returns with user visible side-effects.

This patch removes this optimization and simplifies the pthread
cancellation implementation: pthread_cancel now first checks if
cancellation is already pending and if not always, sends a signal
if the target is not itself.  The SIGCANCEL handler is also simpified
since there is not need to setup a CAS loop.

It also allows to move both the cancellation state and mode out of
'cancelhadling' (it is done in subsequent patches).

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

3 years agonptl: Install cancellation handler on pthread_cancel
Adhemerval Zanella [Mon, 24 May 2021 21:56:59 +0000 (18:56 -0300)]
nptl: Install cancellation handler on pthread_cancel

Now that cancellation is not used anymore to handle thread setup
creation failure, the sighandle can be installed only when
pthread_cancel is actually used.

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

3 years agonptl: Deallocate the thread stack on setup failure (BZ #19511)
Adhemerval Zanella [Fri, 21 May 2021 17:19:23 +0000 (14:19 -0300)]
nptl: Deallocate the thread stack on setup failure (BZ #19511)

To setup either the thread scheduling parameters or affinity,
pthread_create enforce synchronization on created thread to wait until
its parent either release PD ownership or send a cancellation signal if
a failure occurs.

However, cancelling the thread does not deallocate the newly created
stack since cancellation expects that a pthread_join to deallocate any
allocated thread resouces (threads stack or TLS).

This patch changes on how the thread resource is deallocate in case of
failure to be synchronous, where the creating thread will signal the
created thread to exit early so it could be joined.  The creating thread
will be reponsible for the resource cleanup before returning to the
caller.

To signal the creating thread that a failure has occured, an unused
'struct pthread' member, parent_cancelhandling_unsed, now indicates
whether the setup has failed so creating thread can proper exit.

This strategy also simplifies by not using thread cancellation and
thus not running libgcc_so load in the signal handler (which is
avoided in thread cancellation since 'pthread_cancel' is the one
responsible to dlopen libgcc_s).  Another advantage is since the
early exit is move to first step at thread creation, the signal
mask is not already set and thus it can not act on change ID setxid
handler.

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

3 years agoRemove stale references to libdl.a
Florian Weimer [Wed, 9 Jun 2021 11:38:44 +0000 (13:38 +0200)]
Remove stale references to libdl.a

Since commit 0c1c3a771eceec46e66ce1183cf988e2303bd373
("dlfcn: Move dlopen into libc") libdl.a is empty, so linking
against it is no longer necessary.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoFix elf/tst-tls9-static after libdl cleanups.
Stefan Liebler [Wed, 9 Jun 2021 11:19:51 +0000 (13:19 +0200)]
Fix elf/tst-tls9-static after libdl cleanups.

The testcase elf/tst-tls9-static sometimes fails with:
cannot open 'tst-tlsmod5.so': tst-tlsmod5.so: cannot open shared object file: No such file or directory
cannot open 'tst-tlsmod6.so': tst-tlsmod6.so: cannot open shared object file: No such file or directory

After recent commit
6f1c701026287f6928d3bdd1aea7359308635abe
"dlfcn: Cleanups after -ldl is no longer required"
the libdl variable is not set anymore and thus the
dependencies were missing.

3 years agoiconvdata: Split out non-essential gconv module configuration
Siddhesh Poyarekar [Mon, 7 Jun 2021 08:52:21 +0000 (14:22 +0530)]
iconvdata: Split out non-essential gconv module configuration

Split module configuration so that only the bare minimum charsets,
i.e. ANSI_X3.110, ISO8859-15, ISO8859-1, CP1252, UNICODE, UTF-16,
UTF-32 and UTF-7 are configured in gconv-modules.conf.  The remaining
module configurations are now in gconv-modules-extra.conf.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoiconvdata: Move gconv-modules configuration to gconv-modules.conf
Siddhesh Poyarekar [Mon, 7 Jun 2021 08:52:20 +0000 (14:22 +0530)]
iconvdata: Move gconv-modules configuration to gconv-modules.conf

Move all gconv-modules configuration files to gconv-modules.conf.
That is, the S390 extensions now become gconv-modules-s390.conf.  Move
both configuration files into gconv-modules.d.

Now GCONV_PATH/gconv-modules is read only for backward compatibility
for third-party gconv modules directories.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agogconv_conf: Read configuration files in gconv-modules.d
Siddhesh Poyarekar [Mon, 7 Jun 2021 08:52:19 +0000 (14:22 +0530)]
gconv_conf: Read configuration files in gconv-modules.d

Read configuration files with names ending in .conf in
GCONV_PATH/gconv-modules.d to mirror configuration flexibility in
iconvconfig into the iconv program and function.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoiconvconfig: Read configuration from gconv-modules.d subdirectory
Siddhesh Poyarekar [Mon, 7 Jun 2021 08:52:18 +0000 (14:22 +0530)]
iconvconfig: Read configuration from gconv-modules.d subdirectory

In addition to GCONV_PATH/gconv-modules, also read module
configuration from *.conf files in GCONV_PATH/gconv-modules.d.  This
allows a single gconv directory to have multiple sets of gconv modules
but at the same time, a single modules cache.

With this feature, one could separate the glibc supported gconv
modules into a minimal essential set (ISO-8859-*, UTF, etc.) from the
remaining modules.  In future, these could be further segregated into
langpack-associated sets with their own
gconv-modules.d/someconfig.conf.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoiconvconfig: Make file handling more general purpose
Siddhesh Poyarekar [Mon, 7 Jun 2021 08:52:17 +0000 (14:22 +0530)]
iconvconfig: Make file handling more general purpose

Split out configuration file handling code from handle_dir into its
own function so that it can be reused for multiple configuration
files.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoAArch64: Add support for roundeven[f]
Wilco Dijkstra [Tue, 8 Jun 2021 12:33:09 +0000 (13:33 +0100)]
AArch64: Add support for roundeven[f]

Add inline assembler for the roundeven functions.
Passes GLIBC regression.  Note GCC does not inline the builtin (PR100966),
so this cannot be used for now.

3 years agoconfigure: Replaced obsolete AC_TRY_COMPILE
Naohiro Tamura [Sat, 22 May 2021 02:42:48 +0000 (02:42 +0000)]
configure: Replaced obsolete AC_TRY_COMPILE

This patch replaced obsolete AC_TRY_COMPILE to AC_COMPILE_IFELSE or
AC_PREPROC_IFELSE.
It has been confirmed that GNU 'autoconf' 2.69 suppressed obsolete
warnings, updated the following files:
  - configure
  - sysdeps/mach/configure
  - sysdeps/mach/hurd/configure
  - sysdeps/s390/configure
  - sysdeps/unix/sysv/linux/configure
and didn't change the following files:
  - sysdeps/ieee754/ldbl-opt/configure
  - sysdeps/unix/sysv/linux/powerpc/configure

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agolibio: Assume _IO_lock_inexpensive
Adhemerval Zanella [Mon, 10 May 2021 21:05:49 +0000 (18:05 -0300)]
libio: Assume _IO_lock_inexpensive

It is already set by both Linux and Hurd.

3 years agonptl: Remove exit-thread.h
Adhemerval Zanella [Thu, 27 May 2021 12:11:10 +0000 (09:11 -0300)]
nptl: Remove exit-thread.h

No function change.  The code is used only for Linux, besides
being included in generic code.

3 years agoImprove test coverage of strnlen function
Sunil K Pandey [Mon, 31 May 2021 17:44:46 +0000 (10:44 -0700)]
Improve test coverage of strnlen function

This patch covers the following condition:

Strings start with different alignments and end with length less than or
equal to 512 byte.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agodlfcn: Rework static dlopen hooks
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Rework static dlopen hooks

Consolidate all hooks structures into a single one.  There are
no static dlopen ABI concerns because glibc 2.34 already comes
with substantial ABI-incompatible changes in this area.  (Static
dlopen requires the exact same dynamic glibc version that was used
for static linking.)

The new approach uses a pointer to the hooks structure into
_rtld_global_ro and initalizes it in __rtld_static_init.  This avoids
a back-and-forth with various callback functions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Eliminate GLIBC_PRIVATE dependency from tststatic2
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Eliminate GLIBC_PRIVATE dependency from tststatic2

The test appears to use _dlfcn_hook@@GLIBC_PRIVATE as a way to
test dlvsym without having to know the appropriate symbol version.
With <first-versions.h>, we can use a public symbol and the symbol
version at which it was defined first.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Cleanups after -ldl is no longer required
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Cleanups after -ldl is no longer required

This commit removes the ELF constructor and internal variables from
dlfcn/dlfcn.c.  The file now serves the same purpose as
nptl/libpthread-compat.c, so it is renamed to dlfcn/libdl-compat.c.
The use of libdl-shared-only-routines ensures that libdl.a is empty.

This commit adjusts the test suite not to use $(libdl).  The libdl.so
symbolic link is no longer installed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dlopen into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dlopen into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dlvsym into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dlvsym into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dlinfo into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dlinfo into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dladdr1 into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dladdr1 into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dlmopen into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dlmopen into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dlsym into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dlsym into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

In elf/Makefile, remove the $(libdl) dependency from testobj1.so
because it the unused libdl DSO now causes elf/tst-unused-deps to
fail.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dladdr into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dladdr into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agodlfcn: Move dlclose into libc
Florian Weimer [Thu, 3 Jun 2021 06:26:04 +0000 (08:26 +0200)]
dlfcn: Move dlclose into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoImprove test coverage of strlen function
Sunil K Pandey [Mon, 31 May 2021 18:08:12 +0000 (11:08 -0700)]
Improve test coverage of strlen function

This patch covers the following conditions:

- Strings start with different alignments and end at the page boundary
  with less than 64 byte length.
- Strings starts with different alignments and cross page boundary with
  fixed length.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agofix typo
Xeonacid [Wed, 2 Jun 2021 10:12:48 +0000 (10:12 +0000)]
fix typo

"accomodate" should be "accommodate"
Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
3 years agodlfcn: Move dlerror into libc
Florian Weimer [Wed, 2 Jun 2021 05:32:20 +0000 (07:32 +0200)]
dlfcn: Move dlerror into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

There is a minor functionality enhancement: dlerror now sets
errno if it was set as part of the exception.  (This is the result
of using %m in asprintf, to avoid the strerror PLT call.) The
previous errno value upon function return was unpredictable.
Documenting this as a feature is premature; we need to make sure
that the error codes are meaningful when they are set by the dynamic
loader.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoAdd libc ABI extension kludge for baseline-violating libdl symbols
Florian Weimer [Wed, 2 Jun 2021 05:32:19 +0000 (07:32 +0200)]
Add libc ABI extension kludge for baseline-violating libdl symbols

Some targets have a GLIBC_2.0 baseline for libdl, while using
GLIBC_2.2 for libc.  This means that the generated libc.map file
does not have any version nodes for GLIBC_2.0 or GLIBC_2.1.  However,
moving symbols from libdl into libc needs such version nodes.
(Future symbol moves from librt will need this as well.)

This kludge is only necessary for symbols predating GLIBC_2.2 because
the affected targets use GLIBC_2.2 as the baseline for libc.  Given
the small number and fixed set of affected architectures, no generic
mechanism is implemented, and instead the map file fragment is
hard-coded in scripts/versions.mk.

The compat_symbol macro already emits the appropriate version strings,
so no adjustments are needed there.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoscripts/versions.awk: Add local: * to all version nodes
Florian Weimer [Wed, 2 Jun 2021 05:32:19 +0000 (07:32 +0200)]
scripts/versions.awk: Add local: * to all version nodes

This requires that all exported symbol versions are listed in
Versions files.  It results in more consistent behavior across
architectures because previously, symbols could be exported
via explicit versioned_symbol and compat_symbol macros if the
version node existed in some Versions file (without listing the
symbol), and it was not the base version for the library (which
already had the local: * directive).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoAdd missing symbols to Version files
Florian Weimer [Wed, 2 Jun 2021 05:32:19 +0000 (07:32 +0200)]
Add missing symbols to Version files

Some symbols have explicit versioned_symbol or compat_symbol markers
in the sources, but no corresponding entry in the Versions files.
This presently works because the local: * directive is only applied
to the base version.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoFix use of __pthread_attr_copy in mq_notify (bug 27896)
Florian Weimer [Tue, 1 Jun 2021 15:51:41 +0000 (17:51 +0200)]
Fix use of __pthread_attr_copy in mq_notify (bug 27896)

__pthread_attr_copy can fail and does not initialize the attribute
structure in that case.

If __pthread_attr_copy is never called and there is no allocated
attribute, pthread_attr_destroy should not be called, otherwise
there is a null pointer dereference in rt/tst-mqueue6.

Fixes commit 42d359350510506b87101cf77202fefcbfc790cb
("Use __pthread_attr_copy in mq_notify (bug 27896)").

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoUse __pthread_attr_copy in mq_notify (bug 27896)
Andreas Schwab [Thu, 27 May 2021 10:49:47 +0000 (12:49 +0200)]
Use __pthread_attr_copy in mq_notify (bug 27896)

Make a deep copy of the pthread attribute object to remove a potential
use-after-free issue.

3 years agoUpdate floating-point feature test macro handling for C2X
Joseph Myers [Tue, 1 Jun 2021 14:22:06 +0000 (14:22 +0000)]
Update floating-point feature test macro handling for C2X

ISO C2X has made some changes to the handling of feature test macros
related to features from the floating-point TSes, and to exactly what
such features are present in what headers, that require corresponding
changes in glibc.

* For the few features that were controlled by
  __STDC_WANT_IEC_60559_BFP_EXT__ (and the corresponding DFP macro) in
  C2X, there is now instead a new feature test macro
  __STDC_WANT_IEC_60559_EXT__ covering both binary and decimal FP.
  This controls CR_DECIMAL_DIG in <float.h> (provided by GCC; I
  implemented support for the new feature test macro for GCC 11) and
  the totalorder and payload functions in <math.h>.  C2X no longer
  says anything about __STDC_WANT_IEC_60559_BFP_EXT__ (so it's
  appropriate for that macro to continue to enable exactly the
  features from TS 18661-1).

* The SNAN macros for each floating-point type have moved to <float.h>
  (and been renamed in the process).  Thus, the copies in <math.h>
  should only be defined for __STDC_WANT_IEC_60559_BFP_EXT__, not for
  C2X.

* The fmaxmag and fminmag functions have been removed (replaced by new
  functions for the new min/max operations in IEEE 754-2019).  Thus
  those should also only be declared for
  __STDC_WANT_IEC_60559_BFP_EXT__.

* The _FloatN / _FloatNx handling for the last two points in glibc is
  trickier, since __STDC_WANT_IEC_60559_TYPES_EXT__ is still in C2X
  (the integration of TS 18661-3 as an Annex, that is, which hasn't
  yet been merged into the C standard git repository but has been
  accepted by WG14), so C2X with that macro should not declare some
  things that are declared for older standards with that macro.  The
  approach taken here is to provide the declarations (when
  __STDC_WANT_IEC_60559_TYPES_EXT__ is enabled) only when (defined
  __USE_GNU || !__GLIBC_USE (ISOC2X)), so if C2X features are enabled
  then those declarations (that are only in TS 18661-3 and not in C2X)
  will only be provided if _GNU_SOURCE is defined as well.  Thus
  _GNU_SOURCE remains a superset of the TS features as well as of C2X.

Some other somewhat related changes in C2X are not addressed here.
There's an open proposal not to include the fmin and fmax functions
for the _FloatN / _FloatNx types, given the new min/max operations,
which could be handled like the previous point if adopted.  And the
fromfp functions have been changed to return a result in floating type
rather than intmax_t / uintmax_t; my inclination there is to treat
that like that change of totalorder type (new symbol versions etc. for
the ABI change; old versions become compat symbols and are no longer
supported as an API).

Tested for x86_64 and x86.

3 years agostdio-common: Remove _IO_vfwscanf
Florian Weimer [Tue, 1 Jun 2021 14:00:48 +0000 (16:00 +0200)]
stdio-common: Remove _IO_vfwscanf

The symbol has never been exported, so no compatibility symbol is
needed.  Removing this file prevents ld from creation an exported
symbol in case GLIBC_2_0 expands to a symbol version which
does not have a local: *; directive in the symbol version map file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoaarch64: align stack in clone [BZ #27939]
Szabolcs Nagy [Tue, 1 Jun 2021 08:23:40 +0000 (09:23 +0100)]
aarch64: align stack in clone [BZ #27939]

The AArch64 PCS requires 16 byte aligned stack.  Previously if the
caller passed an unaligned stack to clone then the child crashed.

Fixes bug 27939.

3 years agopowerpc: Optimized memcmp for power10
Lucas A. M. Magalhaes [Thu, 6 May 2021 20:01:52 +0000 (17:01 -0300)]
powerpc: Optimized memcmp for power10

This patch was based on the __memcmp_power8 and the recent
__strlen_power10.

Improvements from __memcmp_power8:

1. Don't need alignment code.

   On POWER10 lxvp and lxvl do not generate alignment interrupts, so
they are safe for use on caching-inhibited memory.  Notice that the
comparison on the main loop will wait for both VSR to be ready.
Therefore aligning one of the input address does not improve
performance.  In order to align both registers a vperm is necessary
which add too much overhead.

2. Uses new POWER10 instructions

   This code uses lxvp to decrease contention on load by loading 32 bytes
per instruction.
   The vextractbm is used to have a smaller tail code for calculating the
return value.

3. Performance improvement

   This version has around 35% better performance on average. I saw no
performance regressions for any length or alignment.

Thanks Matheus for helping me out with some details.

Co-authored-by: Matheus Castanho <msc@linux.ibm.com>
Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
3 years agox86-64: Align child stack to 16 bytes [BZ #27902]
H.J. Lu [Sun, 23 May 2021 17:25:10 +0000 (10:25 -0700)]
x86-64: Align child stack to 16 bytes [BZ #27902]

In the x86-64 clone wrapper, align child stack to 16 bytes per the
x86-64 psABI.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agosupport: Do not build xpthread_attr_setaffinity_np for hurd
Adhemerval Zanella [Fri, 28 May 2021 19:00:19 +0000 (16:00 -0300)]
support: Do not build xpthread_attr_setaffinity_np for hurd

It does not provide pthread_attr_setaffinity_np extension.

3 years agonptl: Add pthread_attr_setaffinity_np failure test
Adhemerval Zanella [Mon, 24 May 2021 16:47:10 +0000 (13:47 -0300)]
nptl: Add pthread_attr_setaffinity_np failure test

It checks whether an invalid affinity mask does return an error,
similar to what sysdeps/pthread/tst-bad-schedattr.c does for
pthread_attr_setschedparam.

Checked on x86_64-linux-gnu.

3 years agosupport: Add xpthread_attr_setaffinity_np wrapper
Adhemerval Zanella [Fri, 21 May 2021 18:09:43 +0000 (15:09 -0300)]
support: Add xpthread_attr_setaffinity_np wrapper

3 years agonptl: Move createthread to pthread_create
Adhemerval Zanella [Fri, 21 May 2021 13:12:37 +0000 (10:12 -0300)]
nptl: Move createthread to pthread_create

The 'create_thread' function is moved to pthread_create.c.  It removes
the START_THREAD_DEFN and START_THREAD_SELF macros and make the
lock usage more clear (no need to cross-reference multiple files).

No functional change.

3 years agonptl: Move Linux createthread to nptl
Adhemerval Zanella [Fri, 21 May 2021 13:09:31 +0000 (10:09 -0300)]
nptl: Move Linux createthread to nptl

git mv -f sysdeps/unix/sysv/linux/createthread.c nptl/createthread.c

No functional change.

3 years agonptl: Install SIGSETXID handler with SA_ONSTACK [BZ #27914]
Florian Weimer [Thu, 27 May 2021 13:37:35 +0000 (15:37 +0200)]
nptl: Install SIGSETXID handler with SA_ONSTACK [BZ #27914]

The signal is sent to all threads, some of which may have switched
to very small stacks.  If they have also installed an alternate
signal stack, SA_ONSTACK makes this work.  The Go runtime needs this:

  runtime: C.setuid/C.setgid smashes Go stack
  <https://github.com/golang/go/issues/9400>

Doing this for SIGCANCEL is less obviously beneficial and needs further
testing.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoaarch64: Added optimized memset for A64FX
Naohiro Tamura [Thu, 27 May 2021 07:44:12 +0000 (07:44 +0000)]
aarch64: Added optimized memset for A64FX

This patch optimizes the performance of memset for A64FX [1] which
implements ARMv8-A SVE and has L1 64KB cache per core and L2 8MB cache
per NUMA node.

The performance optimization makes use of Scalable Vector Register
with several techniques such as loop unrolling, memory access
alignment, cache zero fill and prefetch.

SVE assembler code for memset is implemented as Vector Length Agnostic
code so theoretically it can be run on any SOC which supports ARMv8-A
SVE standard.

We confirmed that all testcases have been passed by running 'make
check' and 'make xcheck' not only on A64FX but also on ThunderX2.

And also we confirmed that the SVE 512 bit vector register performance
is roughly 4 times better than Advanced SIMD 128 bit register and 8
times better than scalar 64 bit register by running 'make bench'.

[1] https://github.com/fujitsu/A64FX

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Reviewed-by: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
3 years agoaarch64: Added optimized memcpy and memmove for A64FX
Naohiro Tamura [Thu, 27 May 2021 07:42:35 +0000 (07:42 +0000)]
aarch64: Added optimized memcpy and memmove for A64FX

This patch optimizes the performance of memcpy/memmove for A64FX [1]
which implements ARMv8-A SVE and has L1 64KB cache per core and L2 8MB
cache per NUMA node.

The performance optimization makes use of Scalable Vector Register
with several techniques such as loop unrolling, memory access
alignment, cache zero fill, and software pipelining.

SVE assembler code for memcpy/memmove is implemented as Vector Length
Agnostic code so theoretically it can be run on any SOC which supports
ARMv8-A SVE standard.

We confirmed that all testcases have been passed by running 'make
check' and 'make xcheck' not only on A64FX but also on ThunderX2.

And also we confirmed that the SVE 512 bit vector register performance
is roughly 4 times better than Advanced SIMD 128 bit register and 8
times better than scalar 64 bit register by running 'make bench'.

[1] https://github.com/fujitsu/A64FX

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Reviewed-by: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
3 years agobenchtests: Fixed bench-memcpy-random: buf1: mprotect failed
Naohiro Tamura [Wed, 12 May 2021 09:29:54 +0000 (09:29 +0000)]
benchtests: Fixed bench-memcpy-random: buf1: mprotect failed

This patch fixed mprotect system call failure on AArch64.
This failure happened on not only A64FX but also ThunderX2.

Also this patch updated a JSON key from "max-size" to "length" so that
'plot_strings.py' can process 'bench-memcpy-random.out'

3 years agoaarch64: Added Vector Length Set test helper script
Naohiro Tamura [Thu, 20 May 2021 07:34:37 +0000 (07:34 +0000)]
aarch64: Added Vector Length Set test helper script

This patch is a test helper script to change Vector Length for child
process. This script can be used as test-wrapper for 'make check'.

Usage examples:

~/build$ make check subdirs=string \
test-wrapper='~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 16'

~/build$ ~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 16 \
make test t=string/test-memcpy

~/build$ ~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 32 \
./debugglibc.sh string/test-memmove

~/build$ ~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 64 \
./testrun.sh string/test-memset

3 years agoaarch64: define BTI_C and BTI_J macros as NOP unless HAVE_AARCH64_BTI
Naohiro Tamura [Wed, 12 May 2021 09:27:20 +0000 (09:27 +0000)]
aarch64: define BTI_C and BTI_J macros as NOP unless HAVE_AARCH64_BTI

This patch defines BTI_C and BTI_J macros conditionally for
performance.
If HAVE_AARCH64_BTI is true, BTI_C and BTI_J are defined as HINT
instruction for ARMv8.5 BTI (Branch Target Identification).
If HAVE_AARCH64_BTI is false, both BTI_C and BTI_J are defined as
NOP.

3 years agoconfig: Added HAVE_AARCH64_SVE_ASM for aarch64
Naohiro Tamura [Wed, 12 May 2021 09:26:40 +0000 (09:26 +0000)]
config: Added HAVE_AARCH64_SVE_ASM for aarch64

This patch checks if assembler supports '-march=armv8.2-a+sve' to
generate SVE code or not, and then define HAVE_AARCH64_SVE_ASM macro.

3 years agotst-mallinfo2.c: Use correct multiple for total variable
Yang Xu [Thu, 18 Feb 2021 02:56:33 +0000 (10:56 +0800)]
tst-mallinfo2.c: Use correct multiple for total variable

Since test uses 160 multiple for malloc size, we should also use 160 multiple
for total variable instead of 16, then comparison is meaningful. So fix it.

Also change the ">" to ">=" so that the test is technically valid.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoLinux: Remove remaining references to $(shared-thread-library)
Florian Weimer [Tue, 25 May 2021 09:30:23 +0000 (11:30 +0200)]
Linux: Remove remaining references to $(shared-thread-library)

Since the variable expands to nothing under Linux, it is no longer
necessary to clutter the makefiles with it.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Do not install libpthread.so and do not link tests with it
Florian Weimer [Tue, 25 May 2021 09:30:23 +0000 (11:30 +0200)]
nptl: Do not install libpthread.so and do not link tests with it

Keep installing libpthread.a, so that -lpthread works.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotestrun.sh: Improve --help message
Lucas A. M. Magalhaes [Tue, 25 May 2021 04:44:19 +0000 (10:14 +0530)]
testrun.sh: Improve --help message

The testrun.sh --help message was missing the "container" option.
Besides just adding the missing option I decide to rewrite it in the
same layout as other tools.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agopowerpc: Fix handling of scv return error codes [BZ #27892]
Nicholas Piggin [Thu, 20 May 2021 14:00:36 +0000 (11:00 -0300)]
powerpc: Fix handling of scv return error codes [BZ #27892]

When using scv for templated ASM syscalls, current code interprets any
negative return value as error, but the only valid error codes are in
the range -4095..-1 according to the ABI.

This commit also fixes 'signal.gen.test' strace test, where the issue
was first identified.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
3 years agoProperly check stack alignment [BZ #27901]
H.J. Lu [Sun, 23 May 2021 16:15:52 +0000 (09:15 -0700)]
Properly check stack alignment [BZ #27901]

1. Replace

if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)

which may be optimized out by compiler, with

int
__attribute__ ((weak, noclone, noinline))
is_aligned (void *p, int align)
{
  return (((uintptr_t) p) & (align - 1)) != 0;
}

2. Add TEST_STACK_ALIGN_INIT to TEST_STACK_ALIGN.
3. Add a common TEST_STACK_ALIGN_INIT to check 16-byte stack alignment
for both i386 and x86-64.
4. Update powerpc to use TEST_STACK_ALIGN_INIT.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agox86: Improve memmove-vec-unaligned-erms.S
Noah Goldstein [Sun, 23 May 2021 23:43:24 +0000 (19:43 -0400)]
x86: Improve memmove-vec-unaligned-erms.S

This patch changes the condition for copy 4x VEC so that if length is
exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
8x VEC case.

Results For Skylake memcpy-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
128 , 7   , 7   , 12.587  , 6.808   , New , 54.09

Results For Icelake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
128 , 7   , 7   , 14.546  , 7.642   , New , 52.54

Results For Tigerlake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
128 , 7   , 7   , 13.042  , 6.802   , New , 52.15

Results For Skylake memmove-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
128 , 7   , 0   , 12.049  , 10.182  , New , 84.5

Results For Icelake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
128 , 7   , 0   , 15.565  , 14.436  , New , 92.75

Results For Tigerlake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
128 , 7   , 0   , 15.924  , 14.951  , New , 93.89

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agoBench: Add support for choose direction of memcpy in benchtests
Noah Goldstein [Sun, 23 May 2021 23:36:36 +0000 (19:36 -0400)]
Bench: Add support for choose direction of memcpy in benchtests

This patch adds support for testing memcpy with both dst > src and dst
< src. Since memcpy is implemented as memmove which has seperate
control flows for certain sizes depending on dst > src it seems like
1) information that should be provided in the benchtest output and a
variable that can be controlled for the benchmarks.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agoAdd cast_to_pointer to cast an integer to void * pointer
H.J. Lu [Fri, 21 May 2021 22:58:36 +0000 (15:58 -0700)]
Add cast_to_pointer to cast an integer to void * pointer

3 years agonptl: Remove remaining code from libpthread
Florian Weimer [Fri, 21 May 2021 20:35:01 +0000 (22:35 +0200)]
nptl: Remove remaining code from libpthread

Only the placeholder compatibility symbols are left now.

The __errno_location symbol was removed (moved) using
scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_create, thrd_create into libc
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Move pthread_create, thrd_create into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

The libpthread placeholder symbols need some changes because some
symbol versions have gone away completely.  But
__errno_location@@GLIBC_2.0 still exists, so the GLIBC_2.0 version
is still there.

The internal __pthread_create symbol now points to the correct
function, so the sysdeps/nptl/thrd_create.c override is no longer
necessary.

There was an issue how the hidden alias of pthread_getattr_default_np
was defined, so this commit cleans up that aspects and removes the
GLIBC_PRIVATE export altogether.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Use custom NODELETE DSO for tst-dlopenfail, tst-dlopenfail-2
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
elf: Use custom NODELETE DSO for tst-dlopenfail, tst-dlopenfail-2

Once libpthread is empty and no longer marked NODELETE, it no longer
can be used for testing.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move semi-public __pthread_get_minstack symbol into libc
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Move semi-public __pthread_get_minstack symbol into libc

No abilist updates here because it is a GLIBC_PRIVATE symbol.

It's also necessary to move nptl_version into pthread_create, so
that it still ends up in static binaries.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables

Use the  __nptl_tls_static_size_for_stack inline function instead,
and the GLRO (dl_tls_static_align) value directly.

The computation of GLRO (dl_tls_static_align)  in
_dl_determine_tlsoffset ensures that the alignment is at least
TLS_TCB_ALIGN, which at least STACK_ALIGN (see allocate_stack).
Therefore, the additional rounding-up step is removed.

ALso move the initialization of the default stack size from
__pthread_initialize_minimal_internal to __pthread_early_init.
This introduces an extra system call during single-threaded startup,
but this simplifies the initialization sequence.  No locking is
needed around the writes to __default_pthread_attr because the
process is single-threaded at this point.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Perform signal initialization upon pthread_create
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Perform signal initialization upon pthread_create

Install signal handlers and unblock signals before pthread_create
creates the first thread.

create_thread in sysdeps/unix/sysv/linux/createthread.c can send
SIGCANCEL to the current thread, so the SIGCANCEL handler is currently
needed even if pthread_cancel is never called.  (The way timer_create
uses SIGCANCEL does not need a signal handler; both SIG_DFL and SIG_IGN
dispositions should work.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Remove unused __libc_pthread_init function
Florian Weimer [Fri, 21 May 2021 10:09:07 +0000 (12:09 +0200)]
nptl: Remove unused __libc_pthread_init function

Fixes commit 732139dabeda7ecce0d56200bc176251e759ccde
("Linux: Move __reclaim_stacks into the fork implementation in
libc").

3 years agox86: Improve memset-vec-unaligned-erms.S
Noah Goldstein [Thu, 20 May 2021 17:13:51 +0000 (13:13 -0400)]
x86: Improve memset-vec-unaligned-erms.S

No bug. This commit makes a few small improvements to
memset-vec-unaligned-erms.S. The changes are 1) only aligning to 64
instead of 128. Either alignment will perform equally well in a loop
and 128 just increases the odds of having to do an extra iteration
which can be significant overhead for small values. 2) Align some
targets and the loop. 3) Remove an ALU from the alignment process. 4)
Reorder the last 4x VEC so that they are stored after the loop. 5)
Move the condition for leq 8x VEC to before the alignment
process. test-memset and test-wmemset are both passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoHurd: Define ARCH_MIN_GUARD_SIZE in internal <pthread.h>
Florian Weimer [Thu, 20 May 2021 16:55:26 +0000 (18:55 +0200)]
Hurd: Define ARCH_MIN_GUARD_SIZE in internal <pthread.h>

This macro is always defined on Linux.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoelf: Initialize GLRO (dl_minsigstacksize) after static dlopen
Florian Weimer [Thu, 20 May 2021 16:55:26 +0000 (18:55 +0200)]
elf: Initialize GLRO (dl_minsigstacksize) after static dlopen

This is another field of _rtld_global_ro that benefits from
initialization in __rtld_static_init.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agonptl: Add missing __pthread_cond_wait alias in static builds
Florian Weimer [Wed, 19 May 2021 20:16:26 +0000 (22:16 +0200)]
nptl: Add missing __pthread_cond_wait alias in static builds

Fixes commit cf3fff1c195f859ba949a7ad86d4fca70bd99740 ("nptl: Move
cnd_wait into libc").

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
3 years agoRemove --enable-stackguard-randomization (BZ #27872)
Adhemerval Zanella [Wed, 19 May 2021 13:22:19 +0000 (10:22 -0300)]
Remove --enable-stackguard-randomization (BZ #27872)

Last ENABLE_STACKGUARD_RANDOMIZE usage was removed by 4a103975c4.

3 years agos390x: Check HWCAP bits against compiler flags
Florian Weimer [Wed, 19 May 2021 09:09:57 +0000 (11:09 +0200)]
s390x: Check HWCAP bits against compiler flags

When compiled with GCC 11.1 and -march=z14 -O3 build flags, running
ld.so (or any dynamically linked program) prints:

Fatal glibc error: CPU lacks VXE support (z14 or later required)

Co-Authored-By: Stefan Liebler <stli@linux.ibm.com>
Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
This page took 0.092365 seconds and 5 git commands to generate.