diff mbox series

x86: Adjust tst-cpu-features-supports.c for GCC 11

Message ID 20201204002135.1609087-1-hjl.tools@gmail.com
State Superseded
Headers show
Series x86: Adjust tst-cpu-features-supports.c for GCC 11 | expand

Commit Message

H.J. Lu Dec. 4, 2020, 12:21 a.m. UTC
Set RDRAND usable if CPU supports RDRAND.  Also check HAS_CPU_FEATURE
instead of CPU_FEATURE_USABLE for FSGSBASE, LM and XSAVES since
FSGSBASE/LM require kernel support and XSAVES is supervisor-mode only.
---
 sysdeps/x86/cpu-features.c              |  1 +
 sysdeps/x86/tst-cpu-features-supports.c | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

Comments

Florian Weimer Dec. 4, 2020, 8:11 a.m. UTC | #1
* H. J. Lu via Libc-alpha:

> Set RDRAND usable if CPU supports RDRAND.  Also check HAS_CPU_FEATURE
> instead of CPU_FEATURE_USABLE for FSGSBASE, LM and XSAVES since
> FSGSBASE/LM require kernel support and XSAVES is supervisor-mode only.

I think the commit subject is misleading because the RDRAND part is a
glibc bug fix.  Rest looks okay to me.

Thanks,
Florian
diff mbox series

Patch

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index f26deba38d..fe080b63b2 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -85,6 +85,7 @@  update_usable (struct cpu_features *cpu_features)
   CPU_FEATURE_SET_USABLE (cpu_features, WAITPKG);
   CPU_FEATURE_SET_USABLE (cpu_features, GFNI);
   CPU_FEATURE_SET_USABLE (cpu_features, RDPID);
+  CPU_FEATURE_SET_USABLE (cpu_features, RDRAND);
   CPU_FEATURE_SET_USABLE (cpu_features, CLDEMOTE);
   CPU_FEATURE_SET_USABLE (cpu_features, MOVDIRI);
   CPU_FEATURE_SET_USABLE (cpu_features, MOVDIR64B);
diff --git a/sysdeps/x86/tst-cpu-features-supports.c b/sysdeps/x86/tst-cpu-features-supports.c
index bf881b531f..7c7a953458 100644
--- a/sysdeps/x86/tst-cpu-features-supports.c
+++ b/sysdeps/x86/tst-cpu-features-supports.c
@@ -40,6 +40,11 @@  check_supports (int supports, int usable, const char *supports_name,
 #define CHECK_SUPPORTS(str, name) \
   check_supports (__builtin_cpu_supports (#str), \
 		  CPU_FEATURE_USABLE (name), \
+		  #str, "CPU_FEATURE_USABLE (" #name ")");
+
+#define CHECK_CPU_SUPPORTS(str, name) \
+  check_supports (__builtin_cpu_supports (#str), \
+		  HAS_CPU_FEATURE (name), \
 		  #str, "HAS_CPU_FEATURE (" #name ")");
 
 static int
@@ -118,7 +123,7 @@  do_test (int argc, char **argv)
   fails += CHECK_SUPPORTS (fma4, FMA4);
 #endif
 #if __GNUC_PREREQ (11, 0)
-  fails += CHECK_SUPPORTS (fsgsbase, FSGSBASE);
+  fails += CHECK_CPU_SUPPORTS (fsgsbase, FSGSBASE);
   fails += CHECK_SUPPORTS (fxsave, FXSR);
 #endif
 #if __GNUC_PREREQ (8, 0)
@@ -128,7 +133,7 @@  do_test (int argc, char **argv)
   fails += CHECK_SUPPORTS (hle, HLE);
   fails += CHECK_SUPPORTS (ibt, IBT);
   fails += CHECK_SUPPORTS (lahf_lm, LAHF64_SAHF64);
-  fails += CHECK_SUPPORTS (lm, LM);
+  fails += CHECK_CPU_SUPPORTS (lm, LM);
   fails += CHECK_SUPPORTS (lwp, LWP);
   fails += CHECK_SUPPORTS (lzcnt, LZCNT);
 #endif
@@ -180,7 +185,7 @@  do_test (int argc, char **argv)
   fails += CHECK_SUPPORTS (xsave, XSAVE);
   fails += CHECK_SUPPORTS (xsavec, XSAVEC);
   fails += CHECK_SUPPORTS (xsaveopt, XSAVEOPT);
-  fails += CHECK_SUPPORTS (xsaves, XSAVES);
+  fails += CHECK_CPU_SUPPORTS (xsaves, XSAVES);
 #endif
 
   printf ("%d differences between __builtin_cpu_supports and glibc code.\n",