|
|
e354a5 |
commit 04bba1e5d84b6fd8d3a3b006bc240cd5d241ee30
|
|
|
e354a5 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
e354a5 |
Date: Wed Aug 5 13:51:56 2020 -0700
|
|
|
e354a5 |
|
|
|
e354a5 |
x86: Set CPU usable feature bits conservatively [BZ #26552]
|
|
|
e354a5 |
|
|
|
e354a5 |
Set CPU usable feature bits only for CPU features which are usable in
|
|
|
e354a5 |
user space and whose usability can be detected from user space, excluding
|
|
|
e354a5 |
features like FSGSBASE whose enable bit can only be checked in the kernel.
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
|
|
|
e354a5 |
index f13a1df4555c7000..6954728c47d0126b 100644
|
|
|
e354a5 |
--- a/sysdeps/x86/cpu-features.c
|
|
|
e354a5 |
+++ b/sysdeps/x86/cpu-features.c
|
|
|
e354a5 |
@@ -44,107 +44,55 @@ extern void TUNABLE_CALLBACK (set_x86_shstk) (tunable_val_t *)
|
|
|
e354a5 |
static void
|
|
|
e354a5 |
update_usable (struct cpu_features *cpu_features)
|
|
|
e354a5 |
{
|
|
|
e354a5 |
- /* Before COMMON_CPUID_INDEX_80000001, copy the cpuid array elements to
|
|
|
e354a5 |
- the usable array. */
|
|
|
e354a5 |
- unsigned int i;
|
|
|
e354a5 |
- for (i = 0; i < COMMON_CPUID_INDEX_80000001; i++)
|
|
|
e354a5 |
- cpu_features->features[i].usable = cpu_features->features[i].cpuid;
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- /* Before COMMON_CPUID_INDEX_80000001, clear the unknown usable bits
|
|
|
e354a5 |
- and the always zero bits. */
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_1_ECX_16);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_1_ECX_31);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_1_EDX_10);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_1_EDX_20);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_1_EDX_30);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EBX_6);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EBX_22);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_ECX_13);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_ECX_15);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_ECX_16);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_ECX_23);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_ECX_24);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_ECX_26);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_0);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_1);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_5);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_6);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_7);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_9);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_11);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_12);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_13);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_17);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_19);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_21);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_23);
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- /* EAX/EBX from COMMON_CPUID_INDEX_1 and EAX from COMMON_CPUID_INDEX_7
|
|
|
e354a5 |
- aren't used for CPU feature detection. */
|
|
|
e354a5 |
- cpu_features->features[COMMON_CPUID_INDEX_1].usable.eax = 0;
|
|
|
e354a5 |
- cpu_features->features[COMMON_CPUID_INDEX_1].usable.ebx = 0;
|
|
|
e354a5 |
- cpu_features->features[COMMON_CPUID_INDEX_7].usable.eax = 0;
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- /* Starting from COMMON_CPUID_INDEX_80000001, copy the cpuid bits to
|
|
|
e354a5 |
- usable bits. */
|
|
|
e354a5 |
+ /* Copy the cpuid bits to usable bits for CPU featuress whose usability
|
|
|
e354a5 |
+ in user space can be detected without additonal OS support. */
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SSE3);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, PCLMULQDQ);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SSSE3);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CMPXCHG16B);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SSE4_1);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SSE4_2);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, MOVBE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, POPCNT);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, AES);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, OSXSAVE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, TSC);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CX8);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CMOV);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CLFSH);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, MMX);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, FXSR);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SSE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SSE2);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, HTT);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, BMI1);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, HLE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, BMI2);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, ERMS);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, RTM);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, RDSEED);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, ADX);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CLFLUSHOPT);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CLWB);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SHA);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, PREFETCHWT1);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, OSPKE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, WAITPKG);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, GFNI);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, RDPID);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, CLDEMOTE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, MOVDIRI);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, MOVDIR64B);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, FSRM);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, SERIALIZE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, TSXLDTRK);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, LAHF64_SAHF64);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, SVM);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, LZCNT);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, SSE4A);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, PREFETCHW);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, XOP);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, LWP);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, FMA4);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, TBM);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, SYSCALL_SYSRET);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, NX);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, PAGE1GB);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, RDTSCP);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, LM);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, XSAVEOPT);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, XSAVEC);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, XGETBV_ECX_1);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, XSAVES);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, XFD);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, INVARIANT_TSC);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, WBNOINVD);
|
|
|
e354a5 |
- CPU_FEATURE_SET_USABLE (cpu_features, AVX512_BF16);
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- /* MPX has been deprecated. */
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, MPX);
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- /* Clear the usable bits which require OS support. */
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, FMA);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, F16C);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX2);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512F);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512DQ);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_IFMA);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512PF);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512ER);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512CD);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512BW);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512VL);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_VBMI);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, PKU);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_VBMI2);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, VAES);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, VPCLMULQDQ);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_VNNI);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_BITALG);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_VPOPCNTDQ);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_4VNNIW);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_4FMAPS);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_VP2INTERSECT);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AMX_BF16);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AMX_TILE);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AMX_INT8);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, XOP);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, FMA4);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, XSAVEC);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, XFD);
|
|
|
e354a5 |
- CPU_FEATURE_UNSET (cpu_features, AVX512_BF16);
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Can we call xgetbv? */
|
|
|
e354a5 |
if (CPU_FEATURES_CPU_P (cpu_features, OSXSAVE))
|
|
|
e354a5 |
@@ -243,8 +191,11 @@ update_usable (struct cpu_features *cpu_features)
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, AMX_INT8);
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
-
|
|
|
e354a5 |
- /* XFD is usable only when OSXSAVE is enabled. */
|
|
|
e354a5 |
+ /* These features are usable only when OSXSAVE is enabled. */
|
|
|
e354a5 |
+ CPU_FEATURE_SET (cpu_features, XSAVE);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, XSAVEOPT);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, XSAVEC);
|
|
|
e354a5 |
+ CPU_FEATURE_SET_USABLE (cpu_features, XGETBV_ECX_1);
|
|
|
e354a5 |
CPU_FEATURE_SET_USABLE (cpu_features, XFD);
|
|
|
e354a5 |
|
|
|
e354a5 |
/* For _dl_runtime_resolve, set xsave_state_size to xsave area
|