diff options
Diffstat (limited to 'sysdeps/x86')
-rw-r--r-- | sysdeps/x86/Makefile | 10 | ||||
-rw-r--r-- | sysdeps/x86/cacheinfo.h | 8 | ||||
-rw-r--r-- | sysdeps/x86/cpu-features.c | 24 | ||||
-rw-r--r-- | sysdeps/x86/cpu-tunables.c | 45 | ||||
-rw-r--r-- | sysdeps/x86/dl-cacheinfo.h | 10 |
5 files changed, 29 insertions, 68 deletions
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index 56fd5fc805..917c26f116 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -25,7 +25,6 @@ tests-static += \ tst-ifunc-isa-1-static test-xfail-tst-ifunc-isa-1 = $(with-lld) test-xfail-tst-ifunc-isa-1-static = $(with-lld) -ifneq ($(have-tunables),no) tests += \ tst-ifunc-isa-2 \ 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) endif endif -endif ifeq (yes,$(enable-x86-isa-level)) tests += tst-isa-level-1 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-v4.so endif -ifneq ($(have-tunables),no) 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) endif -endif ifeq ($(subdir),math) tests += tst-ldbl-nonnormal-printf @@ -79,12 +75,10 @@ ifeq ($(subdir),setjmp) gen-as-const-headers += jmp_buf-ssp.sym sysdep_routines += __longjmp_cancel ifneq ($(enable-cet),no) -ifneq ($(have-tunables),no) tests += tst-setjmp-cet tst-setjmp-cet-ENV = GLIBC_TUNABLES=glibc.cpu.x86_ibt=on:glibc.cpu.x86_shstk=on endif endif -endif ifeq ($(subdir),string) 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 tests-static += tst-cet-legacy-9-static tst-cet-legacy-10-static 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 \ tst-cet-legacy-5b tst-cet-legacy-6b -endif 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-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-6b.so: $(objpfx)tst-cet-legacy-mod-6c.so 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 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 @@ -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-static-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK endif -endif # Add -fcf-protection to CFLAGS when CET is enabled. CFLAGS-.o += -fcf-protection diff --git a/sysdeps/x86/cacheinfo.h b/sysdeps/x86/cacheinfo.h index 7a99e04b73..ec1bc142c4 100644 --- a/sysdeps/x86/cacheinfo.h +++ b/sysdeps/x86/cacheinfo.h @@ -21,11 +21,9 @@ #include <cpuid.h> #include <cpu-features.h> -#if HAVE_TUNABLES -# define TUNABLE_NAMESPACE cpu -# include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ -# include <elf/dl-tunables.h> -#endif +#define TUNABLE_NAMESPACE cpu +#include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ +#include <elf/dl-tunables.h> #if IS_IN (libc) /* Data cache size for use in memory and string routines, typically diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 822688e21f..978eb29f72 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -23,11 +23,10 @@ #include <dl-cacheinfo.h> #include <dl-minsigstacksize.h> -#if HAVE_TUNABLES extern void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *) attribute_hidden; -# ifdef __LP64__ +#ifdef __LP64__ static void 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] |= bit_arch_Prefer_MAP_32BIT_EXEC; } -# endif +#endif -# if CET_ENABLED +#if CET_ENABLED extern void TUNABLE_CALLBACK (set_x86_ibt) (tunable_val_t *) attribute_hidden; extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *) attribute_hidden; -# endif -#endif -#if CET_ENABLED # include <dl-cet.h> #endif @@ -712,13 +708,12 @@ no_cpuid: dl_init_cacheinfo (cpu_features); -#if HAVE_TUNABLES TUNABLE_GET (hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps)); -# ifdef __LP64__ +#ifdef __LP64__ TUNABLE_GET (prefer_map_32bit_exec, tunable_val_t *, TUNABLE_CALLBACK (set_prefer_map_32bit_exec)); -# endif +#endif bool disable_xsave_features = false; @@ -774,13 +769,6 @@ no_cpuid: 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__ GLRO(dl_hwcap) = HWCAP_X86_64; if (cpu_features->basic.kind == arch_kind_intel) @@ -828,12 +816,10 @@ no_cpuid: #endif #if CET_ENABLED -# if HAVE_TUNABLES TUNABLE_GET (x86_ibt, tunable_val_t *, TUNABLE_CALLBACK (set_x86_ibt)); TUNABLE_GET (x86_shstk, tunable_val_t *, TUNABLE_CALLBACK (set_x86_shstk)); -# endif /* Check CET status. */ unsigned int cet_status = get_cet_status (); diff --git a/sysdeps/x86/cpu-tunables.c b/sysdeps/x86/cpu-tunables.c index 772fb0c4c2..0d4f328585 100644 --- a/sysdeps/x86/cpu-tunables.c +++ b/sysdeps/x86/cpu-tunables.c @@ -16,31 +16,30 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ -#if HAVE_TUNABLES -# define TUNABLE_NAMESPACE cpu -# include <stdbool.h> -# include <stdint.h> -# include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ -# include <elf/dl-tunables.h> -# include <string.h> -# include <cpu-features.h> -# include <ldsodefs.h> +#define TUNABLE_NAMESPACE cpu +#include <stdbool.h> +#include <stdint.h> +#include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */ +#include <elf/dl-tunables.h> +#include <string.h> +#include <cpu-features.h> +#include <ldsodefs.h> /* 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. */ -# if defined USE_MULTIARCH && !defined SHARED -# ifdef __x86_64__ +#if defined USE_MULTIARCH && !defined SHARED +# ifdef __x86_64__ /* DEFAULT_MEMCMP by 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; +# include <sysdeps/x86_64/memcmp-isa-default-impl.h> # else -# define DEFAULT_MEMCMP memcmp +# define DEFAULT_MEMCMP __memcmp_ia32 # 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); \ 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 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); \ if (!DEFAULT_MEMCMP (f, #name, len)) \ { \ @@ -60,7 +59,7 @@ extern __typeof (memcmp) DEFAULT_MEMCMP; } /* 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) \ _Static_assert (sizeof (#name) - 1 == len, #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 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) \ _Static_assert (sizeof (#name) - 1 == len, #name " != " #len); \ if (!DEFAULT_MEMCMP (f, #name, len)) \ @@ -286,8 +285,7 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp) while (*c != '\0'); } -# if CET_ENABLED - +#if CET_ENABLED attribute_hidden void 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) GL(dl_x86_feature_control).shstk = cet_permissive; } -# endif #endif diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index a0474af8d1..ab671487da 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -760,10 +760,8 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) else if (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. */ unsigned int minimum_rep_movsb_threshold; -#endif /* 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 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)) { rep_movsb_threshold = 4096 * (64 / 16); -#if HAVE_TUNABLES minimum_rep_movsb_threshold = 64 * 8; -#endif } else if (CPU_FEATURE_PREFERRED_P (cpu_features, AVX_Fast_Unaligned_Load)) { rep_movsb_threshold = 4096 * (32 / 16); -#if HAVE_TUNABLES minimum_rep_movsb_threshold = 32 * 8; -#endif } else { rep_movsb_threshold = 2048 * (16 / 16); -#if HAVE_TUNABLES minimum_rep_movsb_threshold = 16 * 8; -#endif } /* NB: The default REP MOVSB threshold is 2112 on processors with fast short REP MOVSB (FSRM). */ @@ -799,7 +791,6 @@ dl_init_cacheinfo (struct cpu_features *cpu_features) /* The default threshold to use Enhanced REP STOSB. */ unsigned long int rep_stosb_threshold = 2048; -#if HAVE_TUNABLES long int tunable_size; 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); TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1, SIZE_MAX); -#endif unsigned long int rep_movsb_stop_threshold; /* ERMS feature is implemented from AMD Zen3 architecture and it is |