diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index d7248cbb45..6262b03cd4 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -40,7 +40,7 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *) #endif static void -update_usable (struct cpu_features *cpu_features) +copy_usable (struct cpu_features *cpu_features) { /* Copy the cpuid bits to usable bits for CPU featuress whose usability in user space can be detected without additonal OS support. */ @@ -98,9 +98,13 @@ update_usable (struct cpu_features *cpu_features) CPU_FEATURE_SET_USABLE (cpu_features, FSRS); CPU_FEATURE_SET_USABLE (cpu_features, FSRCS); CPU_FEATURE_SET_USABLE (cpu_features, PTWRITE); +} +static void +update_usable (struct cpu_features *cpu_features) +{ /* Can we call xgetbv? */ - if (CPU_FEATURES_CPU_P (cpu_features, OSXSAVE)) + if (CPU_FEATURE_USABLE_P (cpu_features, OSXSAVE)) { unsigned int xcrlow; unsigned int xcrhigh; @@ -420,8 +424,6 @@ init_cpu_features (struct cpu_features *cpu_features) get_extended_indices (cpu_features); - update_usable (cpu_features); - if (family == 0x06) { model += extended_model; @@ -547,8 +549,6 @@ init_cpu_features (struct cpu_features *cpu_features) get_extended_indices (cpu_features); - update_usable (cpu_features); - ecx = cpu_features->features[CPUID_INDEX_1].cpuid.ecx; if (CPU_FEATURE_USABLE_P (cpu_features, AVX)) @@ -586,8 +586,6 @@ init_cpu_features (struct cpu_features *cpu_features) get_extended_indices (cpu_features); - update_usable (cpu_features); - model += extended_model; if (family == 0x6) { @@ -630,7 +628,6 @@ init_cpu_features (struct cpu_features *cpu_features) { kind = arch_kind_other; get_common_indices (cpu_features, NULL, NULL, NULL, NULL); - update_usable (cpu_features); } /* Support i586 if CX8 is available. */ @@ -652,6 +649,8 @@ no_cpuid: dl_init_cacheinfo (cpu_features); + copy_usable (cpu_features); + #if HAVE_TUNABLES TUNABLE_GET (hwcaps, tunable_val_t *, TUNABLE_CALLBACK (set_hwcaps)); #elif defined SHARED @@ -661,6 +660,8 @@ no_cpuid: GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT; #endif + update_usable (cpu_features); + #ifdef __x86_64__ GLRO(dl_hwcap) = HWCAP_X86_64; if (cpu_features->basic.kind == arch_kind_intel)