Remove --enable-tunables configure option

And make always supported.  The configure option was added on glibc 2.25
and some features require it (such as hwcap mask, huge pages support, and
lock elisition tuning).  It also simplifies the build permutations.

Changes from v1:
 * Remove glibc.rtld.dynamic_sort changes, it is orthogonal and needs
   more discussion.
 * Cleanup more code.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
Adhemerval Zanella Netto 2023-03-23 10:13:51 -03:00 committed by Adhemerval Zanella
parent 6384171fa0
commit 33237fe83d
48 changed files with 75 additions and 513 deletions

19
INSTALL
View file

@ -228,25 +228,6 @@ if 'CFLAGS' is specified it must enable optimization. For example:
By default for x86_64, the GNU C Library is built with the vector By default for x86_64, the GNU C Library is built with the vector
math library. Use this option to disable the vector math library. math library. Use this option to disable the vector math library.
'--enable-tunables'
Tunables support allows additional library parameters to be
customized at runtime. This feature is enabled by default. This
option can take the following values:
'yes'
This is the default if no option is passed to configure. This
enables tunables and selects the default frontend (currently
'valstring').
'no'
This option disables tunables.
'valstring'
This enables tunables and selects the 'valstring' frontend for
tunables. This frontend allows users to specify tunables as a
colon-separated list in a single environment variable
'GLIBC_TUNABLES'.
'--disable-crypt' '--disable-crypt'
Do not install the passphrase-hashing library 'libcrypt' or the Do not install the passphrase-hashing library 'libcrypt' or the
header file 'crypt.h'. 'unistd.h' will still declare the function header file 'crypt.h'. 'unistd.h' will still declare the function

View file

@ -1017,11 +1017,8 @@ CPPFLAGS = $(config-extra-cppflags) $(CPPUNDEFS) $(CPPFLAGS-config) \
$(CPPFLAGS-$(suffix $@)) \ $(CPPFLAGS-$(suffix $@)) \
$(foreach lib,$(libof-$(basename $(@F))) \ $(foreach lib,$(libof-$(basename $(@F))) \
$(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \ $(libof-$(<F)) $(libof-$(@F)),$(CPPFLAGS-$(lib))) \
$(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F))) $(CPPFLAGS-$(<F)) $(CPPFLAGS-$(@F)) $(CPPFLAGS-$(basename $(@F))) \
-DTOP_NAMESPACE=glibc
ifneq (no,$(have-tunables))
CPPFLAGS += -DTOP_NAMESPACE=glibc
endif
override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \ override CFLAGS = -std=gnu11 -fgnu89-inline $(config-extra-cflags) \
$(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \ $(filter-out %frame-pointer,$(+cflags)) $(+gccwarn-c) \
@ -1203,7 +1200,6 @@ endif
# Build the tunables list header early since it could be used by any module in # Build the tunables list header early since it could be used by any module in
# glibc. # glibc.
ifneq (no,$(have-tunables))
before-compile += $(common-objpfx)dl-tunable-list.h before-compile += $(common-objpfx)dl-tunable-list.h
common-generated += dl-tunable-list.h dl-tunable-list.stmp common-generated += dl-tunable-list.h dl-tunable-list.stmp
@ -1216,7 +1212,6 @@ $(common-objpfx)dl-tunable-list.stmp: \
$(AWK) -f $^ > ${@:stmp=T} $(AWK) -f $^ > ${@:stmp=T}
$(move-if-change) ${@:stmp=T} ${@:stmp=h} $(move-if-change) ${@:stmp=T} ${@:stmp=h}
touch $@ touch $@
endif
# Dump the GCC macros used by the default compiler flags to a header # Dump the GCC macros used by the default compiler flags to a header
# file, so that they can be inspected when using different compiler # file, so that they can be inspected when using different compiler

3
NEWS
View file

@ -34,6 +34,9 @@ Deprecated and removed features, and other changes affecting compatibility:
cache can still be disable per-application using tunables cache can still be disable per-application using tunables
(glibc.malloc.tcache_count set to zero). (glibc.malloc.tcache_count set to zero).
* The configure option --enable-tunables has been removed. The tunable
feature is now always enabled.
Changes to build and runtime requirements: Changes to build and runtime requirements:
[Add changes to build and runtime requirements here] [Add changes to build and runtime requirements here]

View file

@ -271,9 +271,6 @@
/* PowerPC32 uses fctidz for floating point to long long conversions. */ /* PowerPC32 uses fctidz for floating point to long long conversions. */
#define HAVE_PPC_FCTIDZ 0 #define HAVE_PPC_FCTIDZ 0
/* Build glibc with tunables support. */
#define HAVE_TUNABLES 0
/* Define if PIE is unsupported. */ /* Define if PIE is unsupported. */
#undef PIE_UNSUPPORTED #undef PIE_UNSUPPORTED

View file

@ -93,7 +93,6 @@ build-nscd = @build_nscd@
use-nscd = @use_nscd@ use-nscd = @use_nscd@
build-hardcoded-path-in-tests= @hardcoded_path_in_tests@ build-hardcoded-path-in-tests= @hardcoded_path_in_tests@
build-pt-chown = @build_pt_chown@ build-pt-chown = @build_pt_chown@
have-tunables = @have_tunables@
pthread-in-libc = @pthread_in_libc@ pthread-in-libc = @pthread_in_libc@
# Build tools. # Build tools.

17
configure vendored
View file

@ -664,7 +664,6 @@ INSTALL_DATA
INSTALL_SCRIPT INSTALL_SCRIPT
INSTALL_PROGRAM INSTALL_PROGRAM
base_machine base_machine
have_tunables
build_pt_chown build_pt_chown
build_nscd build_nscd
libc_cv_static_nss_crypt libc_cv_static_nss_crypt
@ -780,7 +779,6 @@ enable_systemtap
enable_build_nscd enable_build_nscd
enable_nscd enable_nscd
enable_pt_chown enable_pt_chown
enable_tunables
enable_mathvec enable_mathvec
enable_cet enable_cet
enable_scv enable_scv
@ -1448,8 +1446,6 @@ Optional Features:
--disable-build-nscd disable building and installing the nscd daemon --disable-build-nscd disable building and installing the nscd daemon
--disable-nscd library functions will not contact the nscd daemon --disable-nscd library functions will not contact the nscd daemon
--enable-pt_chown Enable building and installing pt_chown --enable-pt_chown Enable building and installing pt_chown
--enable-tunables Enable tunables support. Known values are 'yes',
'no' and 'valstring'
--enable-mathvec Enable building and installing mathvec [default --enable-mathvec Enable building and installing mathvec [default
depends on architecture] depends on architecture]
--enable-cet enable Intel Control-flow Enforcement Technology --enable-cet enable Intel Control-flow Enforcement Technology
@ -3658,19 +3654,6 @@ if test "$build_pt_chown" = yes; then
fi fi
# Check whether --enable-tunables was given.
if test "${enable_tunables+set}" = set; then :
enableval=$enable_tunables; have_tunables=$enableval
else
have_tunables=yes
fi
if test "$have_tunables" = yes; then
$as_echo "#define HAVE_TUNABLES 1" >>confdefs.h
fi
# The abi-tags file uses a fairly simplistic model for name recognition that # The abi-tags file uses a fairly simplistic model for name recognition that
# can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
# $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell. # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.

View file

@ -427,16 +427,6 @@ if test "$build_pt_chown" = yes; then
AC_DEFINE(HAVE_PT_CHOWN) AC_DEFINE(HAVE_PT_CHOWN)
fi fi
AC_ARG_ENABLE([tunables],
[AS_HELP_STRING([--enable-tunables],
[Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
[have_tunables=$enableval],
[have_tunables=yes])
AC_SUBST(have_tunables)
if test "$have_tunables" = yes; then
AC_DEFINE(HAVE_TUNABLES)
fi
# The abi-tags file uses a fairly simplistic model for name recognition that # The abi-tags file uses a fairly simplistic model for name recognition that
# can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
# $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell. # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.

View file

@ -82,6 +82,7 @@ dl-routines = \
dl-tls \ dl-tls \
dl-tls_init_tp \ dl-tls_init_tp \
dl-trampoline \ dl-trampoline \
dl-tunables \
dl-version \ dl-version \
dl-write \ dl-write \
# dl-routines # dl-routines
@ -90,11 +91,6 @@ ifeq (yes,$(use-ldconfig))
dl-routines += dl-cache dl-routines += dl-cache
endif endif
ifneq (no,$(have-tunables))
dl-routines += dl-tunables
tunables-type = $(addprefix TUNABLES_FRONTEND_,$(have-tunables))
CPPFLAGS-dl-tunables.c += -DTUNABLES_FRONTEND=$(tunables-type)
ifeq (yesyes,$(build-shared)$(run-built-tests)) ifeq (yesyes,$(build-shared)$(run-built-tests))
tests-special += $(objpfx)list-tunables.out tests-special += $(objpfx)list-tunables.out
endif endif
@ -104,7 +100,6 @@ endif
ifeq (yes,$(have-loop-to-function)) ifeq (yes,$(have-loop-to-function))
CFLAGS-dl-tunables.c += -fno-tree-loop-distribute-patterns CFLAGS-dl-tunables.c += -fno-tree-loop-distribute-patterns
endif endif
endif
all-dl-routines = $(dl-routines) $(sysdep-dl-routines) all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
# But they are absent from the shared libc, because that code is in ld.so. # But they are absent from the shared libc, because that code is in ld.so.
@ -1173,7 +1168,6 @@ postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \
$(objpfx)/dso-sort-tests-2.generated-makefile $(objpfx)/dso-sort-tests-2.generated-makefile
# Generate from each testcase description file # Generate from each testcase description file
ifeq (yes,$(have-tunables))
$(eval $(call include_dsosort_tests,dso-sort-tests-1.def)) $(eval $(call include_dsosort_tests,dso-sort-tests-1.def))
$(eval $(call include_dsosort_tests,dso-sort-tests-2.def)) $(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
@ -1181,7 +1175,6 @@ $(eval $(call include_dsosort_tests,dso-sort-tests-2.def))
LDFLAGS-tst-bz15311-b.so += -Wl,-z,lazy LDFLAGS-tst-bz15311-b.so += -Wl,-z,lazy
LDFLAGS-tst-bz15311-c.so += -Wl,-z,lazy LDFLAGS-tst-bz15311-c.so += -Wl,-z,lazy
LDFLAGS-tst-bz15311-d.so += -Wl,-z,lazy LDFLAGS-tst-bz15311-d.so += -Wl,-z,lazy
endif
check-abi: $(objpfx)check-abi-ld.out \ check-abi: $(objpfx)check-abi-ld.out \
$(objpfx)check-abi-version-libc.out $(objpfx)check-abi-version-libc.out

View file

@ -205,7 +205,7 @@ search_cache (const char *string_table, uint32_t string_table_size,
uint64_t platform = _dl_string_platform (GLRO (dl_platform)); uint64_t platform = _dl_string_platform (GLRO (dl_platform));
if (platform != (uint64_t) -1) if (platform != (uint64_t) -1)
platform = 1ULL << platform; platform = 1ULL << platform;
uint64_t hwcap_mask = GET_HWCAP_MASK (); uint64_t hwcap_mask = TUNABLE_GET (glibc, cpu, hwcap_mask, uint64_t, NULL);
#define _DL_HWCAP_TLS_MASK (1LL << 63) #define _DL_HWCAP_TLS_MASK (1LL << 63)
uint64_t hwcap_exclude = ~((GLRO (dl_hwcap) & hwcap_mask) uint64_t hwcap_exclude = ~((GLRO (dl_hwcap) & hwcap_mask)
| _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK); | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);

View file

@ -24,17 +24,6 @@
#include <elf/dl-tunables.h> #include <elf/dl-tunables.h>
#if HAVE_TUNABLES
# define GET_HWCAP_MASK() TUNABLE_GET (glibc, cpu, hwcap_mask, uint64_t, NULL)
#else
# ifdef SHARED
# define GET_HWCAP_MASK() GLRO(dl_hwcap_mask)
# else
/* HWCAP_MASK is ignored in static binaries when built without tunables. */
# define GET_HWCAP_MASK() (0)
# endif
#endif
#define GLIBC_HWCAPS_SUBDIRECTORY "glibc-hwcaps" #define GLIBC_HWCAPS_SUBDIRECTORY "glibc-hwcaps"
#define GLIBC_HWCAPS_PREFIX GLIBC_HWCAPS_SUBDIRECTORY "/" #define GLIBC_HWCAPS_PREFIX GLIBC_HWCAPS_SUBDIRECTORY "/"

View file

@ -121,11 +121,6 @@ _dl_sort_maps_original (struct link_map **maps, unsigned int nmaps,
} }
} }
#if !HAVE_TUNABLES
/* In this case, just default to the original algorithm. */
strong_alias (_dl_sort_maps_original, _dl_sort_maps);
#else
/* We use a recursive function due to its better clarity and ease of /* We use a recursive function due to its better clarity and ease of
implementation, as well as faster execution speed. We already use implementation, as well as faster execution speed. We already use
alloca() for list allocation during the breadth-first search of alloca() for list allocation during the breadth-first search of
@ -314,5 +309,3 @@ _dl_sort_maps (struct link_map **maps, unsigned int nmaps,
else else
_dl_sort_maps_dfs (maps, nmaps, force_first, for_fini); _dl_sort_maps_dfs (maps, nmaps, force_first, for_fini);
} }
#endif /* HAVE_TUNABLES. */

View file

@ -168,16 +168,6 @@ enum dso_sort_algorithm _dl_dso_sort_algo;
/* The value of the FPU control word the kernel will preset in hardware. */ /* The value of the FPU control word the kernel will preset in hardware. */
fpu_control_t _dl_fpu_control = _FPU_DEFAULT; fpu_control_t _dl_fpu_control = _FPU_DEFAULT;
#if !HAVE_TUNABLES
/* This is not initialized to HWCAP_IMPORTANT, matching the definition
of _dl_important_hwcaps, below, where no hwcap strings are ever
used. This mask is still used to mediate the lookups in the cache
file. Since there is no way to set this nonzero (we don't grok the
LD_HWCAP_MASK environment variable here), there is no real point in
setting _dl_hwcap nonzero below, but we do anyway. */
uint64_t _dl_hwcap_mask;
#endif
/* Prevailing state of the stack. Generally this includes PF_X, indicating it's /* Prevailing state of the stack. Generally this includes PF_X, indicating it's
* executable but this isn't true for all platforms. */ * executable but this isn't true for all platforms. */
ElfW(Word) _dl_stack_flags = DEFAULT_STACK_PERMS; ElfW(Word) _dl_stack_flags = DEFAULT_STACK_PERMS;
@ -328,11 +318,6 @@ _dl_non_dynamic_init (void)
__unsetenv (cp); __unsetenv (cp);
cp = strchr (cp, '\0') + 1; cp = strchr (cp, '\0') + 1;
} }
#if !HAVE_TUNABLES
if (__access ("/etc/suid-debug", F_OK) != 0)
__unsetenv ("MALLOC_CHECK_");
#endif
} }
#ifdef DL_PLATFORM_INIT #ifdef DL_PLATFORM_INIT

View file

@ -97,14 +97,8 @@ _dl_tls_static_surplus_init (size_t naudit)
{ {
size_t nns, opt_tls; size_t nns, opt_tls;
#if HAVE_TUNABLES
nns = TUNABLE_GET (nns, size_t, NULL); nns = TUNABLE_GET (nns, size_t, NULL);
opt_tls = TUNABLE_GET (optional_static_tls, size_t, NULL); opt_tls = TUNABLE_GET (optional_static_tls, size_t, NULL);
#else
/* Default values of the tunables. */
nns = DEFAULT_NNS;
opt_tls = OPTIONAL_TLS;
#endif
if (nns > DL_NNS) if (nns > DL_NNS)
nns = DL_NNS; nns = DL_NNS;
if (DL_NNS - nns < naudit) if (DL_NNS - nns < naudit)

View file

@ -38,11 +38,6 @@
#include <not-errno.h> #include <not-errno.h>
#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
# define GLIBC_TUNABLES "GLIBC_TUNABLES"
#endif
#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
static char * static char *
tunables_strdup (const char *in) tunables_strdup (const char *in)
{ {
@ -62,7 +57,6 @@ tunables_strdup (const char *in)
return out; return out;
} }
#endif
static char ** static char **
get_next_env (char **envp, char **name, size_t *namelen, char **val, get_next_env (char **envp, char **name, size_t *namelen, char **val,
@ -160,7 +154,6 @@ __tunable_set_val (tunable_id_t id, tunable_val_t *valp, tunable_num_t *minp,
do_tunable_update_val (cur, valp, minp, maxp); do_tunable_update_val (cur, valp, minp, maxp);
} }
#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
/* Parse the tunable string TUNESTR and adjust it to drop any tunables that may /* Parse the tunable string TUNESTR and adjust it to drop any tunables that may
be unsafe for AT_SECURE processes so that it can be used as the new be unsafe for AT_SECURE processes so that it can be used as the new
environment variable value for GLIBC_TUNABLES. VALSTRING is the original environment variable value for GLIBC_TUNABLES. VALSTRING is the original
@ -255,7 +248,6 @@ parse_tunables (char *tunestr, char *valstring)
p += len + 1; p += len + 1;
} }
} }
#endif
/* Enable the glibc.malloc.check tunable in SETUID/SETGID programs only when /* Enable the glibc.malloc.check tunable in SETUID/SETGID programs only when
the system administrator has created the /etc/suid-debug file. This is a the system administrator has created the /etc/suid-debug file. This is a
@ -287,8 +279,7 @@ __tunables_init (char **envp)
while ((envp = get_next_env (envp, &envname, &len, &envval, while ((envp = get_next_env (envp, &envname, &len, &envval,
&prev_envp)) != NULL) &prev_envp)) != NULL)
{ {
#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring if (tunable_is_name ("GLIBC_TUNABLES", envname))
if (tunable_is_name (GLIBC_TUNABLES, envname))
{ {
char *new_env = tunables_strdup (envname); char *new_env = tunables_strdup (envname);
if (new_env != NULL) if (new_env != NULL)
@ -297,7 +288,6 @@ __tunables_init (char **envp)
*prev_envp = new_env; *prev_envp = new_env;
continue; continue;
} }
#endif
for (int i = 0; i < sizeof (tunable_list) / sizeof (tunable_t); i++) for (int i = 0; i < sizeof (tunable_list) / sizeof (tunable_t); i++)
{ {

View file

@ -21,17 +21,9 @@
#ifndef _TUNABLES_H_ #ifndef _TUNABLES_H_
#define _TUNABLES_H_ #define _TUNABLES_H_
#if !HAVE_TUNABLES #include <stdbool.h>
static inline void #include <stddef.h>
__always_inline #include <stdint.h>
__tunables_init (char **unused __attribute__ ((unused)))
{
/* This is optimized out if tunables are not enabled. */
}
#else
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
typedef intmax_t tunable_num_t; typedef intmax_t tunable_num_t;
@ -44,12 +36,12 @@ typedef union
typedef void (*tunable_callback_t) (tunable_val_t *); typedef void (*tunable_callback_t) (tunable_val_t *);
/* Full name for a tunable is top_ns.tunable_ns.id. */ /* Full name for a tunable is top_ns.tunable_ns.id. */
# define TUNABLE_NAME_S(top,ns,id) #top "." #ns "." #id #define TUNABLE_NAME_S(top,ns,id) #top "." #ns "." #id
# define TUNABLE_ENUM_NAME(__top,__ns,__id) TUNABLE_ENUM_NAME1 (__top,__ns,__id) #define TUNABLE_ENUM_NAME(__top,__ns,__id) TUNABLE_ENUM_NAME1 (__top,__ns,__id)
# define TUNABLE_ENUM_NAME1(__top,__ns,__id) __top ## _ ## __ns ## _ ## __id #define TUNABLE_ENUM_NAME1(__top,__ns,__id) __top ## _ ## __ns ## _ ## __id
# include "dl-tunable-list.h" #include "dl-tunable-list.h"
extern void __tunables_init (char **); extern void __tunables_init (char **);
extern void __tunables_print (void); extern void __tunables_print (void);
@ -83,7 +75,7 @@ rtld_hidden_proto (__tunable_set_val)
/* Get and return a tunable value. If the tunable was set externally and __CB /* Get and return a tunable value. If the tunable was set externally and __CB
is defined then call __CB before returning the value. */ is defined then call __CB before returning the value. */
# define TUNABLE_GET_FULL(__top, __ns, __id, __type, __cb) \ #define TUNABLE_GET_FULL(__top, __ns, __id, __type, __cb) \
({ \ ({ \
tunable_id_t id = TUNABLE_ENUM_NAME (__top, __ns, __id); \ tunable_id_t id = TUNABLE_ENUM_NAME (__top, __ns, __id); \
__type ret; \ __type ret; \
@ -92,14 +84,14 @@ rtld_hidden_proto (__tunable_set_val)
}) })
/* Set a tunable value. */ /* Set a tunable value. */
# define TUNABLE_SET_FULL(__top, __ns, __id, __val) \ #define TUNABLE_SET_FULL(__top, __ns, __id, __val) \
({ \ ({ \
__tunable_set_val (TUNABLE_ENUM_NAME (__top, __ns, __id), \ __tunable_set_val (TUNABLE_ENUM_NAME (__top, __ns, __id), \
& (tunable_val_t) {.numval = __val}, NULL, NULL); \ & (tunable_val_t) {.numval = __val}, NULL, NULL); \
}) })
/* Set a tunable value together with min/max values. */ /* Set a tunable value together with min/max values. */
# define TUNABLE_SET_WITH_BOUNDS_FULL(__top, __ns, __id,__val, __min, __max) \ #define TUNABLE_SET_WITH_BOUNDS_FULL(__top, __ns, __id,__val, __min, __max) \
({ \ ({ \
__tunable_set_val (TUNABLE_ENUM_NAME (__top, __ns, __id), \ __tunable_set_val (TUNABLE_ENUM_NAME (__top, __ns, __id), \
& (tunable_val_t) {.numval = __val}, \ & (tunable_val_t) {.numval = __val}, \
@ -109,11 +101,7 @@ rtld_hidden_proto (__tunable_set_val)
/* Namespace sanity for callback functions. Use this macro to keep the /* Namespace sanity for callback functions. Use this macro to keep the
namespace of the modules clean. */ namespace of the modules clean. */
# define TUNABLE_CALLBACK(__name) _dl_tunable_ ## __name #define TUNABLE_CALLBACK(__name) _dl_tunable_ ## __name
# define TUNABLES_FRONTEND_valstring 1
/* The default value for TUNABLES_FRONTEND. */
# define TUNABLES_FRONTEND_yes TUNABLES_FRONTEND_valstring
static __always_inline bool static __always_inline bool
tunable_val_lt (tunable_num_t lhs, tunable_num_t rhs, bool unsigned_cmp) tunable_val_lt (tunable_num_t lhs, tunable_num_t rhs, bool unsigned_cmp)
@ -149,4 +137,3 @@ tunable_is_name (const char *orig, const char *envname)
} }
#endif #endif
#endif

View file

@ -195,12 +195,8 @@ setting environment variables (which would be inherited by subprocesses).\n\
in LIST\n\ in LIST\n\
--audit LIST use objects named in LIST as auditors\n\ --audit LIST use objects named in LIST as auditors\n\
--preload LIST preload objects named in LIST\n\ --preload LIST preload objects named in LIST\n\
--argv0 STRING set argv[0] to STRING before running\n" --argv0 STRING set argv[0] to STRING before running\n\
#if HAVE_TUNABLES --list-tunables list all tunables with minimum and maximum values\n\
"\
--list-tunables list all tunables with minimum and maximum values\n"
#endif
"\
--list-diagnostics list diagnostics information\n\ --list-diagnostics list diagnostics information\n\
--help display this help and exit\n\ --help display this help and exit\n\
--version output version information and exit\n\ --version output version information and exit\n\

View file

@ -357,9 +357,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
._dl_sysinfo = DL_SYSINFO_DEFAULT, ._dl_sysinfo = DL_SYSINFO_DEFAULT,
#endif #endif
._dl_debug_fd = STDERR_FILENO, ._dl_debug_fd = STDERR_FILENO,
#if !HAVE_TUNABLES
._dl_hwcap_mask = HWCAP_IMPORTANT,
#endif
._dl_lazy = 1, ._dl_lazy = 1,
._dl_fpu_control = _FPU_DEFAULT, ._dl_fpu_control = _FPU_DEFAULT,
._dl_pagesize = EXEC_PAGESIZE, ._dl_pagesize = EXEC_PAGESIZE,
@ -1483,7 +1480,6 @@ dl_main (const ElfW(Phdr) *phdr,
_dl_argc -= 2; _dl_argc -= 2;
_dl_argv += 2; _dl_argv += 2;
} }
#if HAVE_TUNABLES
else if (! strcmp (_dl_argv[1], "--list-tunables")) else if (! strcmp (_dl_argv[1], "--list-tunables"))
{ {
state.mode = rtld_mode_list_tunables; state.mode = rtld_mode_list_tunables;
@ -1491,7 +1487,6 @@ dl_main (const ElfW(Phdr) *phdr,
--_dl_argc; --_dl_argc;
++_dl_argv; ++_dl_argv;
} }
#endif
else if (! strcmp (_dl_argv[1], "--list-diagnostics")) else if (! strcmp (_dl_argv[1], "--list-diagnostics"))
{ {
state.mode = rtld_mode_list_diagnostics; state.mode = rtld_mode_list_diagnostics;
@ -1519,13 +1514,11 @@ dl_main (const ElfW(Phdr) *phdr,
else else
break; break;
#if HAVE_TUNABLES
if (__glibc_unlikely (state.mode == rtld_mode_list_tunables)) if (__glibc_unlikely (state.mode == rtld_mode_list_tunables))
{ {
__tunables_print (); __tunables_print ();
_exit (0); _exit (0);
} }
#endif
if (state.mode == rtld_mode_list_diagnostics) if (state.mode == rtld_mode_list_diagnostics)
_dl_print_diagnostics (_environ); _dl_print_diagnostics (_environ);
@ -2624,15 +2617,6 @@ process_envvars (struct dl_main_state *state)
_dl_show_auxv (); _dl_show_auxv ();
break; break;
#if !HAVE_TUNABLES
case 10:
/* Mask for the important hardware capabilities. */
if (!__libc_enable_secure
&& memcmp (envline, "HWCAP_MASK", 10) == 0)
GLRO(dl_hwcap_mask) = _dl_strtoul (&envline[11], NULL);
break;
#endif
case 11: case 11:
/* Path where the binary is found. */ /* Path where the binary is found. */
if (!__libc_enable_secure if (!__libc_enable_secure
@ -2695,12 +2679,7 @@ process_envvars (struct dl_main_state *state)
while (*nextp != '\0'); while (*nextp != '\0');
if (__access ("/etc/suid-debug", F_OK) != 0) if (__access ("/etc/suid-debug", F_OK) != 0)
{ GLRO(dl_debug_mask) = 0;
#if !HAVE_TUNABLES
unsetenv ("MALLOC_CHECK_");
#endif
GLRO(dl_debug_mask) = 0;
}
if (state->mode != rtld_mode_normal) if (state->mode != rtld_mode_normal)
_exit (5); _exit (5);

View file

@ -19,8 +19,6 @@
glibc.malloc.check and glibc.malloc.mmap_threshold but also retain glibc.malloc.check and glibc.malloc.mmap_threshold but also retain
glibc.malloc.mmap_threshold in an unprivileged child. */ glibc.malloc.mmap_threshold in an unprivileged child. */
/* This is compiled as part of the testsuite but needs to see
HAVE_TUNABLES. */
#define _LIBC 1 #define _LIBC 1
#include "config.h" #include "config.h"
#undef _LIBC #undef _LIBC
@ -83,7 +81,6 @@ test_child (int off)
{ {
const char *val = getenv ("GLIBC_TUNABLES"); const char *val = getenv ("GLIBC_TUNABLES");
#if HAVE_TUNABLES
if (val != NULL && strcmp (val, resultstrings[off]) == 0) if (val != NULL && strcmp (val, resultstrings[off]) == 0)
return 0; return 0;
@ -91,14 +88,6 @@ test_child (int off)
printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val); printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val);
return 1; return 1;
#else
if (val != NULL)
{
printf ("[%d] GLIBC_TUNABLES not cleared\n", off);
return 1;
}
return 0;
#endif
} }
static int static int

View file

@ -46,10 +46,8 @@
#include <libc-internal.h> #include <libc-internal.h>
#include <not-cancel.h> #include <not-cancel.h>
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE gmon
# define TUNABLE_NAMESPACE gmon #include <elf/dl-tunables.h>
# include <elf/dl-tunables.h>
#endif
#ifdef PIC #ifdef PIC
# include <link.h> # include <link.h>
@ -130,7 +128,6 @@ __monstartup (u_long lowpc, u_long highpc)
struct gmonparam *p = &_gmonparam; struct gmonparam *p = &_gmonparam;
long int minarcs, maxarcs; long int minarcs, maxarcs;
#if HAVE_TUNABLES
/* Read minarcs/maxarcs tunables. */ /* Read minarcs/maxarcs tunables. */
minarcs = TUNABLE_GET (minarcs, int32_t, NULL); minarcs = TUNABLE_GET (minarcs, int32_t, NULL);
maxarcs = TUNABLE_GET (maxarcs, int32_t, NULL); maxarcs = TUNABLE_GET (maxarcs, int32_t, NULL);
@ -139,11 +136,6 @@ __monstartup (u_long lowpc, u_long highpc)
ERR("monstartup: maxarcs < minarcs, setting maxarcs = minarcs\n"); ERR("monstartup: maxarcs < minarcs, setting maxarcs = minarcs\n");
maxarcs = minarcs; maxarcs = minarcs;
} }
#else
/* No tunables, we use hardcoded defaults */
minarcs = MINARCS;
maxarcs = MAXARCS;
#endif
/* /*
* If we are incorrectly called twice in a row (without an * If we are incorrectly called twice in a row (without an

View file

@ -61,9 +61,7 @@ tests-internal += \
tst-dynarray-fail \ tst-dynarray-fail \
tst-dynarray-at-fail \ tst-dynarray-at-fail \
ifneq (no,$(have-tunables))
tests += tst-malloc-usable-tunables tst-mxfast tests += tst-malloc-usable-tunables tst-mxfast
endif
tests += $(tests-static) tests += $(tests-static)
test-srcs = tst-mtrace test-srcs = tst-mtrace

View file

@ -18,9 +18,7 @@
#include <stdbool.h> #include <stdbool.h>
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE malloc
# define TUNABLE_NAMESPACE malloc
#endif
#include <elf/dl-tunables.h> #include <elf/dl-tunables.h>
/* Compile-time constants. */ /* Compile-time constants. */
@ -47,21 +45,13 @@
static inline size_t static inline size_t
heap_min_size (void) heap_min_size (void)
{ {
#if HAVE_TUNABLES
return mp_.hp_pagesize == 0 ? HEAP_MIN_SIZE : mp_.hp_pagesize; return mp_.hp_pagesize == 0 ? HEAP_MIN_SIZE : mp_.hp_pagesize;
#else
return HEAP_MIN_SIZE;
#endif
} }
static inline size_t static inline size_t
heap_max_size (void) heap_max_size (void)
{ {
#if HAVE_TUNABLES
return mp_.hp_pagesize == 0 ? HEAP_MAX_SIZE : mp_.hp_pagesize * 4; return mp_.hp_pagesize == 0 ? HEAP_MAX_SIZE : mp_.hp_pagesize * 4;
#else
return HEAP_MAX_SIZE;
#endif
} }
/***************************************************************************/ /***************************************************************************/
@ -239,8 +229,7 @@ __malloc_fork_unlock_child (void)
__libc_lock_init (list_lock); __libc_lock_init (list_lock);
} }
#if HAVE_TUNABLES #define TUNABLE_CALLBACK_FNDECL(__name, __type) \
# define TUNABLE_CALLBACK_FNDECL(__name, __type) \
static inline int do_ ## __name (__type value); \ static inline int do_ ## __name (__type value); \
static void \ static void \
TUNABLE_CALLBACK (__name) (tunable_val_t *valp) \ TUNABLE_CALLBACK (__name) (tunable_val_t *valp) \
@ -263,42 +252,6 @@ TUNABLE_CALLBACK_FNDECL (set_tcache_unsorted_limit, size_t)
#endif #endif
TUNABLE_CALLBACK_FNDECL (set_mxfast, size_t) TUNABLE_CALLBACK_FNDECL (set_mxfast, size_t)
TUNABLE_CALLBACK_FNDECL (set_hugetlb, size_t) TUNABLE_CALLBACK_FNDECL (set_hugetlb, size_t)
#else
/* Initialization routine. */
#include <string.h>
extern char **_environ;
static char *
next_env_entry (char ***position)
{
char **current = *position;
char *result = NULL;
while (*current != NULL)
{
if (__builtin_expect ((*current)[0] == 'M', 0)
&& (*current)[1] == 'A'
&& (*current)[2] == 'L'
&& (*current)[3] == 'L'
&& (*current)[4] == 'O'
&& (*current)[5] == 'C'
&& (*current)[6] == '_')
{
result = &(*current)[7];
/* Save current position for next visit. */
*position = ++current;
break;
}
++current;
}
return result;
}
#endif
#if USE_TCACHE #if USE_TCACHE
static void tcache_key_initialize (void); static void tcache_key_initialize (void);
@ -343,7 +296,6 @@ ptmalloc_init (void)
malloc_init_state (&main_arena); malloc_init_state (&main_arena);
#if HAVE_TUNABLES
TUNABLE_GET (top_pad, size_t, TUNABLE_CALLBACK (set_top_pad)); TUNABLE_GET (top_pad, size_t, TUNABLE_CALLBACK (set_top_pad));
TUNABLE_GET (perturb, int32_t, TUNABLE_CALLBACK (set_perturb_byte)); TUNABLE_GET (perturb, int32_t, TUNABLE_CALLBACK (set_perturb_byte));
TUNABLE_GET (mmap_threshold, size_t, TUNABLE_CALLBACK (set_mmap_threshold)); TUNABLE_GET (mmap_threshold, size_t, TUNABLE_CALLBACK (set_mmap_threshold));
@ -363,70 +315,6 @@ ptmalloc_init (void)
/* Force mmap for main arena instead of sbrk, so hugepages are explicitly /* Force mmap for main arena instead of sbrk, so hugepages are explicitly
used. */ used. */
__always_fail_morecore = true; __always_fail_morecore = true;
#else
if (__glibc_likely (_environ != NULL))
{
char **runp = _environ;
char *envline;
while (__builtin_expect ((envline = next_env_entry (&runp)) != NULL,
0))
{
size_t len = strcspn (envline, "=");
if (envline[len] != '=')
/* This is a "MALLOC_" variable at the end of the string
without a '=' character. Ignore it since otherwise we
will access invalid memory below. */
continue;
switch (len)
{
case 8:
if (!__builtin_expect (__libc_enable_secure, 0))
{
if (memcmp (envline, "TOP_PAD_", 8) == 0)
__libc_mallopt (M_TOP_PAD, strtol (&envline[9], NULL, 10));
else if (memcmp (envline, "PERTURB_", 8) == 0)
__libc_mallopt (M_PERTURB, strtol (&envline[9], NULL, 10));
}
break;
case 9:
if (!__builtin_expect (__libc_enable_secure, 0))
{
if (memcmp (envline, "MMAP_MAX_", 9) == 0)
__libc_mallopt (M_MMAP_MAX, strtol (&envline[10],
NULL, 10));
else if (memcmp (envline, "ARENA_MAX", 9) == 0)
__libc_mallopt (M_ARENA_MAX, strtol (&envline[10],
NULL, 10));
}
break;
case 10:
if (!__builtin_expect (__libc_enable_secure, 0))
{
if (memcmp (envline, "ARENA_TEST", 10) == 0)
__libc_mallopt (M_ARENA_TEST, strtol (&envline[11],
NULL, 10));
}
break;
case 15:
if (!__builtin_expect (__libc_enable_secure, 0))
{
if (memcmp (envline, "TRIM_THRESHOLD_", 15) == 0)
__libc_mallopt (M_TRIM_THRESHOLD, strtol (&envline[16],
NULL, 10));
else if (memcmp (envline, "MMAP_THRESHOLD_", 15) == 0)
__libc_mallopt (M_MMAP_THRESHOLD, strtol (&envline[16],
NULL, 10));
}
break;
default:
break;
}
}
}
#endif
} }
/* Managing heaps and arenas (for concurrent threads) */ /* Managing heaps and arenas (for concurrent threads) */
@ -561,7 +449,6 @@ alloc_new_heap (size_t size, size_t top_pad, size_t pagesize,
static heap_info * static heap_info *
new_heap (size_t size, size_t top_pad) new_heap (size_t size, size_t top_pad)
{ {
#if HAVE_TUNABLES
if (__glibc_unlikely (mp_.hp_pagesize != 0)) if (__glibc_unlikely (mp_.hp_pagesize != 0))
{ {
heap_info *h = alloc_new_heap (size, top_pad, mp_.hp_pagesize, heap_info *h = alloc_new_heap (size, top_pad, mp_.hp_pagesize,
@ -569,7 +456,6 @@ new_heap (size_t size, size_t top_pad)
if (h != NULL) if (h != NULL)
return h; return h;
} }
#endif
return alloc_new_heap (size, top_pad, GLRO (dl_pagesize), 0); return alloc_new_heap (size, top_pad, GLRO (dl_pagesize), 0);
} }

View file

@ -376,7 +376,6 @@ memalign_check (size_t alignment, size_t bytes)
return mem2mem_check (tag_new_usable (mem), bytes); return mem2mem_check (tag_new_usable (mem), bytes);
} }
#if HAVE_TUNABLES
static void static void
TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp) TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
{ {
@ -384,7 +383,6 @@ TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
if (value != 0) if (value != 0)
__malloc_debug_enable (MALLOC_CHECK_HOOK); __malloc_debug_enable (MALLOC_CHECK_HOOK);
} }
#endif
static bool static bool
initialize_malloc_check (void) initialize_malloc_check (void)
@ -392,12 +390,6 @@ initialize_malloc_check (void)
/* This is the copy of the malloc initializer that we pulled in along with /* This is the copy of the malloc initializer that we pulled in along with
malloc-check. This does not affect any of the libc malloc structures. */ malloc-check. This does not affect any of the libc malloc structures. */
ptmalloc_init (); ptmalloc_init ();
#if HAVE_TUNABLES
TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check)); TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check));
#else
const char *s = secure_getenv ("MALLOC_CHECK_");
if (s && s[0] != '\0' && s[0] != '0')
__malloc_debug_enable (MALLOC_CHECK_HOOK);
#endif
return __is_malloc_debug_enabled (MALLOC_CHECK_HOOK); return __is_malloc_debug_enabled (MALLOC_CHECK_HOOK);
} }

View file

@ -1856,14 +1856,12 @@ struct malloc_par
INTERNAL_SIZE_T arena_test; INTERNAL_SIZE_T arena_test;
INTERNAL_SIZE_T arena_max; INTERNAL_SIZE_T arena_max;
#if HAVE_TUNABLES
/* Transparent Large Page support. */ /* Transparent Large Page support. */
INTERNAL_SIZE_T thp_pagesize; INTERNAL_SIZE_T thp_pagesize;
/* A value different than 0 means to align mmap allocation to hp_pagesize /* A value different than 0 means to align mmap allocation to hp_pagesize
add hp_flags on flags. */ add hp_flags on flags. */
INTERNAL_SIZE_T hp_pagesize; INTERNAL_SIZE_T hp_pagesize;
int hp_flags; int hp_flags;
#endif
/* Memory map support */ /* Memory map support */
int n_mmaps; int n_mmaps;
@ -1998,7 +1996,7 @@ free_perturb (char *p, size_t n)
static inline void static inline void
madvise_thp (void *p, INTERNAL_SIZE_T size) madvise_thp (void *p, INTERNAL_SIZE_T size)
{ {
#if HAVE_TUNABLES && defined (MADV_HUGEPAGE) #ifdef MADV_HUGEPAGE
/* Do not consider areas smaller than a huge page or if the tunable is /* Do not consider areas smaller than a huge page or if the tunable is
not active. */ not active. */
if (mp_.thp_pagesize == 0 || size < mp_.thp_pagesize) if (mp_.thp_pagesize == 0 || size < mp_.thp_pagesize)
@ -2557,7 +2555,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
&& (mp_.n_mmaps < mp_.n_mmaps_max))) && (mp_.n_mmaps < mp_.n_mmaps_max)))
{ {
char *mm; char *mm;
#if HAVE_TUNABLES
if (mp_.hp_pagesize > 0 && nb >= mp_.hp_pagesize) if (mp_.hp_pagesize > 0 && nb >= mp_.hp_pagesize)
{ {
/* There is no need to isse the THP madvise call if Huge Pages are /* There is no need to isse the THP madvise call if Huge Pages are
@ -2566,7 +2563,6 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
if (mm != MAP_FAILED) if (mm != MAP_FAILED)
return mm; return mm;
} }
#endif
mm = sysmalloc_mmap (nb, pagesize, 0, av); mm = sysmalloc_mmap (nb, pagesize, 0, av);
if (mm != MAP_FAILED) if (mm != MAP_FAILED)
return mm; return mm;
@ -2679,7 +2675,7 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
previous calls. Otherwise, we correct to page-align below. previous calls. Otherwise, we correct to page-align below.
*/ */
#if HAVE_TUNABLES && defined (MADV_HUGEPAGE) #ifdef MADV_HUGEPAGE
/* Defined in brk.c. */ /* Defined in brk.c. */
extern void *__curbrk; extern void *__curbrk;
if (__glibc_unlikely (mp_.thp_pagesize != 0)) if (__glibc_unlikely (mp_.thp_pagesize != 0))
@ -2718,12 +2714,10 @@ sysmalloc (INTERNAL_SIZE_T nb, mstate av)
*/ */
char *mbrk = MAP_FAILED; char *mbrk = MAP_FAILED;
#if HAVE_TUNABLES
if (mp_.hp_pagesize > 0) if (mp_.hp_pagesize > 0)
mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, mbrk = sysmalloc_mmap_fallback (&size, nb, old_size,
mp_.hp_pagesize, mp_.hp_pagesize, mp_.hp_pagesize, mp_.hp_pagesize,
mp_.hp_flags, av); mp_.hp_flags, av);
#endif
if (mbrk == MAP_FAILED) if (mbrk == MAP_FAILED)
mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, MMAP_AS_MORECORE_SIZE, mbrk = sysmalloc_mmap_fallback (&size, nb, old_size, MMAP_AS_MORECORE_SIZE,
pagesize, 0, av); pagesize, 0, av);
@ -2966,7 +2960,7 @@ systrim (size_t pad, mstate av)
return 0; return 0;
/* Release in pagesize units and round down to the nearest page. */ /* Release in pagesize units and round down to the nearest page. */
#if HAVE_TUNABLES && defined (MADV_HUGEPAGE) #ifdef MADV_HUGEPAGE
if (__glibc_unlikely (mp_.thp_pagesize != 0)) if (__glibc_unlikely (mp_.thp_pagesize != 0))
extra = ALIGN_DOWN (top_area - pad, mp_.thp_pagesize); extra = ALIGN_DOWN (top_area - pad, mp_.thp_pagesize);
else else
@ -5410,7 +5404,6 @@ do_set_mxfast (size_t value)
return 0; return 0;
} }
#if HAVE_TUNABLES
static __always_inline int static __always_inline int
do_set_hugetlb (size_t value) do_set_hugetlb (size_t value)
{ {
@ -5429,7 +5422,6 @@ do_set_hugetlb (size_t value)
&mp_.hp_flags); &mp_.hp_flags);
return 0; return 0;
} }
#endif
int int
__libc_mallopt (int param_number, int value) __libc_mallopt (int param_number, int value)

View file

@ -256,25 +256,6 @@ configure with @option{--disable-werror}.
By default for x86_64, @theglibc{} is built with the vector math library. By default for x86_64, @theglibc{} is built with the vector math library.
Use this option to disable the vector math library. Use this option to disable the vector math library.
@item --enable-tunables
Tunables support allows additional library parameters to be customized at
runtime. This feature is enabled by default. This option can take the
following values:
@table @code
@item yes
This is the default if no option is passed to configure. This enables tunables
and selects the default frontend (currently @samp{valstring}).
@item no
This option disables tunables.
@item valstring
This enables tunables and selects the @samp{valstring} frontend for tunables.
This frontend allows users to specify tunables as a colon-separated list in a
single environment variable @env{GLIBC_TUNABLES}.
@end table
@item --disable-crypt @item --disable-crypt
Do not install the passphrase-hashing library @file{libcrypt} or the Do not install the passphrase-hashing library @file{libcrypt} or the
header file @file{crypt.h}. @file{unistd.h} will still declare the header file @file{crypt.h}. @file{unistd.h} will still declare the

View file

@ -16,8 +16,7 @@
License along with the GNU C Library; if not, see License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */ <https://www.gnu.org/licenses/>. */
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE pthread
# define TUNABLE_NAMESPACE pthread
#include <pthread_mutex_conf.h> #include <pthread_mutex_conf.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
@ -53,4 +52,3 @@ __pthread_tunables_init (void)
TUNABLE_GET (stack_cache_size, size_t, TUNABLE_GET (stack_cache_size, size_t,
TUNABLE_CALLBACK (set_stack_cache_size)); TUNABLE_CALLBACK (set_stack_cache_size));
} }
#endif

View file

@ -98,7 +98,6 @@ check_type (const char *mas, pthread_mutexattr_t *ma)
/* Check if a mutex will be elided. Lock elision can only be activated via /* Check if a mutex will be elided. Lock elision can only be activated via
the tunables framework. By default, lock elision is disabled. */ the tunables framework. By default, lock elision is disabled. */
bool assume_elided_mutex = false; bool assume_elided_mutex = false;
#if HAVE_TUNABLES
int ma_type = PTHREAD_MUTEX_TIMED_NP; int ma_type = PTHREAD_MUTEX_TIMED_NP;
if (ma != NULL) if (ma != NULL)
{ {
@ -117,7 +116,6 @@ check_type (const char *mas, pthread_mutexattr_t *ma)
if (TUNABLE_GET_FULL (glibc, elision, enable, int32_t, NULL) == 1) if (TUNABLE_GET_FULL (glibc, elision, enable, int32_t, NULL) == 1)
assume_elided_mutex = true; assume_elided_mutex = true;
} }
#endif
e = pthread_mutex_init (m, ma); e = pthread_mutex_init (m, ma);
if (e != 0) if (e != 0)

View file

@ -445,7 +445,6 @@ class Context(object):
'--disable-profile', '--disable-profile',
'--disable-timezone-tools', '--disable-timezone-tools',
'--disable-mathvec', '--disable-mathvec',
'--disable-tunables',
'--disable-crypt', '--disable-crypt',
'--disable-build-nscd', '--disable-build-nscd',
'--disable-nscd']}, '--disable-nscd']},

View file

@ -586,11 +586,6 @@ struct rtld_global_ro
/* Mask for hardware capabilities that are available. */ /* Mask for hardware capabilities that are available. */
EXTERN uint64_t _dl_hwcap; EXTERN uint64_t _dl_hwcap;
#if !HAVE_TUNABLES
/* Mask for important hardware capabilities we honour. */
EXTERN uint64_t _dl_hwcap_mask;
#endif
#ifdef HAVE_AUX_VECTOR #ifdef HAVE_AUX_VECTOR
/* Pointer to the auxv list supplied to the program at startup. */ /* Pointer to the auxv list supplied to the program at startup. */
EXTERN ElfW(auxv_t) *_dl_auxv; EXTERN ElfW(auxv_t) *_dl_auxv;
@ -1192,22 +1187,13 @@ extern struct link_map * _dl_get_dl_main_map (void)
brk. */ brk. */
void *_dl_early_allocate (size_t size) attribute_hidden; void *_dl_early_allocate (size_t size) attribute_hidden;
/* Initialize the DSO sort algorithm to use. */
#if !HAVE_TUNABLES
static inline void
__always_inline
_dl_sort_maps_init (void)
{
/* This is optimized out if tunables are not enabled. */
}
#else
extern void _dl_sort_maps_init (void) attribute_hidden;
#endif
/* Initialization of libpthread for statically linked applications. /* Initialization of libpthread for statically linked applications.
If libpthread is not linked in, this is an empty function. */ If libpthread is not linked in, this is an empty function. */
void __pthread_initialize_minimal (void) weak_function; void __pthread_initialize_minimal (void) weak_function;
/* Initialize the DSO sort algorithm to use. */
extern void _dl_sort_maps_init (void) attribute_hidden;
/* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */ /* Allocate memory for static TLS block (unless MEM is nonzero) and dtv. */
extern void *_dl_allocate_tls (void *mem); extern void *_dl_allocate_tls (void *mem);
rtld_hidden_proto (_dl_allocate_tls) rtld_hidden_proto (_dl_allocate_tls)

View file

@ -1,16 +1,10 @@
#if !HAVE_TUNABLES
# define GLIBC_TUNABLES_ENVVAR "GLIBC_TUNABLES\0"
#else
# define GLIBC_TUNABLES_ENVVAR
#endif
/* Environment variable to be removed for SUID programs. The names are /* Environment variable to be removed for SUID programs. The names are
all stuffed in a single string which means they have to be terminated all stuffed in a single string which means they have to be terminated
with a '\0' explicitly. */ with a '\0' explicitly. */
#define UNSECURE_ENVVARS \ #define UNSECURE_ENVVARS \
"GCONV_PATH\0" \ "GCONV_PATH\0" \
"GETCONF_DIR\0" \ "GETCONF_DIR\0" \
GLIBC_TUNABLES_ENVVAR \ "GLIBC_TUNABLES\0" \
"HOSTALIASES\0" \ "HOSTALIASES\0" \
"LD_AUDIT\0" \ "LD_AUDIT\0" \
"LD_DEBUG\0" \ "LD_DEBUG\0" \

View file

@ -102,9 +102,7 @@ __tls_init_tp (void)
{ {
bool do_rseq = true; bool do_rseq = true;
#if HAVE_TUNABLES
do_rseq = TUNABLE_GET (rseq, int, NULL); do_rseq = TUNABLE_GET (rseq, int, NULL);
#endif
if (rseq_register_current_thread (pd, do_rseq)) if (rseq_register_current_thread (pd, do_rseq))
{ {
/* We need a writable view of the variables. They are in /* We need a writable view of the variables. They are in

View file

@ -45,11 +45,7 @@
static inline short max_adaptive_count (void) static inline short max_adaptive_count (void)
{ {
#if HAVE_TUNABLES
return __mutex_aconf.spin_count; return __mutex_aconf.spin_count;
#else
return DEFAULT_ADAPTIVE_COUNT;
#endif
} }

View file

@ -53,9 +53,7 @@ __pthread_early_init (void)
__default_pthread_attr.internal.stacksize = limit.rlim_cur; __default_pthread_attr.internal.stacksize = limit.rlim_cur;
__default_pthread_attr.internal.guardsize = GLRO (dl_pagesize); __default_pthread_attr.internal.guardsize = GLRO (dl_pagesize);
#if HAVE_TUNABLES
__pthread_tunables_init (); __pthread_tunables_init ();
#endif
} }
#endif /* _PTHREAD_EARLY_INIT_H */ #endif /* _PTHREAD_EARLY_INIT_H */

View file

@ -20,7 +20,6 @@
#include <adaptive_spin_count.h> #include <adaptive_spin_count.h>
#if HAVE_TUNABLES
struct mutex_config struct mutex_config
{ {
int spin_count; int spin_count;
@ -30,12 +29,5 @@ extern struct mutex_config __mutex_aconf;
libc_hidden_proto (__mutex_aconf) libc_hidden_proto (__mutex_aconf)
extern void __pthread_tunables_init (void) attribute_hidden; extern void __pthread_tunables_init (void) attribute_hidden;
#else
static inline void
__pthread_tunables_init (void)
{
/* No tunables to initialize. */
}
#endif
#endif #endif

View file

@ -18,10 +18,7 @@
#include <stdint.h> #include <stdint.h>
#include <cpu-features.h> #include <cpu-features.h>
#include <elf/dl-tunables.h>
#if HAVE_TUNABLES
# include <elf/dl-tunables.h>
#endif
static inline void static inline void
init_cpu_features (struct cpu_features *cpu_features) init_cpu_features (struct cpu_features *cpu_features)
@ -29,11 +26,7 @@ init_cpu_features (struct cpu_features *cpu_features)
/* Default is to use aligned memory access on optimized function unless /* Default is to use aligned memory access on optimized function unless
tunables is enable, since for this case user can explicit disable tunables is enable, since for this case user can explicit disable
unaligned optimizations. */ unaligned optimizations. */
#if HAVE_TUNABLES
int32_t cached_memfunc = TUNABLE_GET (glibc, cpu, cached_memopt, int32_t, int32_t cached_memfunc = TUNABLE_GET (glibc, cpu, cached_memopt, int32_t,
NULL); NULL);
cpu_features->use_cached_memopt = (cached_memfunc > 0); cpu_features->use_cached_memopt = (cached_memfunc > 0);
#else
cpu_features->use_cached_memopt = false;
#endif
} }

View file

@ -18,15 +18,12 @@
#include <cpu-features.h> #include <cpu-features.h>
#if HAVE_TUNABLES #include <elf/dl-tunables.h>
# include <elf/dl-tunables.h> #include <ifunc-memcmp.h>
# include <ifunc-memcmp.h> #include <string.h>
# include <string.h>
extern __typeof (memcmp) MEMCMP_DEFAULT; extern __typeof (memcmp) MEMCMP_DEFAULT;
#endif
#if HAVE_TUNABLES #define S390_COPY_CPU_FEATURES(SRC_PTR, DEST_PTR) \
# define S390_COPY_CPU_FEATURES(SRC_PTR, DEST_PTR) \
(DEST_PTR)->hwcap = (SRC_PTR)->hwcap; \ (DEST_PTR)->hwcap = (SRC_PTR)->hwcap; \
(DEST_PTR)->stfle_bits[0] = (SRC_PTR)->stfle_bits[0]; (DEST_PTR)->stfle_bits[0] = (SRC_PTR)->stfle_bits[0];
@ -205,7 +202,6 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
cpu_features->stfle_bits[0] = cpu_features_curr.stfle_bits[0] cpu_features->stfle_bits[0] = cpu_features_curr.stfle_bits[0]
& cpu_features_orig.stfle_bits[0]; & cpu_features_orig.stfle_bits[0];
} }
#endif
static inline void static inline void
init_cpu_features (struct cpu_features *cpu_features) init_cpu_features (struct cpu_features *cpu_features)
@ -233,7 +229,5 @@ init_cpu_features (struct cpu_features *cpu_features)
cpu_features->stfle_bits[0] = 0ULL; cpu_features->stfle_bits[0] = 0ULL;
} }
#if HAVE_TUNABLES
TUNABLE_GET (glibc, cpu, hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps)); TUNABLE_GET (glibc, cpu, hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps));
#endif
} }

View file

@ -39,8 +39,9 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
return 1; return 1;
else if (ehdr->e_machine == EM_SPARC32PLUS) else if (ehdr->e_machine == EM_SPARC32PLUS)
{ {
#if HAVE_TUNABLES || defined SHARED #if defined SHARED
uint64_t hwcap_mask = GET_HWCAP_MASK(); uint64_t hwcap_mask = TUNABLE_GET (glibc, cpu, hwcap_mask, uint64_t,
NULL);
return GLRO(dl_hwcap) & hwcap_mask & HWCAP_SPARC_V9; return GLRO(dl_hwcap) & hwcap_mask & HWCAP_SPARC_V9;
#else #else
return GLRO(dl_hwcap) & HWCAP_SPARC_V9; return GLRO(dl_hwcap) & HWCAP_SPARC_V9;

View file

@ -245,11 +245,9 @@ tests-internal += \
tst-sigcontext-get_pc \ tst-sigcontext-get_pc \
# tests-internal # tests-internal
ifneq (no,$(have-tunables))
tests-internal += \ tests-internal += \
tst-rseq-disable \ tst-rseq-disable \
# tests-internal $(have-tunables) # tests-internal
endif
tests-time64 += \ tests-time64 += \
tst-adjtimex-time64 \ tst-adjtimex-time64 \

View file

@ -30,7 +30,6 @@
to see when pointer have been correctly tagged. */ to see when pointer have been correctly tagged. */
#define MTE_ALLOWED_TAGS (0xfffe << PR_MTE_TAG_SHIFT) #define MTE_ALLOWED_TAGS (0xfffe << PR_MTE_TAG_SHIFT)
#if HAVE_TUNABLES
struct cpu_list struct cpu_list
{ {
const char *name; const char *name;
@ -59,19 +58,16 @@ get_midr_from_mcpu (const char *mcpu)
return UINT64_MAX; return UINT64_MAX;
} }
#endif
static inline void static inline void
init_cpu_features (struct cpu_features *cpu_features) init_cpu_features (struct cpu_features *cpu_features)
{ {
register uint64_t midr = UINT64_MAX; register uint64_t midr = UINT64_MAX;
#if HAVE_TUNABLES
/* Get the tunable override. */ /* Get the tunable override. */
const char *mcpu = TUNABLE_GET (glibc, cpu, name, const char *, NULL); const char *mcpu = TUNABLE_GET (glibc, cpu, name, const char *, NULL);
if (mcpu != NULL) if (mcpu != NULL)
midr = get_midr_from_mcpu (mcpu); midr = get_midr_from_mcpu (mcpu);
#endif
/* If there was no useful tunable override, query the MIDR if the kernel /* If there was no useful tunable override, query the MIDR if the kernel
allows it. */ allows it. */
@ -100,13 +96,11 @@ init_cpu_features (struct cpu_features *cpu_features)
cpu_features->mte_state = 0; cpu_features->mte_state = 0;
#ifdef USE_MTAG #ifdef USE_MTAG
# if HAVE_TUNABLES
int mte_state = TUNABLE_GET (glibc, mem, tagging, unsigned, 0); int mte_state = TUNABLE_GET (glibc, mem, tagging, unsigned, 0);
cpu_features->mte_state = (GLRO (dl_hwcap2) & HWCAP2_MTE) ? mte_state : 0; cpu_features->mte_state = (GLRO (dl_hwcap2) & HWCAP2_MTE) ? mte_state : 0;
/* If we lack the MTE feature, disable the tunable, since it will /* If we lack the MTE feature, disable the tunable, since it will
otherwise cause instructions that won't run on this CPU to be used. */ otherwise cause instructions that won't run on this CPU to be used. */
TUNABLE_SET (glibc, mem, tagging, cpu_features->mte_state); TUNABLE_SET (glibc, mem, tagging, cpu_features->mte_state);
# endif
if (cpu_features->mte_state & 4) if (cpu_features->mte_state & 4)
/* Enable choosing system-preferred faulting mode. */ /* Enable choosing system-preferred faulting mode. */

View file

@ -22,9 +22,7 @@
#include <unistd.h> #include <unistd.h>
#include <dl-procinfo.h> #include <dl-procinfo.h>
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE elision
# define TUNABLE_NAMESPACE elision
#endif
#include <elf/dl-tunables.h> #include <elf/dl-tunables.h>
/* Reasonable initial tuning values, may be revised in the future. /* Reasonable initial tuning values, may be revised in the future.
@ -51,7 +49,6 @@ struct elision_config __elision_aconf =
.skip_trylock_internal_abort = 3, .skip_trylock_internal_abort = 3,
}; };
#if HAVE_TUNABLES
static inline void static inline void
__always_inline __always_inline
do_set_elision_enable (int32_t elision_enable) do_set_elision_enable (int32_t elision_enable)
@ -94,14 +91,12 @@ TUNABLE_CALLBACK_FNDECL (skip_lock_internal_abort, int32_t);
TUNABLE_CALLBACK_FNDECL (skip_lock_out_of_tbegin_retries, int32_t); TUNABLE_CALLBACK_FNDECL (skip_lock_out_of_tbegin_retries, int32_t);
TUNABLE_CALLBACK_FNDECL (try_tbegin, int32_t); TUNABLE_CALLBACK_FNDECL (try_tbegin, int32_t);
TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t); TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
#endif
/* Initialize elision. */ /* Initialize elision. */
void void
__lll_elision_init (void) __lll_elision_init (void)
{ {
#if HAVE_TUNABLES
/* Elision depends on tunables and must be explicitly turned on by setting /* Elision depends on tunables and must be explicitly turned on by setting
the appropriate tunable on a supported platform. */ the appropriate tunable on a supported platform. */
@ -117,7 +112,6 @@ __lll_elision_init (void)
TUNABLE_CALLBACK (set_elision_try_tbegin)); TUNABLE_CALLBACK (set_elision_try_tbegin));
TUNABLE_GET (skip_trylock_internal_abort, int32_t, TUNABLE_GET (skip_trylock_internal_abort, int32_t,
TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort)); TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort));
#endif
/* Linux from 3.9 through 4.2 do not abort HTM transaction on syscalls, /* Linux from 3.9 through 4.2 do not abort HTM transaction on syscalls,
instead it suspends the transaction and resumes it when returning to instead it suspends the transaction and resumes it when returning to

View file

@ -22,9 +22,7 @@
#include <unistd.h> #include <unistd.h>
#include <dl-procinfo.h> #include <dl-procinfo.h>
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE elision
# define TUNABLE_NAMESPACE elision
#endif
#include <elf/dl-tunables.h> #include <elf/dl-tunables.h>
/* Reasonable initial tuning values, may be revised in the future. /* Reasonable initial tuning values, may be revised in the future.
@ -51,7 +49,6 @@ struct elision_config __elision_aconf =
.skip_trylock_internal_abort = 3, .skip_trylock_internal_abort = 3,
}; };
#if HAVE_TUNABLES
static inline void static inline void
__always_inline __always_inline
do_set_elision_enable (int32_t elision_enable) do_set_elision_enable (int32_t elision_enable)
@ -93,14 +90,12 @@ TUNABLE_CALLBACK_FNDECL (skip_lock_internal_abort, int32_t);
TUNABLE_CALLBACK_FNDECL (skip_lock_out_of_tbegin_retries, int32_t); TUNABLE_CALLBACK_FNDECL (skip_lock_out_of_tbegin_retries, int32_t);
TUNABLE_CALLBACK_FNDECL (try_tbegin, int32_t); TUNABLE_CALLBACK_FNDECL (try_tbegin, int32_t);
TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t); TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
#endif
/* Initialize elison. */ /* Initialize elison. */
void void
__lll_elision_init (void) __lll_elision_init (void)
{ {
#if HAVE_TUNABLES
/* Elision depends on tunables and must be explicitly turned on by setting /* Elision depends on tunables and must be explicitly turned on by setting
the appropriate tunable on a supported platform. */ the appropriate tunable on a supported platform. */
@ -116,7 +111,6 @@ __lll_elision_init (void)
TUNABLE_CALLBACK (set_elision_try_tbegin)); TUNABLE_CALLBACK (set_elision_try_tbegin));
TUNABLE_GET (skip_trylock_internal_abort, int32_t, TUNABLE_GET (skip_trylock_internal_abort, int32_t,
TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort)); TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort));
#endif
if (!__pthread_force_elision) if (!__pthread_force_elision)
__elision_aconf.try_tbegin = 0; /* Disable elision on rwlocks. */ __elision_aconf.try_tbegin = 0; /* Disable elision on rwlocks. */

View file

@ -22,9 +22,7 @@
#include <elision-conf.h> #include <elision-conf.h>
#include <unistd.h> #include <unistd.h>
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE elision
# define TUNABLE_NAMESPACE elision
#endif
#include <elf/dl-tunables.h> #include <elf/dl-tunables.h>
/* Reasonable initial tuning values, may be revised in the future. /* Reasonable initial tuning values, may be revised in the future.
@ -48,7 +46,6 @@ struct elision_config __elision_aconf =
.skip_trylock_internal_abort = 3, .skip_trylock_internal_abort = 3,
}; };
#if HAVE_TUNABLES
static __always_inline void static __always_inline void
do_set_elision_enable (int32_t elision_enable) do_set_elision_enable (int32_t elision_enable)
{ {
@ -87,14 +84,12 @@ TUNABLE_CALLBACK_FNDECL (skip_lock_busy, int32_t);
TUNABLE_CALLBACK_FNDECL (skip_lock_internal_abort, int32_t); TUNABLE_CALLBACK_FNDECL (skip_lock_internal_abort, int32_t);
TUNABLE_CALLBACK_FNDECL (retry_try_xbegin, int32_t); TUNABLE_CALLBACK_FNDECL (retry_try_xbegin, int32_t);
TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t); TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
#endif
/* Initialize elision. */ /* Initialize elision. */
void void
__lll_elision_init (void) __lll_elision_init (void)
{ {
#if HAVE_TUNABLES
/* Elision depends on tunables and must be explicitly turned on by setting /* Elision depends on tunables and must be explicitly turned on by setting
the appropriate tunable on a supported platform. */ the appropriate tunable on a supported platform. */
@ -108,7 +103,6 @@ __lll_elision_init (void)
TUNABLE_CALLBACK (set_elision_retry_try_xbegin)); TUNABLE_CALLBACK (set_elision_retry_try_xbegin));
TUNABLE_GET (skip_trylock_internal_abort, int32_t, TUNABLE_GET (skip_trylock_internal_abort, int32_t,
TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort)); TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort));
#endif
if (!__pthread_force_elision) if (!__pthread_force_elision)
__elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks. */ __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks. */

View file

@ -2,7 +2,6 @@
default-abi := 64 default-abi := 64
ifeq ($(subdir),elf) ifeq ($(subdir),elf)
ifneq ($(have-tunables),no)
tests-map-32bit = \ tests-map-32bit = \
tst-map-32bit-1a \ tst-map-32bit-1a \
@ -24,4 +23,3 @@ tst-map-32bit-1b-ENV = GLIBC_TUNABLES=glibc.cpu.prefer_map_32bit_exec=1
$(objpfx)tst-map-32bit-1b: $(objpfx)tst-map-32bit-mod.so $(objpfx)tst-map-32bit-1b: $(objpfx)tst-map-32bit-mod.so
endif endif
endif

View file

@ -25,7 +25,6 @@ tests-static += \
tst-ifunc-isa-1-static tst-ifunc-isa-1-static
test-xfail-tst-ifunc-isa-1 = $(with-lld) test-xfail-tst-ifunc-isa-1 = $(with-lld)
test-xfail-tst-ifunc-isa-1-static = $(with-lld) test-xfail-tst-ifunc-isa-1-static = $(with-lld)
ifneq ($(have-tunables),no)
tests += \ tests += \
tst-ifunc-isa-2 \ tst-ifunc-isa-2 \
tst-ifunc-isa-2-static tst-ifunc-isa-2-static
@ -35,7 +34,6 @@ test-xfail-tst-ifunc-isa-2 = $(with-lld)
test-xfail-tst-ifunc-isa-2-static = $(with-lld) test-xfail-tst-ifunc-isa-2-static = $(with-lld)
endif endif
endif endif
endif
ifeq (yes,$(enable-x86-isa-level)) ifeq (yes,$(enable-x86-isa-level))
tests += tst-isa-level-1 tests += tst-isa-level-1
modules-names += tst-isa-level-mod-1-baseline \ modules-names += tst-isa-level-mod-1-baseline \
@ -65,11 +63,9 @@ $(objpfx)tst-isa-level-1.out: $(objpfx)tst-isa-level-mod-1-baseline.so \
$(objpfx)tst-isa-level-mod-1-v3.so \ $(objpfx)tst-isa-level-mod-1-v3.so \
$(objpfx)tst-isa-level-mod-1-v4.so $(objpfx)tst-isa-level-mod-1-v4.so
endif endif
ifneq ($(have-tunables),no)
tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512F tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512F
tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV) tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV)
endif endif
endif
ifeq ($(subdir),math) ifeq ($(subdir),math)
tests += tst-ldbl-nonnormal-printf tests += tst-ldbl-nonnormal-printf
@ -79,12 +75,10 @@ ifeq ($(subdir),setjmp)
gen-as-const-headers += jmp_buf-ssp.sym gen-as-const-headers += jmp_buf-ssp.sym
sysdep_routines += __longjmp_cancel sysdep_routines += __longjmp_cancel
ifneq ($(enable-cet),no) ifneq ($(enable-cet),no)
ifneq ($(have-tunables),no)
tests += tst-setjmp-cet tests += tst-setjmp-cet
tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on
endif endif
endif endif
endif
ifeq ($(subdir),string) ifeq ($(subdir),string)
sysdep_routines += cacheinfo sysdep_routines += cacheinfo
@ -135,10 +129,8 @@ tests += tst-cet-legacy-1 tst-cet-legacy-1a tst-cet-legacy-2 \
tst-cet-legacy-10 tst-cet-legacy-10-static tst-cet-legacy-10 tst-cet-legacy-10-static
tests-static += tst-cet-legacy-9-static tst-cet-legacy-10-static tests-static += tst-cet-legacy-9-static tst-cet-legacy-10-static
tst-cet-legacy-1a-ARGS = -- $(host-test-program-cmd) tst-cet-legacy-1a-ARGS = -- $(host-test-program-cmd)
ifneq (no,$(have-tunables))
tests += tst-cet-legacy-4a tst-cet-legacy-4b tst-cet-legacy-4c \ tests += tst-cet-legacy-4a tst-cet-legacy-4b tst-cet-legacy-4c \
tst-cet-legacy-5b tst-cet-legacy-6b tst-cet-legacy-5b tst-cet-legacy-6b
endif
modules-names += tst-cet-legacy-mod-1 tst-cet-legacy-mod-2 \ modules-names += tst-cet-legacy-mod-1 tst-cet-legacy-mod-2 \
tst-cet-legacy-mod-4 tst-cet-legacy-mod-5a \ tst-cet-legacy-mod-4 tst-cet-legacy-mod-5a \
tst-cet-legacy-mod-5b tst-cet-legacy-mod-5c \ tst-cet-legacy-mod-5b tst-cet-legacy-mod-5c \
@ -195,7 +187,6 @@ $(objpfx)tst-cet-legacy-6a.out: $(objpfx)tst-cet-legacy-mod-6a.so \
$(objpfx)tst-cet-legacy-mod-6a.so: $(objpfx)tst-cet-legacy-mod-6c.so $(objpfx)tst-cet-legacy-mod-6a.so: $(objpfx)tst-cet-legacy-mod-6c.so
$(objpfx)tst-cet-legacy-mod-6b.so: $(objpfx)tst-cet-legacy-mod-6c.so $(objpfx)tst-cet-legacy-mod-6b.so: $(objpfx)tst-cet-legacy-mod-6c.so
LDFLAGS-tst-cet-legacy-mod-6c.so = -Wl,--enable-new-dtags,-z,nodelete LDFLAGS-tst-cet-legacy-mod-6c.so = -Wl,--enable-new-dtags,-z,nodelete
ifneq (no,$(have-tunables))
$(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so $(objpfx)tst-cet-legacy-4a.out: $(objpfx)tst-cet-legacy-mod-4.so
tst-cet-legacy-4a-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=permissive tst-cet-legacy-4a-ENV = GLIBC_TUNABLES=glibc.cpu.x86_shstk=permissive
$(objpfx)tst-cet-legacy-4b.out: $(objpfx)tst-cet-legacy-mod-4.so $(objpfx)tst-cet-legacy-4b.out: $(objpfx)tst-cet-legacy-mod-4.so
@ -211,7 +202,6 @@ tst-cet-legacy-6b-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
tst-cet-legacy-9-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK tst-cet-legacy-9-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
tst-cet-legacy-9-static-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK tst-cet-legacy-9-static-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
endif endif
endif
# Add -fcf-protection to CFLAGS when CET is enabled. # Add -fcf-protection to CFLAGS when CET is enabled.
CFLAGS-.o += -fcf-protection CFLAGS-.o += -fcf-protection

View file

@ -21,11 +21,9 @@
#include <cpuid.h> #include <cpuid.h>
#include <cpu-features.h> #include <cpu-features.h>
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE cpu
# define TUNABLE_NAMESPACE cpu #include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */
# include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ #include <elf/dl-tunables.h>
# include <elf/dl-tunables.h>
#endif
#if IS_IN (libc) #if IS_IN (libc)
/* Data cache size for use in memory and string routines, typically /* Data cache size for use in memory and string routines, typically

View file

@ -23,11 +23,10 @@
#include <dl-cacheinfo.h> #include <dl-cacheinfo.h>
#include <dl-minsigstacksize.h> #include <dl-minsigstacksize.h>
#if HAVE_TUNABLES
extern void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *) extern void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *)
attribute_hidden; attribute_hidden;
# ifdef __LP64__ #ifdef __LP64__
static void static void
TUNABLE_CALLBACK (set_prefer_map_32bit_exec) (tunable_val_t *valp) TUNABLE_CALLBACK (set_prefer_map_32bit_exec) (tunable_val_t *valp)
{ {
@ -35,17 +34,14 @@ TUNABLE_CALLBACK (set_prefer_map_32bit_exec) (tunable_val_t *valp)
GLRO(dl_x86_cpu_features).preferred[index_arch_Prefer_MAP_32BIT_EXEC] GLRO(dl_x86_cpu_features).preferred[index_arch_Prefer_MAP_32BIT_EXEC]
|= bit_arch_Prefer_MAP_32BIT_EXEC; |= bit_arch_Prefer_MAP_32BIT_EXEC;
} }
# endif #endif
# if CET_ENABLED #if CET_ENABLED
extern void TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *) extern void TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *)
attribute_hidden; attribute_hidden;
extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *) extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *)
attribute_hidden; attribute_hidden;
# endif
#endif
#if CET_ENABLED
# include <dl-cet.h> # include <dl-cet.h>
#endif #endif
@ -712,13 +708,12 @@ no_cpuid:
dl_init_cacheinfo (cpu_features); dl_init_cacheinfo (cpu_features);
#if HAVE_TUNABLES
TUNABLE_GET (hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps)); TUNABLE_GET (hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps));
# ifdef __LP64__ #ifdef __LP64__
TUNABLE_GET (prefer_map_32bit_exec, tunable_val_t *, TUNABLE_GET (prefer_map_32bit_exec, tunable_val_t *,
TUNABLE_CALLBACK (set_prefer_map_32bit_exec)); TUNABLE_CALLBACK (set_prefer_map_32bit_exec));
# endif #endif
bool disable_xsave_features = false; bool disable_xsave_features = false;
@ -774,13 +769,6 @@ no_cpuid:
CPU_FEATURE_UNSET (cpu_features, FMA4); CPU_FEATURE_UNSET (cpu_features, FMA4);
} }
#elif defined SHARED
/* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86. The
glibc.cpu.hwcap_mask tunable is initialized already, so no
need to do this. */
GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT;
#endif
#ifdef __x86_64__ #ifdef __x86_64__
GLRO(dl_hwcap) = HWCAP_X86_64; GLRO(dl_hwcap) = HWCAP_X86_64;
if (cpu_features->basic.kind == arch_kind_intel) if (cpu_features->basic.kind == arch_kind_intel)
@ -828,12 +816,10 @@ no_cpuid:
#endif #endif
#if CET_ENABLED #if CET_ENABLED
# if HAVE_TUNABLES
TUNABLE_GET (x86_ibt, tunable_val_t *, TUNABLE_GET (x86_ibt, tunable_val_t *,
TUNABLE_CALLBACK (set_x86_ibt)); TUNABLE_CALLBACK (set_x86_ibt));
TUNABLE_GET (x86_shstk, tunable_val_t *, TUNABLE_GET (x86_shstk, tunable_val_t *,
TUNABLE_CALLBACK (set_x86_shstk)); TUNABLE_CALLBACK (set_x86_shstk));
# endif
/* Check CET status. */ /* Check CET status. */
unsigned int cet_status = get_cet_status (); unsigned int cet_status = get_cet_status ();

View file

@ -16,31 +16,30 @@
License along with the GNU C Library; if not, see License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */ <https://www.gnu.org/licenses/>. */
#if HAVE_TUNABLES #define TUNABLE_NAMESPACE cpu
# define TUNABLE_NAMESPACE cpu #include <stdbool.h>
# include <stdbool.h> #include <stdint.h>
# include <stdint.h> #include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */
# include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ #include <elf/dl-tunables.h>
# include <elf/dl-tunables.h> #include <string.h>
# include <string.h> #include <cpu-features.h>
# include <cpu-features.h> #include <ldsodefs.h>
# include <ldsodefs.h>
/* We can't use IFUNC memcmp nor strlen in init_cpu_features from libc.a /* We can't use IFUNC memcmp nor strlen in init_cpu_features from libc.a
since IFUNC must be set up by init_cpu_features. */ since IFUNC must be set up by init_cpu_features. */
# if defined USE_MULTIARCH && !defined SHARED #if defined USE_MULTIARCH && !defined SHARED
# ifdef __x86_64__ # ifdef __x86_64__
/* DEFAULT_MEMCMP by sysdeps/x86_64/memcmp-isa-default-impl.h. */ /* DEFAULT_MEMCMP by sysdeps/x86_64/memcmp-isa-default-impl.h. */
# include <sysdeps/x86_64/memcmp-isa-default-impl.h> # include <sysdeps/x86_64/memcmp-isa-default-impl.h>
# else
# define DEFAULT_MEMCMP __memcmp_ia32
# endif
extern __typeof (memcmp) DEFAULT_MEMCMP;
# else # else
# define DEFAULT_MEMCMP memcmp # define DEFAULT_MEMCMP __memcmp_ia32
# endif # endif
extern __typeof (memcmp) DEFAULT_MEMCMP;
#else
# define DEFAULT_MEMCMP memcmp
#endif
# define CHECK_GLIBC_IFUNC_CPU_OFF(f, cpu_features, name, len) \ #define CHECK_GLIBC_IFUNC_CPU_OFF(f, cpu_features, name, len) \
_Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \ _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \
if (!DEFAULT_MEMCMP (f, #name, len)) \ if (!DEFAULT_MEMCMP (f, #name, len)) \
{ \ { \
@ -50,7 +49,7 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
/* Disable a preferred feature NAME. We don't enable a preferred feature /* Disable a preferred feature NAME. We don't enable a preferred feature
which isn't available. */ which isn't available. */
# define CHECK_GLIBC_IFUNC_PREFERRED_OFF(f, cpu_features, name, len) \ #define CHECK_GLIBC_IFUNC_PREFERRED_OFF(f, cpu_features, name, len) \
_Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \ _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \
if (!DEFAULT_MEMCMP (f, #name, len)) \ if (!DEFAULT_MEMCMP (f, #name, len)) \
{ \ { \
@ -60,7 +59,7 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
} }
/* Enable/disable a preferred feature NAME. */ /* Enable/disable a preferred feature NAME. */
# define CHECK_GLIBC_IFUNC_PREFERRED_BOTH(f, cpu_features, name, \ #define CHECK_GLIBC_IFUNC_PREFERRED_BOTH(f, cpu_features, name, \
disable, len) \ disable, len) \
_Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \ _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \
if (!DEFAULT_MEMCMP (f, #name, len)) \ if (!DEFAULT_MEMCMP (f, #name, len)) \
@ -74,7 +73,7 @@ extern __typeof (memcmp) DEFAULT_MEMCMP;
/* Enable/disable a preferred feature NAME. Enable a preferred feature /* Enable/disable a preferred feature NAME. Enable a preferred feature
only if the feature NEED is usable. */ only if the feature NEED is usable. */
# define CHECK_GLIBC_IFUNC_PREFERRED_NEED_BOTH(f, cpu_features, name, \ #define CHECK_GLIBC_IFUNC_PREFERRED_NEED_BOTH(f, cpu_features, name, \
need, disable, len) \ need, disable, len) \
_Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \ _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \
if (!DEFAULT_MEMCMP (f, #name, len)) \ if (!DEFAULT_MEMCMP (f, #name, len)) \
@ -286,8 +285,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
while (*c != '\0'); while (*c != '\0');
} }
# if CET_ENABLED #if CET_ENABLED
attribute_hidden attribute_hidden
void void
TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *valp) TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *valp)
@ -313,5 +311,4 @@ TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *valp)
sizeof ("permissive")) == 0) sizeof ("permissive")) == 0)
GL(dl_x86_feature_control).shstk = cet_permissive; GL(dl_x86_feature_control).shstk = cet_permissive;
} }
# endif
#endif #endif

View file

@ -760,10 +760,8 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
else if (non_temporal_threshold > maximum_non_temporal_threshold) else if (non_temporal_threshold > maximum_non_temporal_threshold)
non_temporal_threshold = maximum_non_temporal_threshold; non_temporal_threshold = maximum_non_temporal_threshold;
#if HAVE_TUNABLES
/* NB: The REP MOVSB threshold must be greater than VEC_SIZE * 8. */ /* NB: The REP MOVSB threshold must be greater than VEC_SIZE * 8. */
unsigned int minimum_rep_movsb_threshold; unsigned int minimum_rep_movsb_threshold;
#endif
/* NB: The default REP MOVSB threshold is 4096 * (VEC_SIZE / 16) for /* NB: The default REP MOVSB threshold is 4096 * (VEC_SIZE / 16) for
VEC_SIZE == 64 or 32. For VEC_SIZE == 16, the default REP MOVSB VEC_SIZE == 64 or 32. For VEC_SIZE == 16, the default REP MOVSB
threshold is 2048 * (VEC_SIZE / 16). */ threshold is 2048 * (VEC_SIZE / 16). */
@ -772,24 +770,18 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
&& !CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_No_AVX512)) && !CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_No_AVX512))
{ {
rep_movsb_threshold = 4096 * (64 / 16); rep_movsb_threshold = 4096 * (64 / 16);
#if HAVE_TUNABLES
minimum_rep_movsb_threshold = 64 * 8; minimum_rep_movsb_threshold = 64 * 8;
#endif
} }
else if (CPU_FEATURE_PREFERRED_P (cpu_features, else if (CPU_FEATURE_PREFERRED_P (cpu_features,
AVX_Fast_Unaligned_Load)) AVX_Fast_Unaligned_Load))
{ {
rep_movsb_threshold = 4096 * (32 / 16); rep_movsb_threshold = 4096 * (32 / 16);
#if HAVE_TUNABLES
minimum_rep_movsb_threshold = 32 * 8; minimum_rep_movsb_threshold = 32 * 8;
#endif
} }
else else
{ {
rep_movsb_threshold = 2048 * (16 / 16); rep_movsb_threshold = 2048 * (16 / 16);
#if HAVE_TUNABLES
minimum_rep_movsb_threshold = 16 * 8; minimum_rep_movsb_threshold = 16 * 8;
#endif
} }
/* NB: The default REP MOVSB threshold is 2112 on processors with fast /* NB: The default REP MOVSB threshold is 2112 on processors with fast
short REP MOVSB (FSRM). */ short REP MOVSB (FSRM). */
@ -799,7 +791,6 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
/* The default threshold to use Enhanced REP STOSB. */ /* The default threshold to use Enhanced REP STOSB. */
unsigned long int rep_stosb_threshold = 2048; unsigned long int rep_stosb_threshold = 2048;
#if HAVE_TUNABLES
long int tunable_size; long int tunable_size;
tunable_size = TUNABLE_GET (x86_data_cache_size, long int, NULL); tunable_size = TUNABLE_GET (x86_data_cache_size, long int, NULL);
@ -836,7 +827,6 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
minimum_rep_movsb_threshold, SIZE_MAX); minimum_rep_movsb_threshold, SIZE_MAX);
TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1, TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1,
SIZE_MAX); SIZE_MAX);
#endif
unsigned long int rep_movsb_stop_threshold; unsigned long int rep_movsb_stop_threshold;
/* ERMS feature is implemented from AMD Zen3 architecture and it is /* ERMS feature is implemented from AMD Zen3 architecture and it is

View file

@ -57,7 +57,6 @@ $(objpfx)tst-quad2pie: $(objpfx)tst-quadmod2pie.o
CFLAGS-tst-quad1pie.c = $(PIE-ccflag) CFLAGS-tst-quad1pie.c = $(PIE-ccflag)
CFLAGS-tst-quad2pie.c = $(PIE-ccflag) CFLAGS-tst-quad2pie.c = $(PIE-ccflag)
ifneq (no,$(have-tunables))
tests += tst-platform-1 tests += tst-platform-1
modules-names += tst-platformmod-1 x86_64/tst-platformmod-2 modules-names += tst-platformmod-1 x86_64/tst-platformmod-2
extra-test-objs += tst-platformmod-2.o extra-test-objs += tst-platformmod-2.o
@ -71,7 +70,6 @@ $(objpfx)tst-platform-1.out: $(objpfx)x86_64/tst-platformmod-2.so
# always set to x86_64. # always set to x86_64.
tst-platform-1-ENV = LD_PRELOAD=$(objpfx)\$$PLATFORM/tst-platformmod-2.so \ tst-platform-1-ENV = LD_PRELOAD=$(objpfx)\$$PLATFORM/tst-platformmod-2.so \
GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512F,-AVX2 GLIBC_TUNABLES=glibc.cpu.hwcaps=-AVX512F,-AVX2
endif
tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \ tests += tst-audit3 tst-audit4 tst-audit5 tst-audit6 tst-audit7 \
tst-audit10 tst-sse tst-avx tst-avx512 tst-audit10 tst-sse tst-avx tst-avx512