93dc2d
commit b952c25dc7adf0684c53ad72d1d667da0348c929
93dc2d
Author: H.J. Lu <hjl.tools@gmail.com>
93dc2d
Date:   Fri Jan 14 14:48:01 2022 -0800
93dc2d
93dc2d
    x86: Black list more Intel CPUs for TSX [BZ #27398]
93dc2d
    
93dc2d
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
93dc2d
    
93dc2d
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
93dc2d
    
93dc2d
    This fixes BZ #27398.
93dc2d
    
93dc2d
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
93dc2d
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
93dc2d
93dc2d
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
93dc2d
index 645bba63147f6589..de4e3c3b7258120d 100644
93dc2d
--- a/sysdeps/x86/cpu-features.c
93dc2d
+++ b/sysdeps/x86/cpu-features.c
93dc2d
@@ -507,11 +507,39 @@ init_cpu_features (struct cpu_features *cpu_features)
93dc2d
 	      break;
93dc2d
 	    }
93dc2d
 
93dc2d
-	 /* Disable TSX on some Haswell processors to avoid TSX on kernels that
93dc2d
-	    weren't updated with the latest microcode package (which disables
93dc2d
-	    broken feature by default).  */
93dc2d
+	 /* Disable TSX on some processors to avoid TSX on kernels that
93dc2d
+	    weren't updated with the latest microcode package (which
93dc2d
+	    disables broken feature by default).  */
93dc2d
 	 switch (model)
93dc2d
 	    {
93dc2d
+	    case 0x55:
93dc2d
+	      if (stepping <= 5)
93dc2d
+		goto disable_tsx;
93dc2d
+	      break;
93dc2d
+	    case 0x8e:
93dc2d
+	      /* NB: Although the errata documents that for model == 0x8e,
93dc2d
+		 only 0xb stepping or lower are impacted, the intention of
93dc2d
+		 the errata was to disable TSX on all client processors on
93dc2d
+		 all steppings.  Include 0xc stepping which is an Intel
93dc2d
+		 Core i7-8665U, a client mobile processor.  */
93dc2d
+	    case 0x9e:
93dc2d
+	      if (stepping > 0xc)
93dc2d
+		break;
93dc2d
+	      /* Fall through.  */
93dc2d
+	    case 0x4e:
93dc2d
+	    case 0x5e:
93dc2d
+	      {
93dc2d
+		/* Disable Intel TSX and enable RTM_ALWAYS_ABORT for
93dc2d
+		   processors listed in:
93dc2d
+
93dc2d
+https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
93dc2d
+		 */
93dc2d
+disable_tsx:
93dc2d
+		CPU_FEATURE_UNSET (cpu_features, HLE);
93dc2d
+		CPU_FEATURE_UNSET (cpu_features, RTM);
93dc2d
+		CPU_FEATURE_SET (cpu_features, RTM_ALWAYS_ABORT);
93dc2d
+	      }
93dc2d
+	      break;
93dc2d
 	    case 0x3f:
93dc2d
 	      /* Xeon E7 v3 with stepping >= 4 has working TSX.  */
93dc2d
 	      if (stepping >= 4)