]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Populate COMMON_CPUID_INDEX_80000001 for Intel CPUs [BZ #23459]
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 29 Jul 2018 13:08:59 +0000 (06:08 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 29 Jul 2018 13:30:59 +0000 (06:30 -0700)
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #23459]
* sysdeps/x86/cpu-features.c (get_extended_indices): New
function.
(init_cpu_features): Call get_extended_indices for both Intel
and AMD CPUs.
* sysdeps/x86/cpu-features.h (COMMON_CPUID_INDEX_80000001):
Remove "for AMD" comment.

(cherry picked from commit be525a69a6630abc83144c0a96474f2e26da7443)

ChangeLog
NEWS
sysdeps/x86/cpu-features.c
sysdeps/x86/cpu-features.h

index 7d88c08491a9f0056ec5bbad9191a77b13edb651..7fcb7d59810da1d4fbd911a4ffe03bba990454ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-07-29  H.J. Lu  <hongjiu.lu@intel.com>
+
+       [BZ #23459]
+       * sysdeps/x86/cpu-features.c (get_extended_indices): New
+       function.
+       (init_cpu_features): Call get_extended_indices for both Intel
+       and AMD CPUs.
+       * sysdeps/x86/cpu-features.h (COMMON_CPUID_INDEX_80000001):
+       Remove "for AMD" comment.
+
 2018-07-29  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #23456]
diff --git a/NEWS b/NEWS
index 7627bb0b6edff4d0f81b27c7fe24960e7b309900..bc150b63f95a91b2ccc3ad098b3d4ccf0b01d802 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -88,6 +88,7 @@ The following bugs are resolved with this release:
   [23349] Various glibc headers no longer compatible with <linux/time.h>
   [23363] stdio-common/tst-printf.c has non-free license
   [23456] Wrong index_cpu_LZCNT
+  [23459] COMMON_CPUID_INDEX_80000001 isn't populated for Intel processors
 
 \f
 Version 2.27
index 0fc3674c4b81f85af9a19228ed2b0e83e41511ab..122372862cbc8f95928b4f63cc2c822016f0057c 100644 (file)
@@ -30,6 +30,20 @@ extern void TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *)
   attribute_hidden;
 #endif
 
+static void
+get_extended_indices (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,
@@ -205,6 +219,8 @@ init_cpu_features (struct cpu_features *cpu_features)
       get_common_indeces (cpu_features, &family, &model, &extended_model,
                          &stepping);
 
+      get_extended_indices (cpu_features);
+
       if (family == 0x06)
        {
          model += extended_model;
@@ -324,16 +340,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_indices (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))
        {
index 906ad50920a74705a8c11d9e6663b81b6d3e0cb8..4588c110957018d426d1ec10602ccdf4ec9d91c3 100644 (file)
@@ -106,7 +106,7 @@ enum
   {
     COMMON_CPUID_INDEX_1 = 0,
     COMMON_CPUID_INDEX_7,
-    COMMON_CPUID_INDEX_80000001,       /* for AMD */
+    COMMON_CPUID_INDEX_80000001,
     /* Keep the following line at the end.  */
     COMMON_CPUID_INDEX_MAX
   };