From patchwork Thu Jul 26 18:07:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 28636 Received: (qmail 58948 invoked by alias); 26 Jul 2018 18:08:04 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 58935 invoked by uid 89); 26 Jul 2018 18:08:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=3549, Hx-languages-length:2114, family X-HELO: mga09.intel.com From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459] Date: Thu, 26 Jul 2018 11:07:47 -0700 Message-Id: <20180726180747.15087-1-hjl.tools@gmail.com> [BZ #23459] * sysdeps/x86/cpu-features.c (get_extended_indeces): New function. (init_cpu_features): Call get_extended_indeces for both Intel and AMD CPUs. Reviewed-by: Carlos O'Donell --- sysdeps/x86/cpu-features.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 8108256c42..f8beb96e51 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -42,6 +42,20 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *) # include #endif +static void +get_extended_indeces (struct cpu_features *cpu_features) +{ + unsigned int eax, ebx, ecx, edx; + __cpuid (0x80000000, eax, ebx, ecx, edx); + if (eax >= 0x80000001) + __cpuid (0x80000001, + cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax, + cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx, + cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx, + cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx); + +} + static void get_common_indeces (struct cpu_features *cpu_features, unsigned int *family, unsigned int *model, @@ -224,6 +238,8 @@ init_cpu_features (struct cpu_features *cpu_features) get_common_indeces (cpu_features, &family, &model, &extended_model, &stepping); + get_extended_indeces (cpu_features); + if (family == 0x06) { model += extended_model; @@ -338,16 +354,9 @@ init_cpu_features (struct cpu_features *cpu_features) get_common_indeces (cpu_features, &family, &model, &extended_model, &stepping); - ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx; + get_extended_indeces (cpu_features); - unsigned int eax; - __cpuid (0x80000000, eax, ebx, ecx, edx); - if (eax >= 0x80000001) - __cpuid (0x80000001, - cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].eax, - cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ebx, - cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx, - cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx); + ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx; if (HAS_ARCH_FEATURE (AVX_Usable)) {