x86: Adjust tst-cpu-features-supports.c for GCC 11
Commit Message
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
* 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
@@ -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);
@@ -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",