From 4d916f0f12b230f49967797f98b2b613c734a047 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 19 Oct 2017 08:28:09 -0700 Subject: x86-64: Don't set GLRO(dl_platform) to NULL [BZ #22299] Since ld.so expands $PLATFORM with GLRO(dl_platform), don't set GLRO(dl_platform) to NULL. [BZ #22299] * sysdeps/x86/cpu-features.c (init_cpu_features): Don't set GLRO(dl_platform) to NULL. * sysdeps/x86_64/Makefile (tests): Add tst-platform-1. (modules-names): Add tst-platformmod-1 and x86_64/tst-platformmod-2. (CFLAGS-tst-platform-1.c): New. (CFLAGS-tst-platformmod-1.c): Likewise. (CFLAGS-tst-platformmod-2.c): Likewise. (LDFLAGS-tst-platformmod-2.so): Likewise. ($(objpfx)tst-platform-1): Likewise. ($(objpfx)tst-platform-1.out): Likewise. (tst-platform-1-ENV): Likewise. ($(objpfx)x86_64/tst-platformmod-2.os): Likewise. * sysdeps/x86_64/tst-platform-1.c: New file. * sysdeps/x86_64/tst-platformmod-1.c: Likewise. * sysdeps/x86_64/tst-platformmod-2.c: Likewise. --- sysdeps/x86/cpu-features.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sysdeps/x86/cpu-features.c') diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index c267f17b76..332b0f0d4a 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -335,7 +335,6 @@ no_cpuid: #endif /* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86. */ - GLRO(dl_platform) = NULL; #if !HAVE_TUNABLES && defined SHARED /* The glibc.tune.hwcap_mask tunable is initialized already, so no need to do this. */ @@ -346,13 +345,15 @@ no_cpuid: GLRO(dl_hwcap) = HWCAP_X86_64; if (cpu_features->kind == arch_kind_intel) { + const char *platform = NULL; + if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable) && CPU_FEATURES_CPU_P (cpu_features, AVX512CD)) { if (CPU_FEATURES_CPU_P (cpu_features, AVX512ER)) { if (CPU_FEATURES_CPU_P (cpu_features, AVX512PF)) - GLRO(dl_platform) = "xeon_phi"; + platform = "xeon_phi"; } else { @@ -363,7 +364,7 @@ no_cpuid: } } - if (GLRO(dl_platform) == NULL + if (platform == NULL && CPU_FEATURES_ARCH_P (cpu_features, AVX2_Usable) && CPU_FEATURES_ARCH_P (cpu_features, FMA_Usable) && CPU_FEATURES_CPU_P (cpu_features, BMI1) @@ -371,7 +372,10 @@ no_cpuid: && CPU_FEATURES_CPU_P (cpu_features, LZCNT) && CPU_FEATURES_CPU_P (cpu_features, MOVBE) && CPU_FEATURES_CPU_P (cpu_features, POPCNT)) - GLRO(dl_platform) = "haswell"; + platform = "haswell"; + + if (platform != NULL) + GLRO(dl_platform) = platform; } #else GLRO(dl_hwcap) = 0; -- cgit 1.4.1