Commit Graph

12189 Commits

Author SHA1 Message Date
Joseph Myers 895ef79e04 Move EXCEPTION_ENABLE_SUPPORTED out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_ENABLE_SUPPORTED macro out to its own
math-tests-trap.h header.

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-trap.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-trap.h>.
	(EXCEPTION_ENABLE_SUPPORTED): Do not define here.
	* sysdeps/aarch64/math-tests.h: Remove file.
	* sysdeps/arm/math-tests.h: Likewise.
	* sysdeps/riscv/math-tests.h: Likewise.
	* sysdeps/aarch64/math-tests-trap.h: New file.
	* sysdeps/arm/math-tests-trap.h: Likewise.
	* sysdeps/riscv/math-tests-trap.h: Likewise.
2018-08-24 19:18:16 +00:00
Wilco Dijkstra ca3aac57ef Remove unused math files
Remove empty files due to the sin/cos improvements: k_sinf.c, k_cosf.c,
k_cos.c, k_sin.c.  After the tanf change s_rem_pio2f.c and k_rem_pio2f.c
(and the ia64, m68k and powerpc equivalents) are no longer used,
so remove them.  All e_rem_pio2.c files were already empty or commented
out, so remove them too.  Passes build-many-glibcs.

	* math/Makefile: Remove empty files k_sin(f).c, k_cos(f).c.
	Remove unused files e_rem_pio2(f).c, k_rem_pio2f.c.
	* sysdeps/i386/fpu/e_rem_pio2.c: Delete file.
	* sysdeps/ia64/fpu/e_rem_pio2.c: Likewise.
	* sysdeps/ia64/fpu/e_rem_pio2f.c: Likewise.
	* sysdeps/ia64/fpu/k_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_rem_pio2.c: Likewise.
	* sysdeps/ieee754/dbl-64/k_cos.c: Likewise.
	* sysdeps/ieee754/dbl-64/k_sin.c: Likewise.
	* sysdeps/ieee754/flt-32/e_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/flt-32/k_cosf.c: Likewise.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/flt-32/k_sinf.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/e_rem_pio2.c: Likewise
	* sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c: Likewise
	* sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c: Likewise
	* sysdeps/powerpc/fpu/e_rem_pio2f.c: Likewise.
	* sysdeps/powerpc/fpu/k_rem_pio2f.c: Likewise.
2018-08-24 15:34:54 +01:00
Joseph Myers 60bcac09c0 Move EXCEPTION_TESTS_* out of math-tests.h
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_TESTS_* macros for individual types out to their
own sysdeps header.

As with ROUNDING_TESTS_*, there is no need to define these macros if
FE_ALL_EXCEPT == 0 and the individual exception macros are undefined;
thus, math-tests-exceptions.h headers are only needed for soft-float
ARM and RISC-V, while the other cases that defined these macros do not
need to do so (and the associated math-tests.h headers are thus
removed without needing replacement by math-tests-exceptions.h
headers).

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-exceptions.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-exceptions.h>.
	(EXCEPTION_TESTS_float): Do not define here.
	(EXCEPTION_TESTS_double): Likewise.
	(EXCEPTION_TESTS_long_double): Likewise.
	(EXCEPTION_TESTS_float128): Likewise.
	* sysdeps/arm/math-tests.h [__SOFTFP__] (EXCEPTION_TESTS_float):
	Likewise.
	[__SOFTFP__] (EXCEPTION_TESTS_double): Likewise.
	[__SOFTFP__] (EXCEPTION_TESTS_long_double): Likewise.
	* sysdeps/arm/nofpu/math-tests-exceptions.h: New file.
	* sysdeps/m68k/coldfire/math-tests.h: Remove file.
	* sysdeps/mips/math-tests.h: Likewise.
	* sysdeps/nios2/math-tests.h: Likewise.
	* sysdeps/riscv/math-tests.h [!__riscv_flen]
	(EXCEPTION_TESTS_float): Do not define here.
	[!__riscv_flen] (EXCEPTION_TESTS_double): Likewise.
	[!__riscv_flen] (EXCEPTION_TESTS_long_double): Likewise.
	* sysdeps/riscv/nofpu/math-tests-exceptions.h: New file.
2018-08-23 23:41:13 +00:00
Wilco Dijkstra 900fb446eb Speedup tanf range reduction
Speedup tanf range reduction by using the new sincosf range
reduction algorithm.  Overall code quality is improved due to
inlining, so there is a speedup even if no range reduction is
required.

tanf throughput gains on Cortex-A72:
* |x| < M_PI_4  : 1.1x
* |x| < M_PI_2  : 1.2x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.6x
* |x| < Inf     : 12.1x

	* sysdeps/ieee754/flt-32/s_tanf.c (__tanf): Use fast range reduction.
2018-08-23 12:38:16 +01:00
Joseph Myers 16a25138c1 Move ROUNDING_TESTS_* out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the ROUNDING_TESTS_* macros for individual types out to their
own sysdeps header.

In the soft-float case where FE_TONEAREST is the only rounding mode
macro defined, there is no need to define ROUNDING_TESTS_*; it is only
necessary when rounding modes macros are defined that may not be
supported at runtime.  Thus, the ROUNDING_TESTS_* definitions for some
configurations are just removed, not moved to new
math-tests-rounding.h headers; the only architectures needing
math-tests-rounding.h are those where the macros are defined in
bits/fenv.h because of the possibility of a soft-float compilation
using a hard-float glibc with the same ABI (i.e., ARM and RISC-V).

The test-*-vlen*.h headers, by using #undef, do not yet follow
typo-proof conventions (but they no longer implicitly rely on being
included before math-tests.h, and this area can always be cleaned up
further in future).

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-rounding.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Do not define here.
	(ROUNDING_TESTS_double): Likewise.
	(ROUNDING_TESTS_long_double): Likewise.
	(ROUNDING_TESTS_float128): Likewise.
	* math/test-double-vlen2.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Undefine before defining.
	* math/test-double-vlen4.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Undefine before defining.
	* math/test-double-vlen8.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Undefine before defining.
	* math/test-float-vlen16.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Undefine before defining.
	* math/test-float-vlen4.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Undefine before defining.
	* math/test-float-vlen8.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Undefine before defining.
	* sysdeps/arm/nofpu/math-tests-rounding.h: New file.
	* sysdeps/arm/math-tests.h [__SOFTFP__] (ROUNDING_TESTS_float): Do
	not define here.
	[__SOFTFP__] (ROUNDING_TESTS_double): Likewise.
	[__SOFTFP__] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/riscv/nofpu/math-tests-rounding.h: New file.
	* sysdeps/riscv/math-tests.h [!__riscv_flen]
	(ROUNDING_TESTS_float): Do not define here.
	[!__riscv_flen] (ROUNDING_TESTS_double): Likewise.
	[!__risv_flen] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/m68k/coldfire/math-tests.h [!__mcffpu__]
	(ROUNDING_TESTS_float): Likewise.
	[!__mcffpu__] (ROUNDING_TESTS_double): Likewise.
	[!__mcffpu__] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/mips/math-tests.h [__mips_soft_float]
	(ROUNDING_TESTS_float): Likewise.
	[__mips_soft_float] (ROUNDING_TESTS_double): Likewise.
	[__mips_soft_float] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/nios2/math-tests.h (ROUNDING_TESTS_float): Likewise.
	(ROUNDING_TESTS_double): Likewise.
	(ROUNDING_TESTS_long_double): Likewise.
2018-08-22 12:25:50 +00:00
Tobias Klauser 38b0593e9a Add PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.
This patch adds the PF_XDP, AF_XDP and SOL_XDP macros from Linux 4.18 to
sysdeps/unix/sysv/linux/bits/socket.h.

	* sysdeps/unix/sysv/linux/bits/socket.h (PF_MAX): Set to 45.
	(PF_XDP): New macro.
	(AF_XDP): New macro.
	(SOL_XDP): New macro.
2018-08-21 17:22:53 +00:00
Joseph Myers 5cd7dbdea1 Update netinet/tcp.h from Linux 4.18.
This patch adds constants from netinet/tcp.h in Linux 4.18, and an
associated struct tcp_zerocopy_receive, to sysdeps/gnu/netinet/tcp.h.
The new TCP_REPAIR_* constants seemed sufficiently related to those
already present to include them.

Note that this patch does not include additions to struct tcp_info;
there are many other elements in this structure in the Linux kernel
that are not included in the glibc version (which was last extended in
2007, it seems).  Such additions to the end of the structure may be OK
with the expected way it is used (size passed explicitly to the kernel
with getsockopt), but in principle any change to the size of a type
provided by glibc is an ABI change for external applications /
libraries using that type in their ABIs, and has the associated risks
of such a change.

Tested for x86_64.

	* sysdeps/gnu/netinet/tcp.h (TCP_ZEROCOPY_RECEIVE): New macro.
	(TCP_INQ): Likewise.
	(TCP_CM_INQ): Likewise.
	(TCP_REPAIR_ON): Likewise.
	(TCP_REPAIR_OFF): Likewise.
	(TCP_REPAIR_OFF_NO_WP): Likewise.
	(struct tcp_zerocopy_receive): New type.
2018-08-21 15:57:22 +00:00
Florian Weimer aa42b3dbcb Avoid running some tests if the file system does not support holes
Otherwise, these tests fills up the entire disk (or just run very
slowly and eventually time out).
2018-08-21 12:56:53 +02:00
Florian Weimer ef939d928a __readlink_chk: Remove micro-optimization 2018-08-21 11:24:12 +02:00
Florian Weimer 88ffb39dc6 __readlink_chk: Assume HAVE_INLINED_SYSCALLS
HAVE_INLINED_SYSCALLS is always defined on Linux.
Switch to INLINE_SYSCALL_CALL as well.
2018-08-20 18:24:09 +02:00
Joseph Myers e6edd40d61 Update struct signalfd_siginfo from Linux 4.18.
This patch updates struct signalfd_siginfo in sys/signalfd.h with new
members from Linux 4.18 (plus ssi_addr_lsb, added to the kernel in
2.6.37 without being added to sys/signalfd.h at that time).  The
__pad2 member name follows the kernel and the existing __pad name.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/sys/signalfd.h (struct
	signalfd_siginfo): Add ssi_addr_lsb, ssi_syscall, ssi_call_addr
	and ssi_arch members.
2018-08-20 15:48:16 +00:00
Rajalakshmi Srinivasaraghavan fa78896b1f powerpc: Remove powerpc specific sinf and cosf optimization
New generic optimization of sinf and cosf introduced by commit
599cf39766 shows improvement
compared to powerpc specific assembly version.  Hence removing
the powerpc assembly versions to make use of generic code.
2018-08-20 08:47:43 +05:30
Florian Weimer 86a6c75a29 math: Regenerate s390 ulps
Based on results on a s390x 2964 machine, with -march=z196 and
-mtune=zEC12, and separately with -march=z13 and -mtune=z14.
2018-08-17 16:39:13 +02:00
Rajalakshmi Srinivasaraghavan 7793ad7a2c powerpc: Rearrange little endian specific files
This patch moves little endian specific POWER9 optimization files to
sysdeps/powerpc/powerpc64/le and creates POWER9 ifunc functions
only for little endian.
2018-08-16 12:12:02 +05:30
Siddhesh Poyarekar 436e4d5b96 [aarch64] Add an ASIMD variant of strlen for falkor
This variant of strlen uses vector loads and operations to reduce the
size of the code and also eliminate the non-ascii fallback.  This
works very well for falkor because of its two vector units and
efficient vector ops.  In the best case it reduces latency of cases in
bench-strlen by 48%, with gains throughout the benchmark.
strlen-walk also sees uniform gains in the 5%-15% range.

Overall the routine appears to work better than the stock one for falkor
regardless of the benchmark, length of string or cache state.

The same cannot be said of a53 and a72 though.  a53 performance was
greatly reduced and for a72 it was a bit of a mixed bag, slightly on the
negative side but I reckon it might be fast in some situations.

	* sysdeps/aarch64/strlen.S (__strlen): Rename to STRLEN.
	[!STRLEN](STRLEN): Set to __strlen.
	* sysdeps/aarch64/multiarch/strlen.c: New file.
	* sysdeps/aarch64/multiarch/strlen_generic.S: Likewise.
	* sysdeps/aarch64/multiarch/strlen_asimd.S: Likewise.
	* sysdeps/aarch64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add strlen.
	* sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add
	strlen_generic and strlen_asimd.

Reviewed-By: szabolcs.nagy@arm.com
CC: pinskia@gmail.com
2018-08-15 23:01:33 +05:30
Wilco Dijkstra 126c4e3f80 Use generic sinf/cosf in lgammaf_r
The internal functions __kernel_sinf and __kernel_cosf are used only by
lgammaf_r.  Removing the internal functions and using the generic sinf
and cosf is better overall.  Benchmarking on Cortex-A72 shows the generic
sinf and cosf are 1.4x and 2.3x faster in the range |x| < PI/4, and 0.66x
and 1.1x for |x| < PI/2, so it should make lgammaf_r faster on average.

GLIBC regression tests pass on AArch64.

	* sysdeps/ieee754/flt-32/e_lgammaf_r.c (sin_pif): Use __sinf/__cosf.
	* sysdeps/ieee754/flt-32/k_cosf.c (__kernel_cosf): Remove all code.
	* sysdeps/ieee754/flt-32/k_sinf.c (__kernel_sinf): Likewise.
2018-08-15 16:01:21 +01:00
Wilco Dijkstra 49acec179c Fix spaces in x86_64 ULP file
Fix a few missing spaces, it's now identical to the regenerated version.

Passes GLIBC tests on x64.

	* sysdeps/x86_64/fpu/libm-test-ulps: Regenerate to fix spaces.
2018-08-15 12:56:22 +01:00
Wilco Dijkstra 599cf39766 Improve performance of sinf and cosf
The second patch improves performance of sinf and cosf using the same
algorithms and polynomials.  The returned values are identical to sincosf
for the same input.  ULP definitions for AArch64 and x64 are updated.

sinf/cosf througput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.2x
* |x| < M_PI_4  : 1.8x
* |x| < 2 * M_PI: 1.7x
* |x| < 120.0   : 2.3x
* |x| < Inf     : 3.0x

	* NEWS: Mention sinf, cosf, sincosf.
	* sysdeps/aarch64/libm-test-ulps: Update ULP for sinf, cosf, sincosf.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sinf and cosf.
	* sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c: Add definitions of
	constants rather than including generic sincosf.h.
	* sysdeps/x86_64/fpu/s_sincosf_data.c: Remove.
	* sysdeps/ieee754/flt-32/s_cosf.c (cosf): Rewrite.
	* sysdeps/ieee754/flt-32/s_sincosf.h (reduced_sin): Remove.
	(reduced_cos): Remove.
	(sinf_poly): New function.
	* sysdeps/ieee754/flt-32/s_sinf.c (sinf): Rewrite.
2018-08-14 10:45:59 +01:00
Joseph Myers 17b26500f9 Update syscall-names.list for Linux 4.18.
This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.18.  The io_pgetevents and rseq syscalls are added to the
kernel on various architectures, so need to be mentioned in this file.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
	version to 4.18.
	(io_pgetevents): New syscall.
	(rseq): Likewise.
2018-08-13 21:35:27 +00:00
Joseph Myers 2ce7ba7d15 Move SNAN_TESTS_* out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the SNAN_TESTS_* macros for individual types out to their own
sysdeps header (while the type-generic SNAN_TESTS wrapper for those
macros remains in math-tests.h).

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

	* sysdeps/generic/math-tests-snan.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-snan.h>.
	(SNAN_TESTS_float): Do not define here.
	(SNAN_TESTS_double): Likewise.
	(SNAN_TESTS_long_double): Likewise.
	(SNAN_TESTS_float128): Likewise.
	* sysdeps/i386/fpu/math-tests-snan.h: New file.
	* sysdeps/i386/fpu/math-tests.h: Remove file.
	* sysdeps/ia64/math-tests-snan.h: New file.
	* sysdeps/ia64/math-tests.h: Remove file.
	* sysdeps/x86/math-tests.h: Likewise.
	* sysdeps/x86_64/fpu/math-tests-snan.h: New file.
2018-08-10 19:22:01 +00:00
Wilco Dijkstra ea5c662c62 Improve performance of sincosf
This patch is a complete rewrite of sincosf.  The new version is
significantly faster, as well as simple and accurate.
The worst-case ULP is 0.5607, maximum relative error is 0.5303 * 2^-23 over
all 4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases.

The small range reducer uses a single reduction step to handle values up to
120.0.  It is fastest on targets which support inlined round instructions.

The large range reducer uses integer arithmetic for simplicity.  It does a
32x96 bit multiply to compute a 64-bit modulo result.  This is more than
accurate enough to handle the worst-case cancellation for values close to
an integer multiple of PI/4.  It could be further optimized, however it is
already much faster than necessary.

sincosf throughput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.6x
* |x| < M_PI_4  : 1.7x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.8x
* |x| < Inf     : 2.3x

	* math/Makefile: Add s_sincosf_data.c.
	* sysdeps/ia64/fpu/s_sincosf_data.c: New file.
	* sysdeps/ieee754/flt-32/s_sincosf.h (abstop12): Add new function.
	(sincosf_poly): Likewise.
	(reduce_small): Likewise.
	(reduce_large): Likewise.
	* sysdeps/ieee754/flt-32/s_sincosf.c (sincosf): Rewrite.
	* sysdeps/ieee754/flt-32/s_sincosf_data.c: New file with sincosf data.
	* sysdeps/m68k/m680x0/fpu/s_sincosf_data.c: New file.
	* sysdeps/x86_64/fpu/s_sincosf_data.c: New file.
2018-08-10 17:34:39 +01:00
Szabolcs Nagy 43cfdf8f48 Clean up converttoint handling and document the semantics
This patch currently only affects aarch64.

The roundtoint and converttoint internal functions are only called with small
values, so 32 bit result is enough for converttoint and it is a signed int
conversion so the return type is changed to int32_t.

The original idea was to help the compiler keeping the result in uint64_t,
then it's clear that no sign extension is needed and there is no accidental
undefined or implementation defined signed int arithmetics.

But it turns out gcc does a good job with inlining so changing the type has
no overhead and the semantics of the conversion is less surprising this way.
Since we want to allow the asuint64 (x + 0x1.8p52) style conversion, the top
bits were never usable and the existing code ensures that only the bottom
32 bits of the conversion result are used.

On aarch64 the neon intrinsics (which round ties to even) are changed to
round and lround (which round ties away from zero) this does not affect the
results in a significant way, but more portable (relies on round and lround
being inlined which works with -fno-math-errno).

The TOINT_SHIFT and TOINT_RINT macros were removed, only keep separate code
paths for TOINT_INTRINSICS and !TOINT_INTRINSICS.

	* sysdeps/aarch64/fpu/math_private.h (roundtoint): Use round.
	(converttoint): Use lround.
	* sysdeps/ieee754/flt-32/math_config.h (roundtoint): Declare and
	document the semantics when TOINT_INTRINSICS is set.
	(converttoint): Likewise.
	(TOINT_RINT): Remove.
	(TOINT_SHIFT): Remove.
	* sysdeps/ieee754/flt-32/e_expf.c (__expf): Remove the TOINT_RINT code
	path.
2018-08-10 17:23:16 +01:00
Florian Weimer 690652882b Linux: Rewrite __old_getdents64 [BZ #23497]
Commit 298d0e3129 ("Consolidate Linux
getdents{64} implementation") broke the implementation because it does
not take into account struct offset differences.

The new implementation is close to the old one, before the
consolidation, but has been cleaned up slightly.
2018-08-10 10:20:13 +02:00
Ilya Leoshkevich 8f135efcad S390: Fix unwind in 32-bit _mcount
* Fix CFI offset for %r14.
* Fix unwound value of %r15 being off by 128 bytes.

ChangeLog:

	* sysdeps/s390/s390-32/s390-mcount.S (_mcount):
	Fix unwind.
2018-08-10 09:07:44 +02:00
Ilya Leoshkevich 71c01af52f S390: Implement 64-bit __fentry__
* Since __fentry__ is almost the same as _mcount, reuse the code by
  #including it twice with different #defines around.
* Remove LA usages - they are needed in 31-bit mode to clear the top
  bit, but in 64-bit they appear to do nothing.
* Add CFI rule for the nonstandard return register. This rule applies
  to the current function (binutils generates a new CIE - see
  gas/dw2gencfi.c:select_cie_for_fde()), so it is not necessary to put
  __fentry__ into a new file.
* Fix CFI offset for %r14.
* Add CFI rule for %r0.
* Fix unwound value of %r15 being off by 244 bytes.
* Unwinding in __fentry__@plt does not work, no plan to fix it - it
  would require asking linker to generate CFI for return address in
  %r0.  From functional perspective keeping it broken is fine, since
  the callee did not have a chance to do anything yet.  From
  convenience perspective it would be possible to enhance GDB in the
  future to treat __fentry__@plt in a special way.
* Fix whitespace.
* Fix offsets in comments, which were copied from 32-bit code.
* 32-bit version will not be implemented, since it's not compatible
  with the corresponding PLT stubs: they assume %r12 points to GOT,
  which is not the case for gcc-emitted __fentry__ stub, which runs
  before the prolog.

This patch adds the runtime support in glibc for the -mfentry
gcc feature introduced in [1] and [2].

[1] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00784.html
[2] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00912.html

ChangeLog:

	* sysdeps/s390/s390-64/Versions (__fentry__): Add.
	* sysdeps/s390/s390-64/s390x-mcount.S: Move the common
	code to s390x-mcount.h and #include it.
	* sysdeps/s390/s390-64/s390x-mcount.h: New file.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
	(__fentry__): Add.
2018-08-10 09:07:44 +02:00
Ilya Leoshkevich 8d997d2253 Move __fentry__ version definition to sysdeps/{i386,x86_64}
__fentry__ symbol is currently not defined for other architectures.
Attempts to introduce it cause abicheck to fail, because it will be
available since 2.29 earliest, and not 2.13, which is the case for
Intel.  With the new code, abicheck passes for i686-linux-gnu,
x86_64-linux-gnu and x86_64-linux-gnu32 triples.

ChangeLog:

	* stdlib/Versions: Remove __fentry__.
	* sysdeps/i386/Versions: Add __fentry__.
	* sysdeps/x86_64/Versions: Add __fentry__.
2018-08-10 09:07:44 +02:00
Ilya Leoshkevich 69e2444ab1 S390: Test that lazy binding does not clobber R0
The following combinations need to be tested:
* 32- (g5, esa and zarch) and 64-bit
  * linux32 glibc/configure CC='gcc -m31 -march=g5'
  * linux32 glibc/configure CC='gcc -m31'
  * linux32 glibc/configure CC='gcc -m31 -mzarch'
* With and without VX:
  * glibc/configure libc_cv_asm_s390_vx=no
* With and without profiling (using LD_PROFILE)
* With and without pltexit (using LD_AUDIT)

ChangeLog:

	* sysdeps/s390/Makefile: Register the new tests.
	* sysdeps/s390/tst-dl-runtime-mod.S: New file.
	* sysdeps/s390/tst-dl-runtime-profile-audit.c: New file.
	* sysdeps/s390/tst-dl-runtime-profile-noaudit.c: New file.
	* sysdeps/s390/tst-dl-runtime-resolve-audit.c: New file.
	* sysdeps/s390/tst-dl-runtime-resolve-noaudit.c: New file.
	* sysdeps/s390/tst-dl-runtime.c: New file.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich bde6320f39 S390: Do not clobber R0 in 64-bit _dl_runtime_profile
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
	Do not clobber R0.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich 5755f5e4cc S390: Do not clobber R0 in 64-bit _dl_runtime_resolve
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
	Do not clobber R0.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich c8ad85225b S390: Do not clobber R0 in 32-bit _dl_runtime_profile
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
	Do not clobber R0.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich b215eee1e1 S390: Do not clobber R0 in 32-bit _dl_runtime_resolve
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
	Do not clobber R0.
2018-08-10 09:07:42 +02:00
Ilya Leoshkevich 329c6fec8b S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_profile
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:42 +02:00
Ilya Leoshkevich 0fb7afa2f9 S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:42 +02:00
Ilya Leoshkevich 6954059ad6 S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_profile
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:41 +02:00
Ilya Leoshkevich c7099673aa S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_resolve
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:41 +02:00
Joseph Myers 2813e41e90 Replace gen-libm-test.pl with gen-libm-test.py.
Following the recent discussion of using Python instead of Perl and
Awk for glibc build / test, this patch replaces gen-libm-test.pl with
a new gen-libm-test.py script.  This script should work with all
Python versions supported by glibc (tested by hand with Python 2.7,
tested in the build system with Python 3.5; configure prefers Python 3
if available).

This script is designed to give identical output to gen-libm-test.pl
for ease of verification of the change, except for generated comments
referring to .py instead of .pl.  (That is, identical for actual
inputs passed to the script, not necessarily for all possible input;
for example, this version more precisely follows the C standard syntax
for floating-point constants when deciding when to add LIT macro
calls.)  In one place a comment notes that the generation of
NON_FINITE flags is replicating a bug in the Perl script to assist in
such comparisons (with the expectation that this bug can then be
separately fixed in the Python script later).

Tested for x86_64, including comparison of generated files (and hand
testing of the case of generating a sorted libm-test-ulps file, which
isn't covered by normal "make check").

I'd expect to follow this up by extending the new script to produce
the ulps tables for the manual as well (replacing
manual/libm-err-tab.pl, so that then we just have one ulps file
parser) - at which point the manual build would depend on both Perl
and Python (eliminating the Perl dependency would require someone to
rewrite summary.pl in Python, and that would only eliminate the
*direct* Perl dependency; current makeinfo is written in Perl so there
would still be an indirect dependency).

I think install.texi is more or less equally out-of-date regarding
Perl and Python uses before and after this patch, so I don't think
this patch depends on my patch
<https://sourceware.org/ml/libc-alpha/2018-08/msg00133.html> to update
install.texi regarding such uses (pending review).

	* math/gen-libm-test.py: New file.
	* math/gen-libm-test.pl: Remove.
	* math/Makefile [$(PERL) != no]: Change condition to [PYTHON].
	($(objpfx)libm-test-ulps.h): Use gen-libm-test.py instead of
	gen-libm-test.pl.
	($(libm-test-c-noauto-obj)): Likewise.
	($(libm-test-c-auto-obj)): Likewise.
	($(libm-test-c-narrow-obj)): Likewise.
	(regen-ulps): Likewise.
	* math/README.libm-test: Update references to gen-libm-test.pl.
	* math/libm-test-driver.c (struct test_fj_f_data): Update comment
	referencing gen-libm-test.pl.
	* math/libm-test-nexttoward.inc (nexttoward_test_data): Likewise.
	* math/libm-test-support.c: Likewise.
	* math/libm-test-support.h: Likewise.
	* sysdeps/generic/libm-test-ulps: Likewise.
2018-08-09 15:34:12 +00:00
Samuel Thibault 8ac0f9e6f7 hurd: Avoid PLTs for __pthread_get/setspecific
* sysdeps/htl/pthreadP.h [IS_IN (libpthread)] (__pthread_getspecific,
__pthread_setspecific): Add hidden proto.
* sysdeps/htl/pt-getspecific.c (__pthread_getspecific): Add hidden def.
* sysdeps/htl/pt-setspecific.c (__pthread_setspecific): Add hidden def.
2018-08-09 01:28:55 +02:00
Siddhesh Poyarekar be64b1946b [aarch64] Fix value of MIN_PAGE_SIZE for testing
MIN_PAGE_SIZE is normally set to 4096 but for testing it can be set to
16 so that it exercises the page crossing code for every misaligned
access.  The value was set to 15, which is obviously wrong, so fixed
as obvious and tested.

	* sysdeps/aarch64/strlen.S [TEST_PAGE_CROSS](MIN_PAGE_SIZE):
	Fix value.
2018-08-08 22:47:17 +05:30
Andreas Schwab 92a4cba760
RISC-V: Don't use ps_get_thread_area in libthread_db (bug 23402)
Since RISC-V stores the thread pointer in a general register libthread_db
can just ask the debugger for the register contents instead of trying to
call ps_get_thread_area.  This enables thread debugging in gdb.

	* sysdeps/riscv/nptl/tls.h (DB_THREAD_SELF): Use REGISTER instead
	of CONST_THREAD_AREA.
2018-08-06 12:51:59 -07:00
H.J. Lu fb4c32aef6 x86: Move STATE_SAVE_OFFSET/STATE_SAVE_MASK to sysdep.h
Move STATE_SAVE_OFFSET and STATE_SAVE_MASK to sysdep.h to make
sysdeps/x86/cpu-features.h a C header file.

	* sysdeps/x86/cpu-features.h (STATE_SAVE_OFFSET): Removed.
	(STATE_SAVE_MASK): Likewise.
	Don't check __ASSEMBLER__ to include <cpu-features-offsets.h>.
	* sysdeps/x86/sysdep.h (STATE_SAVE_OFFSET): New.
	(STATE_SAVE_MASK): Likewise.
	* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features-offsets.h>
	instead of <cpu-features.h>.
2018-08-06 06:25:43 -07:00
DJ Delorie bb17621ab8 Regen RISC-V rvd ULPs
* sysdeps/riscv/rv64/rvd/libm-test-ulps: Update.

Note: I regen'd these from scratch, but I'm only committing the
increases, as I only tested on hardware.  There were a few 2->1
decreases that I omitted, possibly "for now".
2018-08-03 13:52:01 -04:00
DJ Delorie bf41818787 RISC-V: Fix rounding save/restore bug.
* sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv):
Fix rounding save-restore bug.

Fixes about a hundred off-by-ULP failures in the math testsuite.
2018-08-03 13:43:31 -04:00
H.J. Lu 430388d5dc x86: Don't include <init-arch.h> in assembly codes
There is no need to include <init-arch.h> in assembly codes since all
x86 IFUNC selector functions are written in C.  Tested on i686 and
x86-64.  There is no code change in libc.so, ld.so and libmvec.so.

	* sysdeps/i386/i686/multiarch/bzero-ia32.S: Don't include
	<init-arch.h>.
	* sysdeps/x86_64/fpu/multiarch/svml_d_sin8_core-avx2.S: Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_expf16_core-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Likewise.
2018-08-03 08:05:00 -07:00
H.J. Lu ae67f2e562 x86: Cleanup cpu-features-offsets.sym
Remove the unused macros.  There is no code changes in libc.so nor
ld.so on i686 and x86-64.

	* sysdeps/x86/cpu-features-offsets.sym
	(rtld_global_ro_offsetof): Removed.
	(CPU_FEATURES_SIZE): Likewise.
	(CPUID_OFFSET): Likewise.
	(CPUID_SIZE): Likewise.
	(CPUID_EAX_OFFSET): Likewise.
	(CPUID_EBX_OFFSET): Likewise.
	(CPUID_ECX_OFFSET): Likewise.
	(CPUID_EDX_OFFSET): Likewise.
	(FAMILY_OFFSET): Likewise.
	(MODEL_OFFSET): Likewise.
	(FEATURE_OFFSET): Likewise.
	(FEATURE_SIZ): Likewise.
	(COMMON_CPUID_INDEX_1): Likewise.
	(COMMON_CPUID_INDEX_7): Likewise.
	(FEATURE_INDEX_1): Likewise.
	(RTLD_GLOBAL_RO_DL_X86_CPU_FEATURES_OFFSET): Updated.
2018-08-03 06:42:09 -07:00
Siddhesh Poyarekar dce452dc52 Rename the glibc.tune namespace to glibc.cpu
The glibc.tune namespace is vaguely named since it is a 'tunable', so
give it a more specific name that describes what it refers to.  Rename
the tunable namespace to 'cpu' to more accurately reflect what it
encompasses.  Also rename glibc.tune.cpu to glibc.cpu.name since
glibc.cpu.cpu is weird.

	* NEWS: Mention the change.
	* elf/dl-tunables.list: Rename tune namespace to cpu.
	* sysdeps/powerpc/dl-tunables.list: Likewise.
	* sysdeps/x86/dl-tunables.list: Likewise.
	* sysdeps/aarch64/dl-tunables.list: Rename tune.cpu to
	cpu.name.
	* elf/dl-hwcaps.c (_dl_important_hwcaps): Adjust.
	* elf/dl-hwcaps.h (GET_HWCAP_MASK): Likewise.
	* manual/README.tunables: Likewise.
	* manual/tunables.texi: Likewise.
	* sysdeps/powerpc/cpu-features.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c
	(init_cpu_features): Likewise.
	* sysdeps/x86/cpu-features.c: Likewise.
	* sysdeps/x86/cpu-features.h: Likewise.
	* sysdeps/x86/cpu-tunables.c: Likewise.
	* sysdeps/x86_64/Makefile: Likewise.
	* sysdeps/x86/dl-cet.c: Likewise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-08-02 23:49:19 +05:30
Joseph Myers 506d7fb1d4 Do not define various fenv.h macros for MIPS soft-float (bug 23479).
MIPS soft-float glibc does not support floating-point exceptions and
rounding modes, and uses a different ABI from hard-float so a
soft-float compilation cannot use a glibc that does support
floating-point exceptions and rounding modes.  Thus, bits/fenv.h
should not, when compiling for soft-float, define macros for the
unsupported features.

This patch changes it accordingly to define those macros only for
hard-float.  None of the exception macros are defined for soft-float,
with FE_ALL_EXCEPT defined to 0 in that case, and only FE_TONEAREST is
defined of the rounding-mode macros, and FE_NOMASK_ENV is not defined;
this is consistent with how architectures lacking exception and
rounding mode support generally define things in this header.  As well
as making the header more correct for this case, this also means the
generic math_private.h optimizations for this case automatically apply
(inlining libm-internal fenv.h function calls that are trivial when
exceptions and rounding modes are not supported).

The mips64 sfp-machine.h then needs similar changes to disable more of
the exception and rounding mode handling for soft-float.  (The mips32
sfp-machine.h is already used only for soft-float, has no integration
with hardware exceptions or rounding modes and so needs no changes.)

Existing binaries might use the old FE_NOMASK_ENV value as an argument
to fesetenv / feupdateenv and expect an error for it (given that it
was defined in a header that also defined FE_ALL_EXCEPT to a nonzero
value).  To preserve that error, wrappers for the fallback fesetenv
and feupdateenv are created in sysdeps/mips/nofpu/.

Tested for mips64 (hard-float and soft-float, all three ABIs).

	[BZ #23479]
	* sysdeps/mips/bits/fenv.h (FE_INEXACT): Define only if
	[__mips_hard_float].
	(FE_UNDERFLOW): Likewise.
	(FE_OVERFLOW): Likewise.
	(FE_DIVBYZERO): Likewise.
	(FE_INVALID): Likewise.
	(FE_ALL_EXCEPT): Define to 0 if [!__mips_hard_float].
	(FE_TOWARDZERO): Define only if [__mips_hard_float].
	(FE_UPWARD): Likewise.
	(FE_DOWNWARD): Likewise.
	(__FE_UNDEFINED): Define if [!__mips_hard_float]
	(FE_NOMASK_ENV): Define only if [__mips_hard_float].
	* sysdeps/mips/mips64/sfp-machine.h (_FP_DECL_EX): Define only if
	[__mips_hard_float].
	(FP_ROUNDMODE): Likewise.
	(FP_RND_NEAREST): Likewise.
	(FP_RND_ZERO): Likewise.
	(FP_RND_PINF): Likewise.
	(FP_RND_MINF): Likewise.
	(FP_EX_INVALID): Likewise.
	(FP_EX_OVERFLOW): Likewise.
	(FP_EX_UNDERFLOW): Likewise.
	(FP_EX_DIVZERO): Likewise.
	(FP_EX_INEXACT): Likewise.
	(FP_INIT_ROUNDMODE): Likewise.
	* sysdeps/mips/nofpu/fesetenv.c: New file.
	* sysdeps/mips/nofpu/feupdateenv.c: Likewise.
2018-08-02 15:53:29 +00:00
H.J. Lu 82c80ac2eb x86: Rename get_common_indeces to get_common_indices
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86/cpu-features.c (get_common_indeces): Renamed to
	...
	(get_common_indices): This.
	(init_cpu_features): Updated.
2018-08-01 04:57:50 -07:00
Joseph Myers 46f8cf5712 Move SNAN_TESTS_PRESERVE_PAYLOAD out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves SNAN_TESTS_PRESERVE_PAYLOAD out to its own sysdeps header.

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-snan-payload.h: New file.
	* sysdeps/hppa/math-tests-snan-payload.h: Likewise.
	* sysdeps/mips/math-tests-snan-payload.h: Likewise.
	* sysdeps/riscv/math-tests-snan-payload.h: Likewise.
	* sysdeps/generic/math-tests.h: Include
	<math-tests-snan-payload.h>.
	(SNAN_TESTS_PRESERVE_PAYLOAD): Do not define macro here.
	* sysdeps/hppa/math-tests.h: Remove file.
	* sysdeps/mips/math-tests.h [!__mips_nan2008]
	(SNAN_TESTS_PRESERVE_PAYLOAD): Do not define macro here.
	* sysdeps/riscv/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD):
	Likewise.
2018-08-01 11:21:16 +00:00
Joseph Myers c0e7e2c127 Move SNAN_TESTS_TYPE_CAST out of math-tests.h.
The math-tests.h header has many different macros and groups of
macros, defined using #ifndef in the generic version which is included
by architecture versions with #include_next after possibly defining
non-default versions of some of those macros.

This use of #ifndef is contrary to our normal typo-proof conventions
for macro definitions.  This patch moves one of the macros,
SNAN_TESTS_TYPE_CAST, out to its own sysdeps header, to follow those
typo-proof conventions more closely.

Tested with build-many-glibcs.py.

2018-08-01  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/generic/math-tests-snan-cast.h: New file.
	* sysdeps/powerpc/math-tests-snan-cast.h: Likewise.
	* sysdeps/generic/math-tests.h: Include <math-tests-snan-cast.h>.
	(SNAN_TESTS_TYPE_CAST): Do not define macro here.
	* sysdeps/powerpc/math-tests.h (SNAN_TESTS_TYPE_CAST): Likewise.
2018-08-01 11:18:57 +00:00
Samuel Thibault 42fc12ef73 hurd: Fix exec usage of mach_setup_thread
Exec needs that mach_setup_thread does *not* set up TLS since it works on
another task, so we have to split this into mach_setup_tls.

	* mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes.
	* mach/setup-thread.c (__mach_setup_thread): Move TLS setup to...
	(__mach_setup_tls): ... new function.
	(mach_setup_tls): New alias.
	* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after
	__mach_setup_thread.
	* sysdeps/mach/hurd/profil.c (update_waiter): Likewise.
	* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise.
	* mach/Versions [libc] (mach_setup_tls): Add symbol.
	* sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
2018-08-01 00:10:03 +02:00
Samuel Thibault f195ea0e2f hurd: Fix startup of static binaries linked against libpthread
* sysdeps/mach/hurd/i386/init-first.c (init1): Move ELF hdr and TLS
initialization...
(init): ... before initializing libpthread.
2018-07-31 22:41:20 +02:00
Adhemerval Zanella 63d5fad404 Update SH libm-tests-ulps
* sysdeps/sh/libm-test-ulps: Update.
2018-07-31 10:33:53 -03:00
H.J. Lu 98864ed0e0 x86/CET: Fix property note parser [BZ #23467]
GNU_PROPERTY_X86_FEATURE_1_AND may not be the first property item.  We
need to check each property item until we reach the end of the property
or find GNU_PROPERTY_X86_FEATURE_1_AND.

This patch adds 2 tests.  The first test checks if IBT is enabled and
the second test reads the output from the first test to check if IBT
is is enabled.  The second second test fails if IBT isn't enabled
properly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23467]
	* sysdeps/unix/sysv/linux/x86/Makefile (tests): Add
	tst-cet-property-1 and tst-cet-property-2 if CET is enabled.
	(CFLAGS-tst-cet-property-1.o): New.
	(ASFLAGS-tst-cet-property-dep-2.o): Likewise.
	($(objpfx)tst-cet-property-2): Likewise.
	($(objpfx)tst-cet-property-2.out): Likewise.
	* sysdeps/unix/sysv/linux/x86/tst-cet-property-1.c: New file.
	* sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/tst-cet-property-dep-2.S: Likewise.
	* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Parse
	each property item until GNU_PROPERTY_X86_FEATURE_1_AND is found.
2018-07-30 16:15:38 -07:00
H.J. Lu c92a00d865 x86: Add tst-get-cpu-features-static to $(tests) [BZ #23458]
All tests should be added to $(tests).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23458]
	* sysdeps/x86/Makefile (tests): Add tst-get-cpu-features-static.
2018-07-30 16:11:19 -07:00
Samuel Thibault af86087f02 hurd: Fix some ld.so symbol override from libc
ld.so symbols to be overriden by libc need to be extern to really get
overriden.

	* sysdeps/mach/hurd/not-errno.h: New file.
	* sysdeps/mach/hurd/i386/localplt.data: Update accordingly.
2018-07-28 15:12:42 +02:00
Samuel Thibault 99bc624136 hurd: Fix some ld.so symbol override from libc
ld.so symbols to be overriden by libc need to be extern to really get
overriden.

	* sysdeps/mach/hurd/dl-unistd.h (__access, __brk, __lseek, __read,
	__sbrk): Do not set attribute_hidden.
	* sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.
	* sysdeps/mach/hurd/i386/localplt.data: Update accordingly.
2018-07-28 14:57:10 +02:00
H.J. Lu 4591b7db23 x86/CET: Don't parse beyond the note end
Simply check if "ptr < ptr_end" since "ptr" is always incremented by 8.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Don't
	parse beyond the note end.
2018-07-27 13:23:31 -07:00
Adhemerval Zanella 2c6da2f487 Fix Linux fcntl OFD locks on unsupported kernels
This patch make the OFD tests return unsupported if kernel does not
support OFD locks (it was added on 3.15).

Checked on a ia64-linux-gnu with Linux 3.14.

	* sysdeps/unix/sysv/linux/tst-ofdlocks.c: Return unsupported if
	kernel does not support OFD locks.
	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
2018-07-27 14:48:06 -03:00
Samuel Thibault 20365a315b hurd: Fix some ld.so symbol override from libc
ld.so symbols to be overriden by libc need to be extern to really get
overriden.

More fixes are needed to avoid the hidden attribute.

	* sysdeps/mach/hurd/Versions (libc): Make __access and
	__access_noerrno external so they can override the ld symbols.
	(ld): Make __access, __read, __sbrk, __strtoul_internal, __write,
	__writev, __open64, __access_noerrno extern so they can be overrided.
	* sysdeps/mach/hurd/i386/libc.abilist: Update accordingly.
	* sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.
2018-07-27 11:18:29 +02:00
Joseph Myers 74759ae5b6 Update powerpc-nofpu ulps.
* sysdeps/powerpc/nofpu/libm-test-ulps: Update.
2018-07-26 22:51:06 +00:00
H.J. Lu be525a69a6 x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23459]
	* sysdeps/x86/cpu-features.c (get_extended_indices): New
	function.
	(init_cpu_features): Call get_extended_indices for both Intel
	and AMD CPUs.
	* sysdeps/x86/cpu-features.h (COMMON_CPUID_INDEX_80000001):
	Remove "for AMD" comment.
2018-07-26 13:31:11 -07:00
H.J. Lu 65d87ade1e x86: Correct index_cpu_LZCNT [BZ # 23456]
cpu-features.h has

 #define bit_cpu_LZCNT		(1 << 5)
 #define index_cpu_LZCNT	COMMON_CPUID_INDEX_1
 #define reg_LZCNT

But the LZCNT feature bit is in COMMON_CPUID_INDEX_80000001:

Initial EAX Value: 80000001H
ECX Extended Processor Signature and Feature Bits:
Bit 05: LZCNT available

index_cpu_LZCNT should be COMMON_CPUID_INDEX_80000001, not
COMMON_CPUID_INDEX_1.  The VMX feature bit is in COMMON_CPUID_INDEX_1:

Initial EAX Value: 01H
Feature Information Returned in the ECX Register:
5 VMX

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ # 23456]
	* sysdeps/x86/cpu-features.h (index_cpu_LZCNT): Set to
	COMMON_CPUID_INDEX_80000001.
2018-07-26 11:10:44 -07:00
H.J. Lu 3fb455b318 ia64: Work around incorrect type of IA64 uc_sigmask
Work around:

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

	* sysdeps/unix/sysv/linux/ia64/tst-setcontext4.c: New file.
2018-07-25 13:55:26 -07:00
Adhemerval Zanella d6499b7039 Fix ISO C threads installed header and HURD assumption
Set installed NPTL header as the expected one (instead of an
internal one for glibc testsuite) and add a hurd specific
stdc-predef with __STDC_NO_THREADS__.

Checked on both i686-linux-gnu and i686-gnu that both threads.h
and stdc-predef.h are the expected ones.

	* nptl/threads.h: Move to ...
	* sysdeps/nptl/threads.h: ... here.
	* sysdeps/hurd/stdc-predef.h: New file.
2018-07-25 17:27:45 -03:00
H.J. Lu 08ac6bed14 x86/CET: Add a setcontext test for CET
Verify that setcontext works with gaps above and below the newly
allocated shadow stack.

	* sysdeps/unix/sysv/linux/x86/Makefile (tests): Add
	tst-cet-setcontext-1 if CET is enabled.
	(CFLAGS-tst-cet-setcontext-1.c): Add -mshstk.
	* sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c: New file.
2018-07-25 08:40:50 -07:00
Adhemerval Zanella 9faaf93850 Fix C11 conformance issues
Remove conformace assumption of NPTL implementation for ISO C threads
and revert wrong libcrypt addition on linknamespace-libs-XPG4.

The i686-gnu target now shows two new conformance failures:

FAIL: conform/ISO11/threads.h/conform
FAIL: conform/ISO11/threads.h/linknamespace

It is expected due missing HTL ISO C threads support and both conformance
.out files indicates the reason ("#error "HTL does not implement ISO C
threads").

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

	* include/threads.h: Move to ...
	* sysdeps/nptl/threads.h: ... here.
	* sysdeps/htl/threads.h: New file.
	* conform/Makefile (linknamespace-libs-ISO11): Use
	static-thread-library instead of linking libpthread.
	(linknamespace-libs-XPG4): Revert wrong libcrypt.a addition.
2018-07-25 12:02:32 -03:00
H.J. Lu 25123a1c5c x86-64/CET: Extend ucontext_t to save shadow stack
This patch adds a field to ucontext_t to save shadow stack:

1. getcontext and swapcontext are updated to save the caller's shadow
stack pointer and return addresses.
2. setcontext and swapcontext are updated to restore shadow stack and
jump to new context directly.
3. makecontext is updated to allocate a new shadow stack and set the
caller's return address to __start_context.

Since makecontext allocates a new shadow stack when making a new
context and kernel allocates a new shadow stack for clone/fork/vfork
syscalls, we track the current shadow stack base.  In setcontext and
swapcontext, if the target shadow stack base is the same as the current
shadow stack base, we unwind the shadow stack.  Otherwise it is a stack
switch and we look for a restore token.

We enable shadow stack at run-time only if program and all used shared
objects, including dlopened ones, are shadow stack enabled, which means
that they must be compiled with GCC 8 or above and glibc 2.28 or above.
We need to save and restore shadow stack only if shadow stack is enabled.
When caller of getcontext, setcontext, swapcontext and makecontext is
compiled with smaller ucontext_t, shadow stack won't be enabled at
run-time.  We check if shadow stack is enabled before accessing the
extended field in ucontext_t.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h (ucontext_t): Add
	__ssp.
	* sysdeps/unix/sysv/linux/x86_64/__start_context.S: Include
	<asm/prctl.h> and "ucontext_i.h" when shadow stack is enabled.
	(__push___start_context): New.
	* sysdeps/unix/sysv/linux/x86_64/getcontext.S: Include
	<asm/prctl.h>.
	(__getcontext): Record the current shadow stack base.  Save the
	caller's shadow stack pointer and base.
	* sysdeps/unix/sysv/linux/x86_64/makecontext.c: Include
	<pthread.h>, <libc-pointer-arith.h> and <sys/prctl.h>.
	(__push___start_context): New prototype.
	(__makecontext): Call __push___start_context to allocate a new
	shadow stack, push __start_context onto the new stack as well
	as the new shadow stack.
	* sysdeps/unix/sysv/linux/x86_64/setcontext.S: Include
	<asm/prctl.h>.
	(__setcontext): Restore the target shadow stack.
	* sysdeps/unix/sysv/linux/x86_64/swapcontext.S: Include
	<asm/prctl.h>.
	(__swapcontext): Record the current shadow stack base.  Save
	the caller's shadow stack pointer and base.  Restore the target
	shadow stack.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT): New.
	* sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym (oSSP): New.
2018-07-25 06:37:31 -07:00
H.J. Lu fddcd00377 x86/CET: Add tests with legacy non-CET shared objects
Check binary compatibility of CET-enabled executables:

1. When CET-enabled executable is used with legacy non-CET shared object
at run-time, ld.so should disable SHSTK and put legacy non-CET shared
objects in legacy bitmap.
2. When IBT-enabled executable dlopens legacy non-CET shared object,
ld.so should put legacy shared object in legacy bitmap.
3. Use GLIBC_TUNABLES=glibc.tune.x86_shstk=[on|off|permissive] to
control how SHSTK is enabled.

	* sysdeps/x86/Makefile (tests): Add tst-cet-legacy-1,
	tst-cet-legacy-2, tst-cet-legacy-2a, tst-cet-legacy-3,
	tst-cet-legacy-4, tst-cet-legacy-4a, tst-cet-legacy-4b
	and tst-cet-legacy-4c.
	(modules-names): Add tst-cet-legacy-mod-1, tst-cet-legacy-mod-2
	and tst-cet-legacy-mod-4.
	(CFLAGS-tst-cet-legacy-2.c): New.
	(CFLAGS-tst-cet-legacy-mod-1.c): Likewise.
	(CFLAGS-tst-cet-legacy-mod-2.c): Likewise.
	(CFLAGS-tst-cet-legacy-3.c): Likewise.
	(CFLAGS-tst-cet-legacy-4.c): Likewise.
	(CFLAGS-tst-cet-legacy-mod-4.c): Likewise.
	($(objpfx)tst-cet-legacy-1): Likewise.
	($(objpfx)tst-cet-legacy-2): Likewise.
	($(objpfx)tst-cet-legacy-2.out): Likewise.
	($(objpfx)tst-cet-legacy-2a): Likewise.
	($(objpfx)tst-cet-legacy-2a.out): Likewise.
	($(objpfx)tst-cet-legacy-4): Likewise.
	($(objpfx)tst-cet-legacy-4.out): Likewise.
	($(objpfx)tst-cet-legacy-4a): Likewise.
	($(objpfx)tst-cet-legacy-4a.out): Likewise.
	(tst-cet-legacy-4a-ENV): Likewise.
	($(objpfx)tst-cet-legacy-4b): Likewise.
	($(objpfx)tst-cet-legacy-4b.out): Likewise.
	(tst-cet-legacy-4b-ENV): Likewise.
	($(objpfx)tst-cet-legacy-4c): Likewise.
	($(objpfx)tst-cet-legacy-4c.out): Likewise.
	(tst-cet-legacy-4c-ENV): Likewise.
	* sysdeps/x86/tst-cet-legacy-1.c: New file.
	* sysdeps/x86/tst-cet-legacy-2.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-2a.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-3.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4a.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4b.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4c.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-mod-1.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-mod-2.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-mod-4.c: Likewise.
2018-07-25 04:47:05 -07:00
H.J. Lu 9aa3113a42 x86: Rename __glibc_reserved2 to ssp_base in tcbhead_t
This will be used to record the current shadow stack base for shadow
stack switching by getcontext, makecontext, setcontext and swapcontext.
If the target shadow stack base is the same as the current shadow stack
base, we unwind the shadow stack.  Otherwise it is a stack switch and
we look for a restore token to restore the target shadow stack.

	* sysdeps/i386/nptl/tcb-offsets.sym (SSP_BASE_OFFSET): New.
	* sysdeps/i386/nptl/tls.h (tcbhead_t): Replace __glibc_reserved2
	with ssp_base.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (SSP_BASE_OFFSET): New.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Replace __glibc_reserved2
	with ssp_base.
2018-07-25 04:39:39 -07:00
Florian Weimer e0f9c462d8 alpha: mlock2, copy_file_range syscalls were introduced in kernel 4.13 2018-07-24 22:38:39 +02:00
H.J. Lu 394df3815e x86/CET: Extend arch_prctl syscall for CET control
CET arch_prctl bits should be defined in <asm/prctl.h> from Linux kernel
header files.  Add x86 <include/asm/prctl.h> for pre-CET kernel header
files.

Note: sysdeps/unix/sysv/linux/x86/include/asm/prctl.h should be removed
if <asm/prctl.h> from the required kernel header files contains CET
arch_prctl bits.

 /* CET features:
    IBT:   GNU_PROPERTY_X86_FEATURE_1_IBT
    SHSTK: GNU_PROPERTY_X86_FEATURE_1_SHSTK
  */

 /* Return CET features in unsigned long long *addr:
      features: addr[0].
      shadow stack base address: addr[1].
      shadow stack size: addr[2].
  */
 # define ARCH_CET_STATUS		0x3001
 /* Disable CET features in unsigned int features.  */
 # define ARCH_CET_DISABLE		0x3002
 /* Lock all CET features.  */
 # define ARCH_CET_LOCK			0x3003
 /* Allocate a new shadow stack with unsigned long long *addr:
      IN: requested shadow stack size: *addr.
      OUT: allocated shadow stack address: *addr.
  */
 # define ARCH_CET_ALLOC_SHSTK		0x3004
 /* Return legacy region bitmap info in unsigned long long *addr:
     address: addr[0].
     size: addr[1].
  */
 # define ARCH_CET_LEGACY_BITMAP	0x3005

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/x86/include/asm/prctl.h: New file.
	* sysdeps/unix/sysv/linux/x86/cpu-features.c: Include
	<sys/prctl.h> and <asm/prctl.h>.
	(get_cet_status): Call arch_prctl with ARCH_CET_STATUS.
	* sysdeps/unix/sysv/linux/x86/dl-cet.h: Include <sys/prctl.h>
	and <asm/prctl.h>.
	(dl_cet_allocate_legacy_bitmap): Call arch_prctl with
	ARCH_CET_LEGACY_BITMAP.
	(dl_cet_disable_cet): Call arch_prctl with ARCH_CET_DISABLE.
	(dl_cet_lock_cet): Call arch_prctl with ARCH_CET_LOCK.
	* sysdeps/x86/libc-start.c: Include <startup.h>.
2018-07-24 12:23:17 -07:00
Florian Weimer 465455306f sh: Do not define __ASSUME_STATX 2018-07-24 21:05:07 +02:00
Adhemerval Zanella c6dd669bed nptl: Add abilist symbols for C11 threads
This patch adds the required abilist symbols for C11 thread support.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
	(thrd_current, thrd_equal, thrd_sleep, thrd_yield): Add C11 thread
	symbols.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist [[GLIBC_2.28]
	(call_once, cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
	cnd_timedwait, cnd_wait, mtx_destroy, mtx_init, mtx_lock,
	mtx_timedlock, mtx_trylock, mtx_unlokc, thrd_create, thrd_detach,
	thrd_exit, thrd_join, tss_create, tss_delete, tss_get, tss_set):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
	ikewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
2018-07-24 14:07:18 -03:00
Adhemerval Zanella ce7528f637 nptl: Add C11 threads thrd_* functions
This patch adds the thrd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically thrd_create, thrd_curent, rhd_detach, thrd_equal,
thrd_exit, thrd_join, thrd_sleep, thrd_yield, and required types.

Mostly of the definitions are composed based on POSIX conterparts, such as
thrd_t (using pthread_t).  For thrd_* function internally direct
POSIX pthread call are used with the exceptions:

  1. thrd_start uses pthread_create internal implementation, but changes
     how to actually calls the start routine.  This is due the difference
     in signature between POSIX and C11, where former return a 'void *'
     and latter 'int'.
     To avoid calling convention issues due 'void *' to int cast, routines
     from C11 threads are started slight different than default pthread one.
     Explicit cast to expected return are used internally on pthread_create
     and the result is stored back to void also with an explicit cast.

  2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
     errno and to handle expected standard return codes.  It is a
     cancellation entrypoint to be consistent with both thrd_join and
     cnd_{timed}wait.

  3. thrd_yield also uses internal direct syscall to avoid errno clobbering.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/Makefile (conformtest-headers-ISO11): Add threads.h.
	(linknamespace-libs-ISO11): Add libpthread.a.
	* conform/data/threads.h-data: New file: add C11 thrd_* types and
	functions.
	* include/stdc-predef.h (__STDC_NO_THREADS__): Remove definition.
	* nptl/Makefile (headers): Add threads.h.
	(libpthread-routines): Add new C11 thread thrd_create, thrd_current,
	thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, and
	thrd_yield.
	* nptl/Versions (libpthread) [GLIBC_2.28]): Add new C11 thread
	thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit,
	thrd_join, thrd_sleep, and thrd_yield symbols.
	* nptl/descr.h (struct pthread): Add c11 field.
	* nptl/pthreadP.h (ATTR_C11_THREAD): New define.
	* nptl/pthread_create.c (START_THREAD_DEFN): Call C11 thread start
	routine with expected function prototype.
	(__pthread_create_2_1): Add C11 threads check based on attribute
	value.
	* sysdeps/unix/sysdep.h (INTERNAL_SYSCALL_CANCEL): New macro.
	* nptl/thrd_create.c: New file.
	* nptl/thrd_current.c: Likewise.
	* nptl/thrd_detach.c: Likewise.
	* nptl/thrd_equal.c: Likewise.
	* nptl/thrd_exit.c: Likewise.
	* nptl/thrd_join.c: Likewise.
	* nptl/thrd_priv.h: Likewise.
	* nptl/thrd_sleep.c: Likewise.
	* nptl/thrd_yield.c: Likewise.
	* include/threads.h: Likewise.
2018-07-24 14:06:45 -03:00
H.J. Lu e27f41ba2b Add <bits/indirect-return.h>
Add <bits/indirect-return.h> and include it in <ucontext.h>.
__INDIRECT_RETURN defined in <bits/indirect-return.h> indicates if
swapcontext requires special compiler treatment.  The default
__INDIRECT_RETURN is empty.

On x86, when shadow stack is enabled, __INDIRECT_RETURN is defined
with indirect_return attribute, which has been added to GCC 9, to
indicate that swapcontext returns via indirect branch.  Otherwise
__INDIRECT_RETURN is defined with returns_twice attribute.

When shadow stack is enabled, remove always_inline attribute from
prepare_test_buffer in string/tst-xbzero-opt.c to avoid:

tst-xbzero-opt.c: In function ‘prepare_test_buffer’:
tst-xbzero-opt.c:105:1: error: function ‘prepare_test_buffer’ can never be inlined because it uses setjmp
 prepare_test_buffer (unsigned char *buf)

when indirect_return attribute isn't available.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* bits/indirect-return.h: New file.
	* misc/sys/cdefs.h (__glibc_has_attribute): New.
	* sysdeps/x86/bits/indirect-return.h: Likewise.
	* stdlib/Makefile (headers): Add bits/indirect-return.h.
	* stdlib/ucontext.h: Include <bits/indirect-return.h>.
	(swapcontext): Add __INDIRECT_RETURN.
	* string/tst-xbzero-opt.c (ALWAYS_INLINE): New.
	(prepare_test_buffer): Use it.
2018-07-24 07:55:47 -07:00
H.J. Lu 3650e1d928 x86: Update vfork to pop shadow stack
The shadow stack prevents us from pushing the saved return PC onto
the stack and returning normally.  Instead we pop the shadow stack
and return directly.  This is the safest way to return and ensures
any stack manipulations done by the vfork'd child doesn't cause the
parent to terminate when CET is enabled.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/i386/vfork.S (SYSCALL_ERROR_HANDLER):
	Redefine if shadow stack is enabled.
	(SYSCALL_ERROR_LABEL): Likewise.
	(__vfork): Pop shadow stack and jump back to to caller directly
	when shadow stack is in use.
	* sysdeps/unix/sysv/linux/x86_64/vfork.S (SYSCALL_ERROR_HANDLER):
	Redefine if shadow stack is enabled.
	(SYSCALL_ERROR_LABEL): Likewise.
	(__vfork): Pop shadow stack and jump back to to caller directly
	when shadow stack is in use.
2018-07-24 05:21:07 -07:00
H.J. Lu ca027e0f62 x86-64: Add endbr64 to tst-quadmod[12].S
Add endbr64 to tst-quadmod1.S and tst-quadmod2.S so that func and foo
can be called indirectly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86_64/tst-quadmod1.S (func): Add endbr64 if IBT is
	enabled.
	(foo): Likewise.
	* sysdeps/x86_64/tst-quadmod2.S (func) : Likewise.
	(foo): Likewise.
2018-07-24 05:12:14 -07:00
Samuel Thibault 2d5c41ded9 check-execstack: Permit sysdeps to xfail some libs
* scripts/check-execstack.awk: Consider `xfail' variable containing a
	list
	of libraries whose stack executability is expected.
	* elf/Makefile ($(objpfx)check-execstack.out): Pass
	$(check-execstack-xfail) to check-execstack.awk through `xfail'
	variable.
	* sysdeps/mach/hurd/i386/Makefile (check-execstack-xfail): Set to ld.so
	libc.so libpthread.so.
2018-07-20 03:28:14 +02:00
Samuel Thibault 8ba1520e8c hurd: Fix installed-headers tests
* sysdeps/mach/include/mach-shortcuts-hidden.h [!_ISOMAC]: Do not
	declare libc hidden prototypes.
	* sysdeps/mach/include/mach/mach_traps.h [!_ISOMAC]: Likewise.
2018-07-20 03:28:08 +02:00
Samuel Thibault 38547460b7 Fix new file header 2018-07-20 01:44:58 +02:00
Thomas Schwinge de195be015 hurd: Implement pipe2
* sysdeps/mach/hurd/pipe2.c: New file, copy from pipe.c.  Evolve it to
	implement __pipe2.
	* sysdeps/mach/hurd/pipe.c (__pipe): Reimplement using __pipe2.
2018-07-20 01:29:55 +02:00
Thomas Schwinge 75d5e4a09e hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socketpair
* sysdeps/mach/hurd/socketpair.c (__socketpair): Handle SOCK_CLOEXEC
	and SOCK_NONBLOCK.
2018-07-20 01:24:41 +02:00
Thomas Schwinge 6008824221 hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socket
* sysdeps/mach/hurd/socket.c (__socket): Handle SOCK_CLOEXEC and
	SOCK_NONBLOCK.
2018-07-20 01:22:12 +02:00
Samuel Thibault 46f2474e93 hurd: Enable thread-safe i386 atomic instructions
* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Set multiple_threads
	to 1.
2018-07-20 01:12:08 +02:00
H.J. Lu e2d40a8822 x86-64: Use _CET_NOTRACK in memcmp-sse4.S
* sysdeps/x86_64/multiarch/memcmp-sse4.S (BRANCH_TO_JMPTBL_ENTRY):
	Add _CET_NOTRACK before indirect jump to jump table.
2018-07-18 08:07:32 -07:00
H.J. Lu 77a8ae0948 i386: Use _CET_NOTRACK in memset-sse2-rep.S
* sysdeps/i386/i686/multiarch/memset-sse2-rep.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:04:12 -07:00
H.J. Lu 90d15dc577 i386: Use _CET_NOTRACK in strcat-sse2.S
* sysdeps/i386/i686/multiarch/strcat-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:03:15 -07:00
H.J. Lu f1574581c7 i386: Use _CET_NOTRACK in strcpy-sse2.S
* sysdeps/i386/i686/multiarch/strcpy-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:02:26 -07:00
H.J. Lu 7fb613361c i386: Use _CET_NOTRACK in memcpy-ssse3.S
* sysdeps/i386/i686/multiarch/memcpy-ssse3.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:01:06 -07:00
H.J. Lu 0a899af097 i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
* sysdeps/i386/i686/multiarch/memcpy-ssse3-rep.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(BRANCH_TO_JMPTBL_ENTRY_TAIL): Likewise.
2018-07-18 08:00:09 -07:00
H.J. Lu 177824e232 i386: Use _CET_NOTRACK in memcmp-sse4.S
* sysdeps/i386/i686/multiarch/memcmp-sse4.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 07:59:04 -07:00
H.J. Lu 00e7b76a8f i386: Use _CET_NOTRACK in memset-sse2.S
* sysdeps/i386/i686/multiarch/memset-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 07:57:59 -07:00
H.J. Lu 7e119cd582 i386: Use _CET_NOTRACK in i686/memcmp.S
* sysdeps/i386/i686/memcmp.S (memcmp): Add _CET_NOTRACK before
	indirect jump to jump table.
2018-07-18 07:56:58 -07:00
H.J. Lu 03aaf49b68 x86-64: Use _CET_NOTRACK in memcpy-ssse3.S
* sysdeps/x86_64/multiarch/memcpy-ssse3.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(MEMCPY): Likewise.
2018-07-18 06:39:46 -07:00
H.J. Lu 811e9e52b2 x86-64: Use _CET_NOTRACK in memcpy-ssse3-back.S
* sysdeps/x86_64/multiarch/memcpy-ssse3-back.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(MEMCPY): Likewise.
2018-07-18 06:38:23 -07:00
H.J. Lu 8817df4265 x86-64: Use _CET_NOTRACK in strcmp-sse42.S
* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
	_CET_NOTRACK before indirect jump to jump table.
2018-07-18 06:37:09 -07:00
H.J. Lu 921595d151 x86-64: Use _CET_NOTRACK in strcpy-sse2-unaligned.S
* sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 06:33:06 -07:00
H.J. Lu 4ef60d9597 x86_64: Use _CET_NOTRACK in strcmp.S
* sysdeps/x86_64/strcmp.S (STRCMP): Add _CET_NOTRACK before
	indirect jump to jump table.
2018-07-18 06:31:53 -07:00
H.J. Lu be9ccd27c0 i386: Add _CET_ENDBR to indirect jump targets in add_n.S/sub_n.S
i386 add_n.S and sub_n.S use a trick to implment jump tables with LEA.
We can't use conditional branches nor normal jump tables since jump
table entries use EFLAGS set by jump table index.  This patch adds
_CET_ENDBR to indirect jump targets and adjust destination for
_CET_ENDBR.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/add_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
	* sysdeps/i386/i686/add_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
	* sysdeps/i386/sub_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_sub_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
2018-07-17 16:11:44 -07:00
H.J. Lu 5efc6777ad x86-64: Add _CET_ENDBR to STRCMP_SSE42
Add _CET_ENDBR to STRCMP_SSE42, which is called indirectly, to support
IBT.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
	_CET_ENDBR.
2018-07-17 16:08:47 -07:00
H.J. Lu 562837c002 x86: Add _CET_ENDBR to functions in dl-tlsdesc.S
Add _CET_ENDBR to functions in dl-tlsdesc.S, which are called indirectly,
to support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_return): Add
	_CET_ENDBR.
	(_dl_tlsdesc_undefweak): Likewise.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_resolve_abs_plus_addend): Likewise.
	(_dl_tlsdesc_resolve_rel): Likewise.
	(_dl_tlsdesc_resolve_rela): Likewise.
	(_dl_tlsdesc_resolve_hold): Likewise.
	* sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_return): Likewise.
	(_dl_tlsdesc_undefweak): Likewise.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_resolve_rela): Likewise.
	(_dl_tlsdesc_resolve_hold): Likewise.
2018-07-17 16:07:17 -07:00
H.J. Lu 124bcde683 x86: Add _CET_ENDBR to functions in crti.S
Add _CET_ENDBR to functions in crti.S, which are called indirectly, to
support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
	(_fini): Likewise.
	* sysdeps/x86_64/crti.S (_init): Likewise.
	(_fini): Likewise.
2018-07-17 16:05:18 -07:00
H.J. Lu ba2ea23d05 x86: Always include <dl-cet.h>/cet-tunables.h> for --enable-cet
Always include <dl-cet.h> and cet-tunables.h> when CET is enabled.
Otherwise, configure glibc with --enable-cet --disable-tunables will
fail to build.

	* sysdeps/x86/cpu-features.c: Always include <dl-cet.h> and
	cet-tunables.h> when CET is enabled.
2018-07-17 04:16:35 -07:00
H.J. Lu f753fa7dea x86: Support IBT and SHSTK in Intel CET [BZ #21598]
Intel Control-flow Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-en
forcement-technology-preview.pdf

includes Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK).

GNU_PROPERTY_X86_FEATURE_1_IBT is added to GNU program property to
indicate that all executable sections are compatible with IBT when
ENDBR instruction starts each valid target where an indirect branch
instruction can land.  Linker sets GNU_PROPERTY_X86_FEATURE_1_IBT on
output only if it is set on all relocatable inputs.

On an IBT capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable IBT and
lock IBT if GNU_PROPERTY_X86_FEATURE_1_IBT is set on the executable.
2. When loading an executable with an interpreter, enable IBT if
GNU_PROPERTY_X86_FEATURE_1_IBT is set on the interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_IBT isn't set on the executable,
     disable IBT.
  b. Lock IBT.
3. If IBT is enabled, when loading a shared object without
GNU_PROPERTY_X86_FEATURE_1_IBT:
  a. If legacy interwork is allowed, then mark all pages in executable
     PT_LOAD segments in legacy code page bitmap.  Failure of legacy code
     page bitmap allocation causes an error.
  b. If legacy interwork isn't allowed, it causes an error.

GNU_PROPERTY_X86_FEATURE_1_SHSTK is added to GNU program property to
indicate that all executable sections are compatible with SHSTK where
return address popped from shadow stack always matches return address
popped from normal stack.  Linker sets GNU_PROPERTY_X86_FEATURE_1_SHSTK
on output only if it is set on all relocatable inputs.

On a SHSTK capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on the executable.
2. When loading an executable with an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_SHSTK isn't set on the executable
     or any shared objects loaded via the DT_NEEDED tag, disable SHSTK.
  b. Otherwise lock SHSTK.
3. After SHSTK is enabled, it is an error to load a shared object
without GNU_PROPERTY_X86_FEATURE_1_SHSTK.

To enable CET support in glibc, --enable-cet is required to configure
glibc.  When CET is enabled, both compiler and assembler must support
CET.  Otherwise, it is a configure-time error.

To support CET run-time control,

1. _dl_x86_feature_1 is added to the writable ld.so namespace to indicate
if IBT or SHSTK are enabled at run-time.  It should be initialized by
init_cpu_features.
2. For dynamic executables:
   a. A l_cet field is added to struct link_map to indicate if IBT or
      SHSTK is enabled in an ELF module.  _dl_process_pt_note or
      _rtld_process_pt_note is called to process PT_NOTE segment for
      GNU program property and set l_cet.
   b. _dl_open_check is added to check IBT and SHSTK compatibilty when
      dlopening a shared object.
3. Replace i386 _dl_runtime_resolve and _dl_runtime_profile with
_dl_runtime_resolve_shstk and _dl_runtime_profile_shstk, respectively if
SHSTK is enabled.

CET run-time control can be changed via GLIBC_TUNABLES with

$ export GLIBC_TUNABLES=glibc.tune.x86_shstk=[permissive|on|off]
$ export GLIBC_TUNABLES=glibc.tune.x86_ibt=[permissive|on|off]

1. permissive: SHSTK is disabled when dlopening a legacy ELF module.
2. on: IBT or SHSTK are always enabled, regardless if there are IBT or
SHSTK bits in GNU program property.
3. off: IBT or SHSTK are always disabled, regardless if there are IBT or
SHSTK bits in GNU program property.

<cet.h> from CET-enabled GCC is automatically included by assembly codes
to add GNU_PROPERTY_X86_FEATURE_1_IBT and GNU_PROPERTY_X86_FEATURE_1_SHSTK
to GNU program property.  _CET_ENDBR is added at the entrance of all
assembly functions whose address may be taken.  _CET_NOTRACK is used to
insert NOTRACK prefix with indirect jump table to support IBT.  It is
defined as notrack when _CET_NOTRACK is defined in <cet.h>.

	 [BZ #21598]
	* configure.ac: Add --enable-cet.
	* configure: Regenerated.
	* elf/Makefille (all-built-dso): Add a comment.
	* elf/dl-load.c (filebuf): Moved before "dynamic-link.h".
	Include <dl-prop.h>.
	(_dl_map_object_from_fd): Call _dl_process_pt_note on PT_NOTE
	segment.
	* elf/dl-open.c: Include <dl-prop.h>.
	(dl_open_worker): Call _dl_open_check.
	* elf/rtld.c: Include <dl-prop.h>.
	(dl_main): Call _rtld_process_pt_note on PT_NOTE segment.  Call
	_rtld_main_check.
	* sysdeps/generic/dl-prop.h: New file.
	* sysdeps/i386/dl-cet.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/cpu-features.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/dl-cet.h: Likewise.
	* sysdeps/x86/cet-tunables.h: Likewise.
	* sysdeps/x86/check-cet.awk: Likewise.
	* sysdeps/x86/configure: Likewise.
	* sysdeps/x86/configure.ac: Likewise.
	* sysdeps/x86/dl-cet.c: Likewise.
	* sysdeps/x86/dl-procruntime.c: Likewise.
	* sysdeps/x86/dl-prop.h: Likewise.
	* sysdeps/x86/libc-start.h: Likewise.
	* sysdeps/x86/link_map.h: Likewise.
	* sysdeps/i386/dl-trampoline.S (_dl_runtime_resolve): Add
	_CET_ENDBR.
	(_dl_runtime_profile): Likewise.
	(_dl_runtime_resolve_shstk): New.
	(_dl_runtime_profile_shstk): Likewise.
	* sysdeps/linux/x86/Makefile (sysdep-dl-routines): Add dl-cet
	if CET is enabled.
	(CFLAGS-.o): Add -fcf-protection if CET is enabled.
	(CFLAGS-.os): Likewise.
	(CFLAGS-.op): Likewise.
	(CFLAGS-.oS): Likewise.
	(asm-CPPFLAGS): Add -fcf-protection -include cet.h if CET
	is enabled.
	(tests-special): Add $(objpfx)check-cet.out.
	(cet-built-dso): New.
	(+$(cet-built-dso:=.note)): Likewise.
	(common-generated): Add $(cet-built-dso:$(common-objpfx)%=%.note).
	($(objpfx)check-cet.out): New.
	(generated): Add check-cet.out.
	* sysdeps/x86/cpu-features.c: Include <dl-cet.h> and
	<cet-tunables.h>.
	(TUNABLE_CALLBACK (set_x86_ibt)): New prototype.
	(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
	(init_cpu_features): Call get_cet_status to check CET status
	and update dl_x86_feature_1 with CET status.  Call
	TUNABLE_CALLBACK (set_x86_ibt) and TUNABLE_CALLBACK
	(set_x86_shstk).  Disable and lock CET in libc.a.
	* sysdeps/x86/cpu-tunables.c: Include <cet-tunables.h>.
	(TUNABLE_CALLBACK (set_x86_ibt)): New function.
	(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
	* sysdeps/x86/sysdep.h (_CET_NOTRACK): New.
	(_CET_ENDBR): Define if not defined.
	(ENTRY): Add _CET_ENDBR.
	* sysdeps/x86/dl-tunables.list (glibc.tune): Add x86_ibt and
	x86_shstk.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Add
	_CET_ENDBR.
	(_dl_runtime_profile): Likewise.
2018-07-16 14:08:27 -07:00
Rogerio Alves 52b2a80fae powerpc64: Always restore TOC on longjmp [BZ #21895]
This patch changes longjmp to always restore the TOC pointer (r2 register)
to the caller frame on powerpc64 and powerpc64le.  This is related to bug
21895 that reports a situation where you have a static longjmp to a
shared object file.

	[BZ #21895]
	* sysdeps/powerpc/powerpc64/__longjmp-common.S: Remove condition code for
	restoring r2 in longjmp.
	* sysdeps/powerpc/powerpc64/Makefile: Added tst-setjmp-bug21895-static to
	test list.
	Added rules to build test tst-setjmp-bug21895-static.
	Added module setjmp-bug21895 and rules to build a shared object from it.
	* sysdeps/powerpc/powerpc64/setjmp-bug21895.c: New test file.
	* sysdeps/powerpc/powerpc64/tst-setjmp-bug21895-static.c: New test file.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-07-16 16:08:41 -03:00
H.J. Lu 31e422ca96 x86_64: Undef SHADOW_STACK_POINTER_OFFSET last
Since SHADOW_STACK_POINTER_OFFSET is defined in jmp_buf-ssp.h, we must
undef SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.

	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Undef
	SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.
2018-07-15 08:48:54 -07:00
H.J. Lu faaee1f07e x86: Support shadow stack pointer in setjmp/longjmp
Save and restore shadow stack pointer in setjmp and longjmp to support
shadow stack in Intel CET.  Use feature_1 in tcbhead_t to check if
shadow stack is enabled before saving and restoring shadow stack pointer.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/__longjmp.S: Include <jmp_buf-ssp.h>.
	(__longjmp): Restore shadow stack pointer if shadow stack is
	enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
	isn't defined for __longjmp_cancel.
	* sysdeps/i386/bsd-_setjmp.S: Include <jmp_buf-ssp.h>.
	(_setjmp): Save shadow stack pointer if shadow stack is enabled
	and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/i386/bsd-setjmp.S: Include <jmp_buf-ssp.h>.
	(setjmp): Save shadow stack pointer if shadow stack is enabled
	and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/i386/setjmp.S: Include <jmp_buf-ssp.h>.
	(__sigsetjmp): Save shadow stack pointer if shadow stack is
	enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Include
	<jmp_buf-ssp.h>.
	(____longjmp_chk): Restore shadow stack pointer if shadow stack
	is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/unix/sysv/linux/x86/Makefile (gen-as-const-headers):
	Remove jmp_buf-ssp.sym.
	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Include
	<jmp_buf-ssp.h>.
	(____longjmp_chk): Restore shadow stack pointer if shadow stack
	is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/x86/Makefile (gen-as-const-headers): Add
	jmp_buf-ssp.sym.
	* sysdeps/x86/jmp_buf-ssp.sym: New dummy file.
	* sysdeps/x86_64/__longjmp.S: Include <jmp_buf-ssp.h>.
	(__longjmp): Restore shadow stack pointer if shadow stack is
	enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
	isn't defined for __longjmp_cancel.
	* sysdeps/x86_64/setjmp.S: Include <jmp_buf-ssp.h>.
	(__sigsetjmp): Save shadow stack pointer if shadow stack is
	enabled and SHADOW_STACK_POINTER_OFFSET is defined.
2018-07-14 05:59:53 -07:00
H.J. Lu ebff9c5cfa x86: Rename __glibc_reserved1 to feature_1 in tcbhead_t [BZ #22563]
feature_1 has X86_FEATURE_1_IBT and X86_FEATURE_1_SHSTK bits for CET
run-time control.

CET_ENABLED, IBT_ENABLED and SHSTK_ENABLED are defined to 1 or 0 to
indicate that if CET, IBT and SHSTK are enabled.

<tls-setup.h> is added to set up thread-local data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #22563]
	* nptl/pthread_create.c: Include <tls-setup.h>.
	(__pthread_create_2_1): Call tls_setup_tcbhead.
	* sysdeps/generic/tls-setup.h: New file.
	* sysdeps/x86/nptl/tls-setup.h: Likewise.
	* sysdeps/i386/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (FEATURE_1_OFFSET):
	Likewise.
	* sysdeps/i386/nptl/tls.h (tcbhead_t): Rename __glibc_reserved1
	to feature_1.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Likewise.
	* sysdeps/x86/sysdep.h (X86_FEATURE_1_IBT): New.
	(X86_FEATURE_1_SHSTK): Likewise.
	(CET_ENABLED): Likewise.
	(IBT_ENABLED): Likewise.
	(SHSTK_ENABLED): Likewise.
2018-07-14 05:56:46 -07:00
Florian Weimer fd70af4552 Add the statx function 2018-07-10 16:14:45 +02:00
Adhemerval Zanella b444e8f7cc Comment tst-ofdlocks-compat expected failure in some Linux releases
As pointed out in a libc-alpha thread [1], the misc/tst-ofdlocks-compat
may fail in some specific Linux releases.  This patch adds a comment
along with a link to discussion in the test source code.

No changes are expected.

	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Add a comment about
	a kernel issue which lead to test failure in some cases.

[1] https://sourceware.org/ml/libc-alpha/2018-07/msg00243.html
2018-07-10 10:28:39 -03:00
Szabolcs Nagy 397c54c1af aarch64: add HWCAP_ATOMICS to HWCAP_IMPORTANT
This enables searching shared libraries in atomics/ when the hardware
supports LSE atomics of armv8.1 so one can provide optimized variants
of libraries in a portable way.

LSE atomics does not affect library abi, the new instructions can
interoperate with old ones.

I considered the earlier comments on the patch

https://sourceware.org/ml/libc-alpha/2018-04/msg00400.html
https://sourceware.org/ml/libc-alpha/2018-04/msg00625.html

It turns out that the way glibc dynamic linker decides on the search
path is not very flexible: it wants to use hwcap bits and associated
strings.  So some targets reuse hwcap bits for glibc internal purposes
to affect the search logic.  But hwcap is an interface with the kernel,
glibc should not allocate bits in it for its internal logic as that
limits future hwcap extensions and confusing to users who expect to see
hwcap bits in ifunc resolvers.  Instead of rewriting the dynamic linker
path logic (which affects all targets) this patch just uses the existing
mechanism, however this means that the path name has to be the hwcap
name "atomics" and cannot be changed to something more meaningful to
users.

It is hard to tell how much performance benefit this can give, in
principle armv8.1 atomics can be better optimized in the hardware, so it
can make a difference for synchronization heavy code.  On some systems
such multilib setup may be the only viable way to get optimized
libraries used.

	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT): Add
	HWCAP_ATOMICS.
2018-07-06 15:58:16 +01:00
Szabolcs Nagy d0cd798071 aarch64: Remove HWCAP_CPUID from HWCAP_IMPORTANT
This partially reverts

commit f82e9672ad
Author:     Siddhesh Poyarekar <siddhesh@sourceware.org>

    aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK

The idea was to make it possible to disable cpuid based ifunc resolution
in glibc by changing the hwcap mask which the user could already control.

However the hwcap mask has an orthogonal role: it specifies additional
library search paths for the dynamic linker.  So "cpuid" got added to
the search paths when it was set in the default mask (HWCAP_IMPORTANT),
which is not useful behaviour, the hwcap masking should not be reused
in the cpu features code.

Meanwhile there is a tunable to set the cpu explicitly so it is possible
to disable the cpuid based dispatch without using a hwcap mask:

  GLIBC_TUNABLES=glibc.tune.cpu=generic

	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features):
	Use dl_hwcap without masking.
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT):
	Remove HWCAP_CPUID.
2018-07-06 15:57:18 +01:00
Amit Pawar bce5911b67 Use AVX_Fast_Unaligned_Load from Zen onwards.
From Zen onwards this will be enabled. It was disabled for the
Excavator case and will remain disabled.

Reviewd-by: Carlos O'Donell <carlos@redhat.com>
2018-07-06 09:55:36 -04:00
Maciej W. Rozycki 9449a295ad libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
where correct absolute (SHN_ABS) symbol run-time load semantics is
required.  This way it can be ensured at static link time that a program
or DSO will not suffer from previous semantics where absolute symbols
were relocated by the base address, or symbols whose `st_value' is zero
silently ignored leading to a confusing "undefined symbol" error message
at load time, and instead "ELF file ABI version invalid" is printed with
old dynamic loaders, making it clear that there is an ABI version
incompatibility.

	[BZ #19818]
	[BZ #23307]
	* libc-abis (ABSOLUTE): New ABI.
	* sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
	* NEWS: Mention the new ABI.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-05 18:06:43 +01:00
Florian Weimer d6da5cb6a8 Add renameat2 function [BZ #17662]
The implementation falls back to renameat if renameat2 is not available
in the kernel (or in the kernel headers) and the flags argument is zero.
Without kernel support, a non-zero argument returns EINVAL, not ENOSYS.
This mirrors what the kernel does for invalid renameat2 flags.
2018-07-05 19:00:10 +02:00
Adhemerval Zanella 7279af007c Fix hurd expected fcntl version
Different than Linux, hurd does not need the OFD locks fix from
06ab719d30 (since OFD locks are current Linux specific). This in
turn allows hurd to not provide a fcntl compat symbol.

Checked on a i686-gnu with check-abi.

	* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl): Remove
	symbol.
2018-07-03 10:02:06 -03:00
Gabriel F. T. Gomes b7b88cea41 ldbl-128ibm-compat: Add printf_size
Since the addition of the _Float128 API, strfromf128 and printf_size use
__printf_fp to print _Float128 values.  This is achieved by setting the
'is_binary128' member of the 'printf_info' structure to one.  Now that
the format of long double on powerpc64le is getting a third option, this
mechanism is reused for long double values that have binary128 format
(i.e.: when -mabi=ieeelongdouble).

This patch adds __printf_sizeieee128 as an exported symbol, but doesn't
provide redirections from printf_size, yet.  All redirections will be
installed in a future commit, once all other functions that print or
read long double values with binary128 format are ready.  In
__printf_fp, when 'is_binary128' is one, the floating-point argument is
treated as if it was of _Float128 type, regardless of the value of
'is_long_double', thus __printf_sizeieee128 sets 'is_binary128' to the
same value of 'is_long_double'.  Otherwise, double values would not be
printed correctly.

Tested for powerpc64le.
2018-07-02 10:51:01 -03:00
Szabolcs Nagy 2b445206a1 Use uint32_t sign in single precision math error handling functions
Ideally sign should be bool, but sometimes (e.g. in powf) it's more
efficient to pass a non-zero value than 1 to indicate that the sign
should be set.  The fixed size int is less ambigous than unsigned
long.

	* sysdeps/ieee754/flt-32/e_powf.c (__powf): Use uint32_t.
	(exp2f_inline): Likewise.
	* sysdeps/ieee754/flt-32/math_config.h (__math_oflowf): Likewise.
	(__math_uflowf): Likewise.
	(__math_may_uflowf): Likewise.
	(__math_divzerof): Likewise.
	(__math_invalidf): Likewise.
	* sysdeps/ieee754/flt-32/math_errf.c (xflowf): Likewise.
	(__math_oflowf): Likewise.
	(__math_uflowf): Likewise.
	(__math_may_uflowf): Likewise.
	(__math_divzerof): Likewise.
	(__math_invalidf): Likewise.
2018-07-02 09:29:04 +01:00
Carlos O'Donell 2827ab990a libc: Extend __libc_freeres framework (Bug 23329).
The __libc_freeres framework does not extend to non-libc.so objects.
This causes problems in general for valgrind and mtrace detecting
unfreed objects in both libdl.so and libpthread.so.  This change is
a pre-requisite to properly moving the malloc hooks out of malloc
since such a move now requires precise accounting of all allocated
data before destructors are run.

This commit adds a proper hook in libc.so.6 for both libdl.so and
for libpthread.so, this ensures that shm-directory.c which uses
freeit () to free memory is called properly.  We also remove the
nptl_freeres hook and fall back to using weak-ref-and-check idiom
for a loaded libpthread.so, thus making this process similar for
all DSOs.

Lastly we follow best practice and use explicit free calls for
both libdl.so and libpthread.so instead of the generic hook process
which has undefined order.

Tested on x86_64 with no regressions.

Signed-off-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-06-29 22:39:06 -04:00
Siddhesh Poyarekar 0aec4c1d18 aarch64,falkor: Use vector registers for memcpy
Vector registers perform better than scalar register pairs for copying
data so prefer them instead.  This results in a time reduction of over
50% (i.e. 2x speed improvemnet) for some smaller sizes for memcpy-walk.
Larger sizes show improvements of around 1% to 2%.  memcpy-random shows
a very small improvement, in the range of 1-2%.

	* sysdeps/aarch64/multiarch/memcpy_falkor.S (__memcpy_falkor):
	Use vector registers.
2018-06-29 22:45:59 +05:30
Siddhesh Poyarekar ce76a5cb8d aarch64,falkor: Use vector registers for memmove
Vector registers perform much better for moves compared to pairs of
registers on falkor, so use them instead.  This results in a time
reduction of up to 50% (i.e. 2x improvement) for a lot of the smaller
sizes, i.e. up to 1K in memmove-walk.  Improvements for larger sizes are
smaller, at about 1%-2%.

	* sysdeps/aarch64/multiarch/memmove_falkor.S
	(__memcpy_falkor): Use vector registers.
2018-06-29 22:45:07 +05:30
Daniel Alvarez c1f86a33ca getifaddrs: Don't return ifa entries with NULL names [BZ #21812]
A lookup operation in map_newlink could turn into an insert because of
holes in the interface part of the map.  This leads to incorrectly set
the name of the interface to NULL when the interface is not present
for the address being processed (most likely because the interface was
added between the RTM_GETLINK and RTM_GETADDR calls to the kernel).
When such changes are detected by the kernel, it'll mark the dump as
"inconsistent" by setting NLM_F_DUMP_INTR flag on the next netlink
message.

This patch checks this condition and retries the whole operation.
Hopes are that next time the interface corresponding to the address
entry is present in the list and correct name is returned.
2018-06-29 09:44:55 +02:00
Rajalakshmi Srinivasaraghavan 86a0f56158 ldbl-128ibm-compat: Introduce ieee128 symbols
This patch adds __*ieee128 symbols for strfrom, strtold, strtold_l, wcstold
and wcstold_l functions.  Redirection from *l to *ieee128 will be handled
in separate patch once we start building these new files.

2018-06-28  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>

	* sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add __strfromieee128,
	 __strtoieee128, __strtoieee128_l,__wcstoieee128 and __wcstoieee128_l.
	* sysdeps/ieee754/ldbl-128ibm-compat/strfromf128.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/strtof128.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/strtof128_l.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/wcstof128.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/wcstof128_l.c: New file.
2018-06-28 13:57:50 +05:30
Florian Weimer 890c2ced35 gethostid (Linux variant): Switch to struct scratch_buffer [BZ #18023]
Previously, extend_alloca was used without alloca accounting,
which could have been problematic with large NSS results.
2018-06-27 17:55:38 +02:00
Adhemerval Zanella 95f8ae8c83 Revert hurd errno.h changes
Patch 06ab719d30 wrongly added mach errno.h changes.
2018-06-26 20:13:34 -03:00
Adhemerval Zanella 06ab719d30 Fix Linux fcntl OFD locks for non-LFS architectures (BZ#20251)
This patch fixes the OFD ("file private") locks for architectures that
support non-LFS flock definition (__USE_FILE_OFFSET64 not defined). The
issue in this case is both F_OFD_{GETLK,SETLK,SETLKW} and
F_{SET,GET}L{W}K64 expects a flock64 argument and when using old
F_OFD_* flags with a non LFS flock argument the kernel might interpret
the underlying data wrongly.  Kernel idea originally was to avoid using
such flags in non-LFS syscall, but since GLIBC uses fcntl with LFS
semantic as default it is possible to provide the functionality and
avoid the bogus struct kernel passing by adjusting the struct manually
for the required flags.

The idea follows other LFS interfaces that provide two symbols:

  1. A new LFS fcntl64 is added on default ABI with the usual macros to
     select it for FILE_OFFSET_BITS=64.

  2. The Linux non-LFS fcntl use a stack allocated struct flock64 for
     F_OFD_{GETLK,SETLK,SETLKW} copy the results on the user provided
     struct.

  3. Keep a compat symbol with old broken semantic for architectures
     that do not define __OFF_T_MATCHES_OFF64_T.

So for architectures which defines __USE_FILE_OFFSET64, fcntl64 will
aliased to fcntl and no adjustment would be required.  So to actually
use F_OFD_* with LFS support the source must be built with LFS support
(_FILE_OFFSET_BITS=64).

Also F_OFD_SETLKW command is handled a cancellation point, as for
F_SETLKW{64}.

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

	[BZ #20251]
	* NEWS: Mention fcntl64 addition.
	* csu/check_fds.c: Replace __fcntl_nocancel by __fcntl64_nocancel.
	* login/utmp_file.c: Likewise.
	* sysdeps/posix/fdopendir.c: Likewise.
	* sysdeps/posix/opendir.c: Likewise.
	* sysdeps/unix/pt-fcntl.c: Likewise.
	* include/fcntl.h (__libc_fcntl64, __fcntl64,
	__fcntl64_nocancel_adjusted): New prototype.
	(__fcntl_nocancel_adjusted): Remove prototype.
	* io/Makefile (routines): Add fcntl64.
	(CFLAGS-fcntl64.c): New rule.
	* io/Versions [GLIBC_2.28] (fcntl64): New symbol.
	[GLIBC_PRIVATE] (__libc_fcntl): Rename to __libc_fcntl64.
	* io/fcntl.h (fcntl64): Add prototype and redirect if
	__USE_FILE_OFFSET64 is defined.
	* io/fcntl64.c: New file.
	* manual/llio.text: Add a note for which commands fcntl acts a
	cancellation point.
	* nptl/Makefile (CFLAGS-fcntl64.c): New rule.
	* sysdeps/mach/hurd/fcntl.c: Alias fcntl to fcntl64 symbols.
	* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl, fcntl64):
	New symbols.
	* sysdeps/unix/sysv/linux/fcntl.c (__libc_fcntl): Fix F_GETLK64,
	F_OFD_GETLK, F_SETLK64, F_SETLKW64, F_OFD_SETLK, and F_OFD_SETLKW for
	non-LFS case.
	* sysdeps/unix/sysv/linux/fcntl64.c: New file.
	* sysdeps/unix/sysv/linux/fcntl_nocancel.c (__fcntl_nocancel): Rename
	to __fcntl64_nocancel.
	(__fcntl_nocancel_adjusted): Rename to __fcntl64_nocancel_adjusted.
	* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): Rename
	to __fcntl64_nocancel.
	* sysdeps/unix/sysv/linux/tst-ofdlocks.c: New file.
	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add tst-ofdlocks.
	(tests-internal): Add tst-ofdlocks-compat.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
	(fcntl64): New symbol.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist [GLIBC_2.28] (fcntl,
	fcntl64): Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilis: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
2018-06-26 13:22:53 -03:00
Florian Weimer 124e025864 Run thread shutdown functions in an explicit order
This removes the __libc_thread_subfreeres hook in favor of explict
calls.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-06-26 15:27:12 +02:00
Tulio Magno Quites Machado Filho d93f4ff16b m68k: Reorganize log1p and significand implementations
Commit 5e79e0292b broke m68k after
s_significand.c became available in the build directory.  All m68k
implementations of log1p and significand were including s_significand.c
and stopped working after the inclusion of the the auto-generated file.

This patch reorganizes the implementation of log1p and significand for
m680x0 in order to avoid hitting this problem.

	* sysdeps/m68k/m680x0/fpu/s_log1p.c: Set as the generic file for
	all log1p and significand functions on m680x0.
	* sysdeps/m68k/m680x0/fpu/s_log1pf.c: Include s_log1p.c instead
	of s_significand.c..
	* sysdeps/m68k/m680x0/fpu/s_log1pl.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/s_significandf.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/s_significandl.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/s_significand.c: Move all the code to
	s_log1p.c and include it..

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-06-22 21:34:28 -03:00
Florian Weimer f496b28e61 math: Set 387 and SSE2 rounding mode for tgamma on i386 [BZ #23253]
Previously, only the SSE2 rounding mode was set, so the assembler
implementations using 387 were not following the expecting rounding
mode.
2018-06-21 08:04:29 +02:00
Tulio Magno Quites Machado Filho 209ae17c60 ldbl-128ibm-compat: Create libm-alias-float128.h
Add a new libm-alias-float128.h in order to provide the __*ieee128
aliases for the existing *f128 that do not have a globally exported
symbol.

	* sysdeps/ieee754/ldbl-128ibm-compat/Versions: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h: New file.
2018-06-20 19:02:07 -03:00
Tulio Magno Quites Machado Filho 5e79e0292b Add a generic significand implementation
Create a template for significand.

	* math/Makefile (libm-calls): Move s_significandF to...
	(gen-libm-calls): ... here.
	* math/s_significand_template.c: New file.
	* math/s_significand.c: Removed.
	* math/s_significandf.c: Removed.
	* math/s_significandl.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_significand.c: Removed.
	* sysdeps/ieee754/ldbl-opt/s_significandl.c: Removed.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-06-20 18:15:06 -03:00
Tulio Magno Quites Machado Filho badba23cac Move declare_mgen_finite_alias definition
Move declare_mgen_finite_alias, declare_mgen_finite_alias_s and
declare_mgen_finite_alias_x to a shared place in order to reuse them in
other files that also declare _finite aliases.

	* math/e_exp2_template.c (declare_mgen_finite_alias,
	declare_mgen_finite_alias_s, declare_mgen_finite_alias_x): Move to...
	* sysdeps/generic/math-type-macros.h (declare_mgen_finite_alias,
	declare_mgen_finite_alias_s, declare_mgen_finite_alias_x): ... here.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-06-20 17:42:47 -03:00
Samuel Thibault 152fbfb3ad hurd: fix localplt.data format
* sysdeps/mach/hurd/i386/localplt.data: Drop empty line.
2018-06-19 02:37:23 +02:00
Samuel Thibault c77e4dc0f5 hurd: Fix "Missing required PLT reference"
* sysdeps/mach/hurd/localplt.data: Move to...
	* sysdeps/mach/hurd/i386/localplt.data: new file. Add + REL
	R_386_GLOB_DAT like on Linux i386.
2018-06-19 02:32:41 +02:00
Joseph Myers f2857da7cd Add SHM_STAT_ANY from Linux 4.17 to bits/shm.h.
Linux 4.17 adds a SHM_STAT_ANY constant (ipcs command).  This patch
adds it to the relevant bits/shm.h headers.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/alpha/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): New macro.
	* sysdeps/unix/sysv/linux/arm/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/generic/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/sh/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/shm.h [__USE_MISC]
	(SHM_STAT_ANY): Likewise.
2018-06-18 13:37:57 +00:00
Joseph Myers 176c7fee51 Add SEM_STAT_ANY from Linux 4.17 to bits/sem.h.
Linux 4.17 adds a SEM_STAT_ANY constant (ipcs command).  This patch
adds it to the relevant bits/sem.h headers.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/alpha/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): New macro.
	* sysdeps/unix/sysv/linux/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/generic/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/sem.h [__USE_MISC]
	(SEM_STAT_ANY): Likewise.
2018-06-18 13:36:41 +00:00
Joseph Myers 86bf0019ed Add MSG_STAT_ANY from Linux 4.17 to bits/msq.h.
Linux 4.17 adds a MSG_STAT_ANY constant (ipcs command).  This patch
adds it to the relevant bits/msq.h headers.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/alpha/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): New macro.
	* sysdeps/unix/sysv/linux/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/generic/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/hppa/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/msq.h [__USE_MISC]
	(MSG_STAT_ANY): Likewise.
2018-06-18 13:34:52 +00:00
Joseph Myers 91b2f3e5dd Update MAP_TYPE value for hppa from Linux 4.17.
This patch updates the hppa definition of MAP_TYPE to reflect a
corresponding change in the Linux kernel in 4.17 (so the value now has
four bits set, as it does on other architectures, although they are
different from other architectures because of hppa differences in
other MAP_* bits).

Tested with build-many-glibcs.py for hppa.

	* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_MISC]
	(MAP_TYPE): Change value to 0x2b.
2018-06-18 13:33:52 +00:00
Florian Weimer 3fe8fc793f Linux: Create Netlink socket with SOCK_CLOEXEC in __check_pf [BZ #15722] 2018-06-18 15:24:55 +02:00
Joseph Myers 809dc95d14 Fix powerpc64le build of nan-sign tests (bug 23303).
My recent nan-sign tests fail to build for powerpc64le with GCC 8
because of the special compile / link options needed there for any
test using _Float128.  This patch arranges for these tests to be
handled on powerpc64le similarly to other such tests.

Tested with build-many-glibcs.py for powerpc64le.

	[BZ #23303]
	* sysdeps/powerpc/powerpc64/le/Makefile
	(CFLAGS-tst-strtod-nan-sign.c): Add -mfloat128.
	(CFLAGS-tst-wcstod-nan-sign.c): Likewise.
	(gnulib-tests): Also add $(f128-loader-link) for
	tst-strtod-nan-sign abd tst-wcstod-nan-sign.
2018-06-18 11:27:51 +00:00
Samuel Thibault 4d0ac0375b hurd: Fix reference to _hurd_self_sigstate
* sysdeps/hurd/include/hurd/signal.h (_hurd_self_sigstate): Add hidden
	prototype and definition.
	* sysdeps/mach/hurd/i386/____longjmp_chk.S (____longjmp_chk): Use
	hidden target for _hurd_self_sigstate.
2018-06-16 14:07:23 +00:00
Samuel Thibault f96a85e0fe hurd: Fix missing __pthread_get_cleanup_stack symbol
Rework 57e1651557 ("hurd: Avoid PLT ref for __pthread_get_cleanup_stack")
to keep the __pthread_get_cleanup_stack symbol.

        * htl/pt-cleanup.c (__pthread_get_cleanup_stack): Rename to
        ___pthread_get_cleanup_stack.
        (__pthread_get_cleanup_stack): Remove hidden def, add alias.
        * htl/pt-exit.c (__pthread_exit): Use ___pthread_get_cleanup_stack
        instead of __pthread_get_cleanup_stack.
        * sysdeps/htl/pthread-functions.h [libpthread]
        (__pthread_get_cleanup_stack): Remove hidden proto.
        * sysdeps/htl/pthreadP.h (___pthread_get_cleanup_stack): Add
        prototype.
	* sysdeps/htl/pthreadP.h (___pthread_get_cleanup_stack): Add hidden
	attribute.
	* htl/pt-join.c (__pthread_get_cleanup_stack): Define to
	___pthread_get_cleanup_stack.
2018-06-16 10:52:04 +02:00
Samuel Thibault 8c9d53428e hurd: Whitelist PLT refs which are difficult to avoid
* sysdeps/mach/hurd/localplt.data (siglongjmp, longjmp,
	__libc_lseek64, _IO_funlockfile): Whitelist PLT references.
2018-06-16 02:59:36 +02:00
Samuel Thibault b0344cf5c5 hurd: Avoid PLT references to syscalls
* mach/Makefile ($(mach-syscalls:%=$(objpfx))): Add hidden definition.
	* sysdeps/mach/include/mach/mach_traps.h (__mach_reply_port,
	__mach_thread_self, __mach_task_self, __mach_host_self, __swtch,
	__swtch_pri, __thread_switch, __evc_wait): Add hidden prototypes.
2018-06-16 02:50:36 +02:00
Samuel Thibault 7a646a93fa hurd: Avoid PLT ref to __mach_msg
* sysdeps/mach/include/mach.h (__mach_msg): Add hidden prototype.
	* mach/msg.c: Include <mach.h>.
	(__mach_msg): Add hidden definition.
2018-06-16 02:50:30 +02:00
Samuel Thibault c1b7586c54 hurd: Avoid PLT references to shortcuts
* sysdeps/mach/include/mach-shortcuts-hidden.h: New file.
	* mach/shortcut.awk: Make syscall stubs include
	<mach-shortcuts-hidden.h> and add hidden definition.
	* sysdeps/mach/include/mach.h: Include <mach-shortcuts-hidden.h>.
2018-06-16 02:48:41 +02:00
Samuel Thibault 932d05f0dc hurd: Avoid missing PLT ref from ld.so requirement
* sysdeps/mach/hurd/localplt.data (ld.so): Make ref to __open optional.
2018-06-16 01:49:29 +02:00
Samuel Thibault 57e1651557 hurd: Avoid PLT ref for __pthread_get_cleanup_stack
* htl/pt-cleanup.c (___pthread_get_cleanup_stack): Rename to
	__pthread_get_cleanup_stack.
	(__pthread_get_cleanup_stack): Remove alias, add hidden def.
	* htl/pt-exit.c (__pthread_exit): Use __pthread_get_cleanup_stack
	instead of ___pthread_get_cleanup_stack.
	* sysdeps/htl/pthread-functions.h [libpthread]
	(__pthread_get_cleanup_stack): Add hidden proto.
	* sysdeps/htl/pthreadP.h (___pthread_get_cleanup_stack): Remove
	prototype.
2018-06-16 01:37:42 +02:00
Samuel Thibault faf7bbc2d0 hurd: Detect 32bit overflow in value returned by lseek
* sysdeps/mach/hurd/lseek.c: Include <errno.h>.
	* sysdeps/mach/hurd/lseek.c (__libc_lseek): Check that the value returned
	by __lseek64 can fit off_t, return EOVERFLOW otherwise.
2018-06-16 01:37:14 +02:00
Samuel Thibault 298a8b59d4 hurd: avoid PLT ref between sendfile and sendfile64
* include/sys/sendfile.h (__sendfile64): Declare hidden prototype.
	* sysdeps/mach/hurd/sendfile.c (sendfile): Call __sendfile64 instead
	of sendfile.
	* sysdeps/mach/hurd/sendfile64.c (sendfile64): Rename to __sendfile64.
	(sendfile64): New strong alias.
2018-06-16 00:44:57 +02:00