about summary refs log tree commit diff
path: root/sysdeps/x86/tst-get-cpu-features.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-06-17 06:34:46 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-06-22 13:09:33 -0700
commitecbbadbf107ea1155ae5b71a8b7bd48f38c76731 (patch)
treeedc19a18074492532661cf40364d633ac39e75b8 /sysdeps/x86/tst-get-cpu-features.c
parentea04f0213135b13d80f568ca2c4127c2ec112537 (diff)
downloadglibc-ecbbadbf107ea1155ae5b71a8b7bd48f38c76731.tar.gz
glibc-ecbbadbf107ea1155ae5b71a8b7bd48f38c76731.tar.xz
glibc-ecbbadbf107ea1155ae5b71a8b7bd48f38c76731.zip
x86: Update CPU feature detection [BZ #26149]
1. Divide architecture features into the usable features and the preferred
features.  The usable features are for correctness and can be exported in
a stable ABI.  The preferred features are for performance and only for
glibc internal use.
2. Change struct cpu_features to

struct cpu_features
{
  struct cpu_features_basic basic;
  unsigned int *usable_p;
  struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX];
  unsigned int usable[USABLE_FEATURE_INDEX_MAX];
  unsigned int preferred[PREFERRED_FEATURE_INDEX_MAX];
  ...
};

and initialize usable_p to pointer to the usable arary so that

struct cpu_features
{
  struct cpu_features_basic basic;
  unsigned int *usable_p;
  struct cpuid_registers cpuid[COMMON_CPUID_INDEX_MAX];
};

can be exported via a stable ABI.  The cpuid and usable arrays can be
expanded with backward binary compatibility for both .o and .so files.
3. Add COMMON_CPUID_INDEX_7_ECX_1 for AVX512_BF16.
4. Detect ENQCMD, PKS, AVX512_VP2INTERSECT, MD_CLEAR, SERIALIZE, HYBRID,
TSXLDTRK, L1D_FLUSH, CORE_CAPABILITIES and AVX512_BF16.
5. Rename CAPABILITIES to ARCH_CAPABILITIES.
6. Check if AVX512_VP2INTERSECT, AVX512_BF16 and PKU are usable.
7. Update CPU feature detection test.
Diffstat (limited to 'sysdeps/x86/tst-get-cpu-features.c')
-rw-r--r--sysdeps/x86/tst-get-cpu-features.c67
1 files changed, 14 insertions, 53 deletions
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index 0dcb906a86..c60918cf00 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -174,15 +174,24 @@ do_test (void)
   CHECK_CPU_FEATURE (CLDEMOTE);
   CHECK_CPU_FEATURE (MOVDIRI);
   CHECK_CPU_FEATURE (MOVDIR64B);
+  CHECK_CPU_FEATURE (ENQCMD);
   CHECK_CPU_FEATURE (SGX_LC);
+  CHECK_CPU_FEATURE (PKS);
   CHECK_CPU_FEATURE (AVX512_4VNNIW);
   CHECK_CPU_FEATURE (AVX512_4FMAPS);
   CHECK_CPU_FEATURE (FSRM);
+  CHECK_CPU_FEATURE (AVX512_VP2INTERSECT);
+  CHECK_CPU_FEATURE (MD_CLEAR);
+  CHECK_CPU_FEATURE (SERIALIZE);
+  CHECK_CPU_FEATURE (HYBRID);
+  CHECK_CPU_FEATURE (TSXLDTRK);
   CHECK_CPU_FEATURE (PCONFIG);
   CHECK_CPU_FEATURE (IBT);
   CHECK_CPU_FEATURE (IBRS_IBPB);
   CHECK_CPU_FEATURE (STIBP);
-  CHECK_CPU_FEATURE (CAPABILITIES);
+  CHECK_CPU_FEATURE (L1D_FLUSH);
+  CHECK_CPU_FEATURE (ARCH_CAPABILITIES);
+  CHECK_CPU_FEATURE (CORE_CAPABILITIES);
   CHECK_CPU_FEATURE (SSBD);
   CHECK_CPU_FEATURE (LAHF64_SAHF64);
   CHECK_CPU_FEATURE (SVM);
@@ -204,84 +213,36 @@ do_test (void)
   CHECK_CPU_FEATURE (XSAVES);
   CHECK_CPU_FEATURE (INVARIANT_TSC);
   CHECK_CPU_FEATURE (WBNOINVD);
+  CHECK_CPU_FEATURE (AVX512_BF16);
 
   printf ("Usable CPU features:\n");
-  CHECK_CPU_FEATURE_USABLE (SSE3);
-  CHECK_CPU_FEATURE_USABLE (PCLMULQDQ);
-  CHECK_CPU_FEATURE_USABLE (SSSE3);
   CHECK_CPU_FEATURE_USABLE (FMA);
-  CHECK_CPU_FEATURE_USABLE (CMPXCHG16B);
-  CHECK_CPU_FEATURE_USABLE (SSE4_1);
-  CHECK_CPU_FEATURE_USABLE (SSE4_2);
-  CHECK_CPU_FEATURE_USABLE (MOVBE);
-  CHECK_CPU_FEATURE_USABLE (POPCNT);
-  CHECK_CPU_FEATURE_USABLE (AES);
-  CHECK_CPU_FEATURE_USABLE (XSAVE);
-  CHECK_CPU_FEATURE_USABLE (OSXSAVE);
   CHECK_CPU_FEATURE_USABLE (AVX);
   CHECK_CPU_FEATURE_USABLE (F16C);
-  CHECK_CPU_FEATURE_USABLE (RDRAND);
-  CHECK_CPU_FEATURE_USABLE (FPU);
-  CHECK_CPU_FEATURE_USABLE (TSC);
-  CHECK_CPU_FEATURE_USABLE (MSR);
-  CHECK_CPU_FEATURE_USABLE (CX8);
-  CHECK_CPU_FEATURE_USABLE (SEP);
-  CHECK_CPU_FEATURE_USABLE (CMOV);
-  CHECK_CPU_FEATURE_USABLE (CLFSH);
-  CHECK_CPU_FEATURE_USABLE (MMX);
-  CHECK_CPU_FEATURE_USABLE (FXSR);
-  CHECK_CPU_FEATURE_USABLE (SSE);
-  CHECK_CPU_FEATURE_USABLE (SSE2);
-  CHECK_CPU_FEATURE_USABLE (FSGSBASE);
-  CHECK_CPU_FEATURE_USABLE (BMI1);
-  CHECK_CPU_FEATURE_USABLE (HLE);
   CHECK_CPU_FEATURE_USABLE (AVX2);
-  CHECK_CPU_FEATURE_USABLE (BMI2);
-  CHECK_CPU_FEATURE_USABLE (ERMS);
   CHECK_CPU_FEATURE_USABLE (AVX512F);
   CHECK_CPU_FEATURE_USABLE (AVX512DQ);
-  CHECK_CPU_FEATURE_USABLE (RDSEED);
-  CHECK_CPU_FEATURE_USABLE (ADX);
   CHECK_CPU_FEATURE_USABLE (AVX512_IFMA);
-  CHECK_CPU_FEATURE_USABLE (CLFLUSHOPT);
-  CHECK_CPU_FEATURE_USABLE (CLWB);
   CHECK_CPU_FEATURE_USABLE (AVX512PF);
   CHECK_CPU_FEATURE_USABLE (AVX512ER);
   CHECK_CPU_FEATURE_USABLE (AVX512CD);
-  CHECK_CPU_FEATURE_USABLE (SHA);
   CHECK_CPU_FEATURE_USABLE (AVX512BW);
   CHECK_CPU_FEATURE_USABLE (AVX512VL);
-  CHECK_CPU_FEATURE_USABLE (PREFETCHWT1);
   CHECK_CPU_FEATURE_USABLE (AVX512_VBMI);
+  CHECK_CPU_FEATURE_USABLE (PKU);
   CHECK_CPU_FEATURE_USABLE (AVX512_VBMI2);
-  CHECK_CPU_FEATURE_USABLE (GFNI);
   CHECK_CPU_FEATURE_USABLE (VAES);
   CHECK_CPU_FEATURE_USABLE (VPCLMULQDQ);
   CHECK_CPU_FEATURE_USABLE (AVX512_VNNI);
   CHECK_CPU_FEATURE_USABLE (AVX512_BITALG);
   CHECK_CPU_FEATURE_USABLE (AVX512_VPOPCNTDQ);
-  CHECK_CPU_FEATURE_USABLE (RDPID);
-  CHECK_CPU_FEATURE_USABLE (CLDEMOTE);
-  CHECK_CPU_FEATURE_USABLE (MOVDIRI);
-  CHECK_CPU_FEATURE_USABLE (MOVDIR64B);
   CHECK_CPU_FEATURE_USABLE (AVX512_4VNNIW);
   CHECK_CPU_FEATURE_USABLE (AVX512_4FMAPS);
-  CHECK_CPU_FEATURE_USABLE (FSRM);
-  CHECK_CPU_FEATURE_USABLE (LAHF64_SAHF64);
-  CHECK_CPU_FEATURE_USABLE (LZCNT);
-  CHECK_CPU_FEATURE_USABLE (SSE4A);
-  CHECK_CPU_FEATURE_USABLE (PREFETCHW);
+  CHECK_CPU_FEATURE_USABLE (AVX512_VP2INTERSECT);
   CHECK_CPU_FEATURE_USABLE (XOP);
   CHECK_CPU_FEATURE_USABLE (FMA4);
-  CHECK_CPU_FEATURE_USABLE (TBM);
-  CHECK_CPU_FEATURE_USABLE (SYSCALL_SYSRET);
-  CHECK_CPU_FEATURE_USABLE (RDTSCP);
-  CHECK_CPU_FEATURE_USABLE (XSAVEOPT);
   CHECK_CPU_FEATURE_USABLE (XSAVEC);
-  CHECK_CPU_FEATURE_USABLE (XGETBV_ECX_1);
-  CHECK_CPU_FEATURE_USABLE (XSAVES);
-  CHECK_CPU_FEATURE_USABLE (INVARIANT_TSC);
-  CHECK_CPU_FEATURE_USABLE (WBNOINVD);
+  CHECK_CPU_FEATURE_USABLE (AVX512_BF16);
 
   return 0;
 }