b1dca6
commit 32ac0b988466785d6e3cc1dffc364bb26fc63193
b1dca6
Author: mayshao <mayshao-oc@zhaoxin.com>
b1dca6
Date:   Fri Apr 24 12:55:38 2020 +0800
b1dca6
b1dca6
    x86: Add CPU Vendor ID detection support for Zhaoxin processors
b1dca6
    
b1dca6
    To recognize Zhaoxin CPU Vendor ID, add a new architecture type
b1dca6
    arch_kind_zhaoxin for Vendor Zhaoxin detection.
b1dca6
b1dca6
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
b1dca6
index ade37a9bb3de86cc..c432d646ce6806a6 100644
b1dca6
--- a/sysdeps/x86/cpu-features.c
b1dca6
+++ b/sysdeps/x86/cpu-features.c
b1dca6
@@ -464,6 +464,60 @@ init_cpu_features (struct cpu_features *cpu_features)
b1dca6
 	  }
b1dca6
 	}
b1dca6
     }
b1dca6
+  /* This spells out "CentaurHauls" or " Shanghai ".  */
b1dca6
+  else if ((ebx == 0x746e6543 && ecx == 0x736c7561 && edx == 0x48727561)
b1dca6
+	   || (ebx == 0x68532020 && ecx == 0x20206961 && edx == 0x68676e61))
b1dca6
+    {
b1dca6
+      unsigned int extended_model, stepping;
b1dca6
+
b1dca6
+      kind = arch_kind_zhaoxin;
b1dca6
+
b1dca6
+      get_common_indices (cpu_features, &family, &model, &extended_model,
b1dca6
+			  &stepping);
b1dca6
+
b1dca6
+      get_extended_indices (cpu_features);
b1dca6
+
b1dca6
+      model += extended_model;
b1dca6
+      if (family == 0x6)
b1dca6
+        {
b1dca6
+          if (model == 0xf || model == 0x19)
b1dca6
+            {
b1dca6
+              cpu_features->feature[index_arch_AVX_Usable]
b1dca6
+                &= (~bit_arch_AVX_Usable
b1dca6
+                & ~bit_arch_AVX2_Usable);
b1dca6
+
b1dca6
+              cpu_features->feature[index_arch_Slow_SSE4_2]
b1dca6
+                |= (bit_arch_Slow_SSE4_2);
b1dca6
+
b1dca6
+              cpu_features->feature[index_arch_AVX_Fast_Unaligned_Load]
b1dca6
+                &= ~bit_arch_AVX_Fast_Unaligned_Load;
b1dca6
+            }
b1dca6
+        }
b1dca6
+      else if (family == 0x7)
b1dca6
+        {
b1dca6
+          if (model == 0x1b)
b1dca6
+            {
b1dca6
+              cpu_features->feature[index_arch_AVX_Usable]
b1dca6
+                &= (~bit_arch_AVX_Usable
b1dca6
+                & ~bit_arch_AVX2_Usable);
b1dca6
+
b1dca6
+              cpu_features->feature[index_arch_Slow_SSE4_2]
b1dca6
+                |= bit_arch_Slow_SSE4_2;
b1dca6
+
b1dca6
+              cpu_features->feature[index_arch_AVX_Fast_Unaligned_Load]
b1dca6
+                &= ~bit_arch_AVX_Fast_Unaligned_Load;
b1dca6
+           }
b1dca6
+         else if (model == 0x3b)
b1dca6
+           {
b1dca6
+             cpu_features->feature[index_arch_AVX_Usable]
b1dca6
+               &= (~bit_arch_AVX_Usable
b1dca6
+               & ~bit_arch_AVX2_Usable);
b1dca6
+
b1dca6
+               cpu_features->feature[index_arch_AVX_Fast_Unaligned_Load]
b1dca6
+               &= ~bit_arch_AVX_Fast_Unaligned_Load;
b1dca6
+           }
b1dca6
+       }
b1dca6
+    }
b1dca6
   else
b1dca6
     {
b1dca6
       kind = arch_kind_other;
b1dca6
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
b1dca6
index 4917182e99a8ee90..388172a1c07bf979 100644
b1dca6
--- a/sysdeps/x86/cpu-features.h
b1dca6
+++ b/sysdeps/x86/cpu-features.h
b1dca6
@@ -53,6 +53,7 @@ enum cpu_features_kind
b1dca6
   arch_kind_unknown = 0,
b1dca6
   arch_kind_intel,
b1dca6
   arch_kind_amd,
b1dca6
+  arch_kind_zhaoxin,
b1dca6
   arch_kind_other
b1dca6
 };
b1dca6