b1dca6
commit 94cd37ebb293321115a36a422b091fdb72d2fb08
b1dca6
Author: H.J. Lu <hjl.tools@gmail.com>
b1dca6
Date:   Wed Sep 16 05:27:32 2020 -0700
b1dca6
b1dca6
    x86: Use HAS_CPU_FEATURE with IBT and SHSTK [BZ #26625]
b1dca6
    
b1dca6
    commit 04bba1e5d84b6fd8d3a3b006bc240cd5d241ee30
b1dca6
    Author: H.J. Lu <hjl.tools@gmail.com>
b1dca6
    Date:   Wed Aug 5 13:51:56 2020 -0700
b1dca6
    
b1dca6
        x86: Set CPU usable feature bits conservatively [BZ #26552]
b1dca6
    
b1dca6
        Set CPU usable feature bits only for CPU features which are usable in
b1dca6
        user space and whose usability can be detected from user space, excluding
b1dca6
        features like FSGSBASE whose enable bit can only be checked in the kernel.
b1dca6
    
b1dca6
    no longer turns on the usable bits of IBT and SHSTK since we don't know
b1dca6
    if IBT and SHSTK are usable until much later.  Use HAS_CPU_FEATURE to
b1dca6
    check if the processor supports IBT and SHSTK.
b1dca6
b1dca6
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
b1dca6
index 77a596a15404b575..7f2ff00f2b4b45f2 100644
b1dca6
--- a/sysdeps/x86/cpu-features.c
b1dca6
+++ b/sysdeps/x86/cpu-features.c
b1dca6
@@ -722,9 +722,9 @@ no_cpuid:
b1dca6
 	     GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
b1dca6
 	   */
b1dca6
 	  unsigned int cet_feature = 0;
b1dca6
-	  if (!CPU_FEATURE_USABLE (IBT))
b1dca6
+	  if (!HAS_CPU_FEATURE (IBT))
b1dca6
 	    cet_feature |= GNU_PROPERTY_X86_FEATURE_1_IBT;
b1dca6
-	  if (!CPU_FEATURE_USABLE (SHSTK))
b1dca6
+	  if (!HAS_CPU_FEATURE (SHSTK))
b1dca6
 	    cet_feature |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
b1dca6
 
b1dca6
 	  if (cet_feature)
b1dca6
diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c
b1dca6
index 11ff0618fae7230f..d481bddc27e5d7cc 100644
b1dca6
--- a/sysdeps/x86/dl-cet.c
b1dca6
+++ b/sysdeps/x86/dl-cet.c
b1dca6
@@ -74,10 +74,10 @@ dl_cet_check (struct link_map *m, const char *program)
b1dca6
 
b1dca6
 	     GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK
b1dca6
 	   */
b1dca6
-	  enable_ibt &= (CPU_FEATURE_USABLE (IBT)
b1dca6
+	  enable_ibt &= (HAS_CPU_FEATURE (IBT)
b1dca6
 			 && (enable_ibt_type == cet_always_on
b1dca6
 			     || (m->l_cet & lc_ibt) != 0));
b1dca6
-	  enable_shstk &= (CPU_FEATURE_USABLE (SHSTK)
b1dca6
+	  enable_shstk &= (HAS_CPU_FEATURE (SHSTK)
b1dca6
 			   && (enable_shstk_type == cet_always_on
b1dca6
 			       || (m->l_cet & lc_shstk) != 0));
b1dca6
 	}
b1dca6
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
b1dca6
index c01d701b52090983..3ec94e0c9a191f36 100644
b1dca6
--- a/sysdeps/x86/tst-get-cpu-features.c
b1dca6
+++ b/sysdeps/x86/tst-get-cpu-features.c
b1dca6
@@ -318,7 +318,6 @@ do_test (void)
b1dca6
   CHECK_CPU_FEATURE_USABLE (OSPKE);
b1dca6
   CHECK_CPU_FEATURE_USABLE (WAITPKG);
b1dca6
   CHECK_CPU_FEATURE_USABLE (AVX512_VBMI2);
b1dca6
-  CHECK_CPU_FEATURE_USABLE (SHSTK);
b1dca6
   CHECK_CPU_FEATURE_USABLE (GFNI);
b1dca6
   CHECK_CPU_FEATURE_USABLE (VAES);
b1dca6
   CHECK_CPU_FEATURE_USABLE (VPCLMULQDQ);
b1dca6
@@ -342,7 +341,6 @@ do_test (void)
b1dca6
   CHECK_CPU_FEATURE_USABLE (HYBRID);
b1dca6
   CHECK_CPU_FEATURE_USABLE (TSXLDTRK);
b1dca6
   CHECK_CPU_FEATURE_USABLE (PCONFIG);
b1dca6
-  CHECK_CPU_FEATURE_USABLE (IBT);
b1dca6
   CHECK_CPU_FEATURE_USABLE (AMX_BF16);
b1dca6
   CHECK_CPU_FEATURE_USABLE (AMX_TILE);
b1dca6
   CHECK_CPU_FEATURE_USABLE (AMX_INT8);