diff options
author | Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> | 2023-03-23 10:13:51 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-03-29 14:33:06 -0300 |
commit | 33237fe83d553dff111915024c9670adc3f06048 (patch) | |
tree | 610ddd2195dca3c3901cfcc74f76e4ab6eb6c0e7 /elf | |
parent | 6384171fa0cef59b738ce8d0499fcea4f5009411 (diff) | |
download | glibc-33237fe83d553dff111915024c9670adc3f06048.zip glibc-33237fe83d553dff111915024c9670adc3f06048.tar.gz glibc-33237fe83d553dff111915024c9670adc3f06048.tar.bz2 |
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>
Diffstat (limited to 'elf')
-rw-r--r-- | elf/Makefile | 9 | ||||
-rw-r--r-- | elf/dl-cache.c | 2 | ||||
-rw-r--r-- | elf/dl-hwcaps.h | 11 | ||||
-rw-r--r-- | elf/dl-sort-maps.c | 7 | ||||
-rw-r--r-- | elf/dl-support.c | 15 | ||||
-rw-r--r-- | elf/dl-tls.c | 6 | ||||
-rw-r--r-- | elf/dl-tunables.c | 12 | ||||
-rw-r--r-- | elf/dl-tunables.h | 35 | ||||
-rw-r--r-- | elf/dl-usage.c | 8 | ||||
-rw-r--r-- | elf/rtld.c | 23 | ||||
-rw-r--r-- | elf/tst-env-setuid-tunables.c | 11 |
11 files changed, 17 insertions, 122 deletions
diff --git a/elf/Makefile b/elf/Makefile index 8cf46ba..396ec51 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -82,6 +82,7 @@ dl-routines = \ dl-tls \ dl-tls_init_tp \ dl-trampoline \ + dl-tunables \ dl-version \ dl-write \ # dl-routines @@ -90,11 +91,6 @@ ifeq (yes,$(use-ldconfig)) dl-routines += dl-cache 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)) tests-special += $(objpfx)list-tunables.out endif @@ -104,7 +100,6 @@ endif ifeq (yes,$(have-loop-to-function)) CFLAGS-dl-tunables.c += -fno-tree-loop-distribute-patterns endif -endif all-dl-routines = $(dl-routines) $(sysdep-dl-routines) # 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 # 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-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-c.so += -Wl,-z,lazy LDFLAGS-tst-bz15311-d.so += -Wl,-z,lazy -endif check-abi: $(objpfx)check-abi-ld.out \ $(objpfx)check-abi-version-libc.out diff --git a/elf/dl-cache.c b/elf/dl-cache.c index 07c054b..6312868 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -205,7 +205,7 @@ search_cache (const char *string_table, uint32_t string_table_size, uint64_t platform = _dl_string_platform (GLRO (dl_platform)); if (platform != (uint64_t) -1) 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) uint64_t hwcap_exclude = ~((GLRO (dl_hwcap) & hwcap_mask) | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK); diff --git a/elf/dl-hwcaps.h b/elf/dl-hwcaps.h index abe6aaf..3012ebf 100644 --- a/elf/dl-hwcaps.h +++ b/elf/dl-hwcaps.h @@ -24,17 +24,6 @@ #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_PREFIX GLIBC_HWCAPS_SUBDIRECTORY "/" diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c index 325e963..5616c8a 100644 --- a/elf/dl-sort-maps.c +++ b/elf/dl-sort-maps.c @@ -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 implementation, as well as faster execution speed. We already use 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 _dl_sort_maps_dfs (maps, nmaps, force_first, for_fini); } - -#endif /* HAVE_TUNABLES. */ diff --git a/elf/dl-support.c b/elf/dl-support.c index d2519ce..3225999 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -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. */ 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 * executable but this isn't true for all platforms. */ ElfW(Word) _dl_stack_flags = DEFAULT_STACK_PERMS; @@ -328,11 +318,6 @@ _dl_non_dynamic_init (void) __unsetenv (cp); cp = strchr (cp, '\0') + 1; } - -#if !HAVE_TUNABLES - if (__access ("/etc/suid-debug", F_OK) != 0) - __unsetenv ("MALLOC_CHECK_"); -#endif } #ifdef DL_PLATFORM_INIT diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 8943a3b..4ef7bc3 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -97,14 +97,8 @@ _dl_tls_static_surplus_init (size_t naudit) { size_t nns, opt_tls; -#if HAVE_TUNABLES nns = TUNABLE_GET (nns, 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) nns = DL_NNS; if (DL_NNS - nns < naudit) diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index 327b9eb..62b7332 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -38,11 +38,6 @@ #include <not-errno.h> -#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring -# define GLIBC_TUNABLES "GLIBC_TUNABLES" -#endif - -#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring static char * tunables_strdup (const char *in) { @@ -62,7 +57,6 @@ tunables_strdup (const char *in) return out; } -#endif static char ** 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); } -#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring /* 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 environment variable value for GLIBC_TUNABLES. VALSTRING is the original @@ -255,7 +248,6 @@ parse_tunables (char *tunestr, char *valstring) p += len + 1; } } -#endif /* 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 @@ -287,8 +279,7 @@ __tunables_init (char **envp) while ((envp = get_next_env (envp, &envname, &len, &envval, &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); if (new_env != NULL) @@ -297,7 +288,6 @@ __tunables_init (char **envp) *prev_envp = new_env; continue; } -#endif for (int i = 0; i < sizeof (tunable_list) / sizeof (tunable_t); i++) { diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h index ae6e014..45c191e 100644 --- a/elf/dl-tunables.h +++ b/elf/dl-tunables.h @@ -21,17 +21,9 @@ #ifndef _TUNABLES_H_ #define _TUNABLES_H_ -#if !HAVE_TUNABLES -static inline void -__always_inline -__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> +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> typedef intmax_t tunable_num_t; @@ -44,12 +36,12 @@ typedef union typedef void (*tunable_callback_t) (tunable_val_t *); /* 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_NAME1(__top,__ns,__id) __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 -# include "dl-tunable-list.h" +#include "dl-tunable-list.h" extern void __tunables_init (char **); 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 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); \ __type ret; \ @@ -92,14 +84,14 @@ rtld_hidden_proto (__tunable_set_val) }) /* 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_val_t) {.numval = __val}, NULL, NULL); \ }) /* 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_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 of the modules clean. */ -# 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 +#define TUNABLE_CALLBACK(__name) _dl_tunable_ ## __name static __always_inline bool 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 diff --git a/elf/dl-usage.c b/elf/dl-usage.c index 53535c1..98f0b0d 100644 --- a/elf/dl-usage.c +++ b/elf/dl-usage.c @@ -195,12 +195,8 @@ setting environment variables (which would be inherited by subprocesses).\n\ in LIST\n\ --audit LIST use objects named in LIST as auditors\n\ --preload LIST preload objects named in LIST\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" -#endif -"\ + --argv0 STRING set argv[0] to STRING before running\n\ + --list-tunables list all tunables with minimum and maximum values\n\ --list-diagnostics list diagnostics information\n\ --help display this help and exit\n\ --version output version information and exit\n\ @@ -357,9 +357,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro = ._dl_sysinfo = DL_SYSINFO_DEFAULT, #endif ._dl_debug_fd = STDERR_FILENO, -#if !HAVE_TUNABLES - ._dl_hwcap_mask = HWCAP_IMPORTANT, -#endif ._dl_lazy = 1, ._dl_fpu_control = _FPU_DEFAULT, ._dl_pagesize = EXEC_PAGESIZE, @@ -1483,7 +1480,6 @@ dl_main (const ElfW(Phdr) *phdr, _dl_argc -= 2; _dl_argv += 2; } -#if HAVE_TUNABLES else if (! strcmp (_dl_argv[1], "--list-tunables")) { state.mode = rtld_mode_list_tunables; @@ -1491,7 +1487,6 @@ dl_main (const ElfW(Phdr) *phdr, --_dl_argc; ++_dl_argv; } -#endif else if (! strcmp (_dl_argv[1], "--list-diagnostics")) { state.mode = rtld_mode_list_diagnostics; @@ -1519,13 +1514,11 @@ dl_main (const ElfW(Phdr) *phdr, else break; -#if HAVE_TUNABLES if (__glibc_unlikely (state.mode == rtld_mode_list_tunables)) { __tunables_print (); _exit (0); } -#endif if (state.mode == rtld_mode_list_diagnostics) _dl_print_diagnostics (_environ); @@ -2624,15 +2617,6 @@ process_envvars (struct dl_main_state *state) _dl_show_auxv (); 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: /* Path where the binary is found. */ if (!__libc_enable_secure @@ -2695,12 +2679,7 @@ process_envvars (struct dl_main_state *state) while (*nextp != '\0'); if (__access ("/etc/suid-debug", F_OK) != 0) - { -#if !HAVE_TUNABLES - unsetenv ("MALLOC_CHECK_"); -#endif - GLRO(dl_debug_mask) = 0; - } + GLRO(dl_debug_mask) = 0; if (state->mode != rtld_mode_normal) _exit (5); diff --git a/elf/tst-env-setuid-tunables.c b/elf/tst-env-setuid-tunables.c index 807b426..7dfb0e0 100644 --- a/elf/tst-env-setuid-tunables.c +++ b/elf/tst-env-setuid-tunables.c @@ -19,8 +19,6 @@ glibc.malloc.check and glibc.malloc.mmap_threshold but also retain 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 #include "config.h" #undef _LIBC @@ -83,7 +81,6 @@ test_child (int off) { const char *val = getenv ("GLIBC_TUNABLES"); -#if HAVE_TUNABLES if (val != NULL && strcmp (val, resultstrings[off]) == 0) return 0; @@ -91,14 +88,6 @@ test_child (int off) printf ("[%d] Unexpected GLIBC_TUNABLES VALUE %s\n", off, val); return 1; -#else - if (val != NULL) - { - printf ("[%d] GLIBC_TUNABLES not cleared\n", off); - return 1; - } - return 0; -#endif } static int |