From patchwork Mon Nov 30 17:04:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 9845 Received: (qmail 60801 invoked by alias); 30 Nov 2015 17:04:33 -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 60790 invoked by uid 89); 30 Nov 2015 17:04:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f169.google.com MIME-Version: 1.0 X-Received: by 10.60.40.133 with SMTP id x5mr44613556oek.34.1448903069503; Mon, 30 Nov 2015 09:04:29 -0800 (PST) In-Reply-To: References: <563B276D.4010403@redhat.com> Date: Mon, 30 Nov 2015 09:04:29 -0800 Message-ID: Subject: Re: [PATCH] Fixed family and model detection for AMD CPU's From: "H.J. Lu" To: "Pawar, Amit" Cc: Joseph Myers , Florian Weimer , "libc-alpha@sourceware.org" On Tue, Nov 24, 2015 at 9:17 PM, Pawar, Amit wrote: > Changes are done as per the suggestion. Can you or someone please apply this attached patch on behalf of me? > This is what I checked in with ChangeLog entries. Please provide proper ChangeLog entries next time. From 9627da32ec76600244e7723e99b9d4e27691f1ff Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 30 Nov 2015 08:53:37 -0800 Subject: [PATCH] Update family and model detection for AMD CPUs AMD CPUs uses the similar encoding scheme for extended family and model as Intel CPUs as shown in: http://support.amd.com/TechDocs/25481.pdf This patch updates get_common_indeces to get family and model for both Intel and AMD CPUs when family == 0x0f. [BZ #19214] * sysdeps/x86/cpu-features.c (get_common_indeces): Add an argument to return extended model. Update family and model with extended family and model when family == 0x0f. (init_cpu_features): Updated. --- ChangeLog | 8 ++++++++ sysdeps/x86/cpu-features.c | 27 +++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b769a0e..038181c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-11-30 Amit Pawar + + [BZ #19214] + * sysdeps/x86/cpu-features.c (get_common_indeces): Add an + argument to return extended model. Update family and model + with extended family and model when family == 0x0f. + (init_cpu_features): Updated. + 2015-11-29 Samuel Thibault The RPC interface used by mmap uses the unsigned vm_offset_t, not the diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index b03451d..fba3ef0 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -21,7 +21,8 @@ static inline void get_common_indeces (struct cpu_features *cpu_features, - unsigned int *family, unsigned int *model) + unsigned int *family, unsigned int *model, + unsigned int *extended_model) { unsigned int eax; __cpuid (1, eax, cpu_features->cpuid[COMMON_CPUID_INDEX_1].ebx, @@ -30,6 +31,12 @@ get_common_indeces (struct cpu_features *cpu_features, GLRO(dl_x86_cpu_features).cpuid[COMMON_CPUID_INDEX_1].eax = eax; *family = (eax >> 8) & 0x0f; *model = (eax >> 4) & 0x0f; + *extended_model = (eax >> 12) & 0xf0; + if (*family == 0x0f) + { + *family += (eax >> 20) & 0xff; + *model += *extended_model; + } } static inline void @@ -53,19 +60,13 @@ init_cpu_features (struct cpu_features *cpu_features) /* This spells out "GenuineIntel". */ if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) { + unsigned int extended_model; + kind = arch_kind_intel; - get_common_indeces (cpu_features, &family, &model); + get_common_indeces (cpu_features, &family, &model, &extended_model); - unsigned int eax = cpu_features->cpuid[COMMON_CPUID_INDEX_1].eax; - unsigned int extended_family = (eax >> 20) & 0xff; - unsigned int extended_model = (eax >> 12) & 0xf0; - if (family == 0x0f) - { - family += extended_family; - model += extended_model; - } - else if (family == 0x06) + if (family == 0x06) { ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx; model += extended_model; @@ -132,9 +133,11 @@ init_cpu_features (struct cpu_features *cpu_features) /* This spells out "AuthenticAMD". */ else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) { + unsigned int extended_model; + kind = arch_kind_amd; - get_common_indeces (cpu_features, &family, &model); + get_common_indeces (cpu_features, &family, &model, &extended_model); ecx = cpu_features->cpuid[COMMON_CPUID_INDEX_1].ecx; -- 2.5.0