diff mbox series

V8 [PATCH 1/2] x86: Clear some CPU usable feature bits

Message ID 20200805230137.3572872-1-hjl.tools@gmail.com
State Committed
Headers show
Series V8 [PATCH 1/2] x86: Clear some CPU usable feature bits | expand

Commit Message

H.J. Lu Aug. 5, 2020, 11:01 p.m. UTC
Clear CPU usable feature bits which may require consulting processor
manual to determine how to use them in user space.
---
 sysdeps/x86/cpu-features.c | 59 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 4c24ba7c31..5641a8293b 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -79,6 +79,64 @@  update_usable (struct cpu_features *cpu_features)
   CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_21);
   CPU_FEATURE_UNSET (cpu_features, INDEX_7_EDX_23);
 
+  /* Before COMMON_CPUID_INDEX_80000001, clear the usable bits which may
+     require consulting processor manual to determine how to use them in
+     user space.  */
+  CPU_FEATURE_UNSET (cpu_features, DTES64);
+  CPU_FEATURE_UNSET (cpu_features, DS_CPL);
+  CPU_FEATURE_UNSET (cpu_features, VMX);
+  CPU_FEATURE_UNSET (cpu_features, SMX);
+  CPU_FEATURE_UNSET (cpu_features, EIST);
+  CPU_FEATURE_UNSET (cpu_features, TM2);
+  CPU_FEATURE_UNSET (cpu_features, CNXT_ID);
+  CPU_FEATURE_UNSET (cpu_features, SDBG);
+  CPU_FEATURE_UNSET (cpu_features, XTPRUPDCTRL);
+  CPU_FEATURE_UNSET (cpu_features, PDCM);
+  CPU_FEATURE_UNSET (cpu_features, PCID);
+  CPU_FEATURE_UNSET (cpu_features, DCA);
+  CPU_FEATURE_UNSET (cpu_features, X2APIC);
+  CPU_FEATURE_UNSET (cpu_features, TSC_DEADLINE);
+  CPU_FEATURE_UNSET (cpu_features, VME);
+  CPU_FEATURE_UNSET (cpu_features, DE);
+  CPU_FEATURE_UNSET (cpu_features, PSE);
+  CPU_FEATURE_UNSET (cpu_features, PAE);
+  CPU_FEATURE_UNSET (cpu_features, MCE);
+  CPU_FEATURE_UNSET (cpu_features, APIC);
+  CPU_FEATURE_UNSET (cpu_features, MTRR);
+  CPU_FEATURE_UNSET (cpu_features, PGE);
+  CPU_FEATURE_UNSET (cpu_features, MCA);
+  CPU_FEATURE_UNSET (cpu_features, PAT);
+  CPU_FEATURE_UNSET (cpu_features, PSE_36);
+  CPU_FEATURE_UNSET (cpu_features, DS);
+  CPU_FEATURE_UNSET (cpu_features, ACPI);
+  CPU_FEATURE_UNSET (cpu_features, SS);
+  CPU_FEATURE_UNSET (cpu_features, TM);
+  CPU_FEATURE_UNSET (cpu_features, PBE);
+  CPU_FEATURE_UNSET (cpu_features, TSC_ADJUST);
+  CPU_FEATURE_UNSET (cpu_features, SGX);
+  CPU_FEATURE_UNSET (cpu_features, HLE);
+  CPU_FEATURE_UNSET (cpu_features, SMEP);
+  CPU_FEATURE_UNSET (cpu_features, RTM);
+  CPU_FEATURE_UNSET (cpu_features, RDT_M);
+  CPU_FEATURE_UNSET (cpu_features, DEPR_FPU_CS_DS);
+  CPU_FEATURE_UNSET (cpu_features, RDT_A);
+  CPU_FEATURE_UNSET (cpu_features, SMAP);
+  CPU_FEATURE_UNSET (cpu_features, TRACE);
+  CPU_FEATURE_UNSET (cpu_features, UMIP);
+  CPU_FEATURE_UNSET (cpu_features, SHSTK);
+  CPU_FEATURE_UNSET (cpu_features, SGX_LC);
+  CPU_FEATURE_UNSET (cpu_features, PKS);
+  CPU_FEATURE_UNSET (cpu_features, MD_CLEAR);
+  CPU_FEATURE_UNSET (cpu_features, HYBRID);
+  CPU_FEATURE_UNSET (cpu_features, PCONFIG);
+  CPU_FEATURE_UNSET (cpu_features, IBT);
+  CPU_FEATURE_UNSET (cpu_features, IBRS_IBPB);
+  CPU_FEATURE_UNSET (cpu_features, STIBP);
+  CPU_FEATURE_UNSET (cpu_features, L1D_FLUSH);
+  CPU_FEATURE_UNSET (cpu_features, ARCH_CAPABILITIES);
+  CPU_FEATURE_UNSET (cpu_features, CORE_CAPABILITIES);
+  CPU_FEATURE_UNSET (cpu_features, SSBD);
+
   /* EAX/EBX from COMMON_CPUID_INDEX_1 and EAX from COMMON_CPUID_INDEX_7
      aren't used for CPU feature detection.  */
   cpu_features->features[COMMON_CPUID_INDEX_1].usable.eax = 0;
@@ -106,7 +164,6 @@  update_usable (struct cpu_features *cpu_features)
   CPU_FEATURE_SET_USABLE (cpu_features, XGETBV_ECX_1);
   CPU_FEATURE_SET_USABLE (cpu_features, XSAVES);
   CPU_FEATURE_SET_USABLE (cpu_features, XFD);
-  CPU_FEATURE_SET_USABLE (cpu_features, INVARIANT_TSC);
   CPU_FEATURE_SET_USABLE (cpu_features, WBNOINVD);
   CPU_FEATURE_SET_USABLE (cpu_features, AVX512_BF16);