This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fixed family and model detection for AMD CPU's
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Pawar, Amit" <Amit dot Pawar at amd dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, Florian Weimer <fweimer at redhat dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Tue, 24 Nov 2015 05:22:41 -0800
- Subject: Re: [PATCH] Fixed family and model detection for AMD CPU's
- Authentication-results: sourceware.org; auth=none
- References: <SN1PR12MB0733CCE45E6F9B965769E21E97290 at SN1PR12MB0733 dot namprd12 dot prod dot outlook dot com> <563B276D dot 4010403 at redhat dot com> <SN1PR12MB07330D19C8A7EE7224462F2E97290 at SN1PR12MB0733 dot namprd12 dot prod dot outlook dot com> <alpine dot DEB dot 2 dot 10 dot 1511051246260 dot 4094 at digraph dot polyomino dot org dot uk> <SN1PR12MB0733D57468171C5370FEA01297060 at SN1PR12MB0733 dot namprd12 dot prod dot outlook dot com>
On Tue, Nov 24, 2015 at 2:58 AM, Pawar, Amit <Amit.Pawar@amd.com> wrote:
> Please find the attached recreated patch to this mail. Bugzilla ID included in Glibc Changelog and git commit log.
>
> Problem: In GLIBC Family and model values detection are incorrect.
> Why this fix?
> Based on arch ISA flags string and memory routines are selected. In future patches, will be defining ISA flags based on family
> and model values which will help in selecting the correct string or memory routines.
>
> Is it OK to apply?
>
Try this one instead.
--
H.J.
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;