about summary refs log tree commit diff
path: root/sysdeps/x86/tst-cpu-features-cpuinfo.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2023-03-15 17:42:54 -0700
committerH.J. Lu <hjl.tools@gmail.com>2023-04-03 11:36:48 -0700
commit743113d42e6cad77477769a3de5542d33443ae76 (patch)
tree02f5ac20ff2715acfd54dd50fb670eb49ee43c94 /sysdeps/x86/tst-cpu-features-cpuinfo.c
parent5d1ccdda7b0c625751661d50977f3dfbc73f8eae (diff)
downloadglibc-743113d42e6cad77477769a3de5542d33443ae76.tar.gz
glibc-743113d42e6cad77477769a3de5542d33443ae76.tar.xz
glibc-743113d42e6cad77477769a3de5542d33443ae76.zip
x86: Set FSGSBASE to active if enabled by kernel
Linux kernel uses AT_HWCAP2 to indicate if FSGSBASE instructions are
enabled.  If the HWCAP2_FSGSBASE bit in AT_HWCAP2 is set, FSGSBASE
instructions can be used in user space.  Define dl_check_hwcap2 to set
the FSGSBASE feature to active on Linux when the HWCAP2_FSGSBASE bit is
set.

Add a test to verify that FSGSBASE is active on current kernels.
NB: This test will fail if the kernel doesn't set the HWCAP2_FSGSBASE
bit in AT_HWCAP2 while fsgsbase shows up in /proc/cpuinfo.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'sysdeps/x86/tst-cpu-features-cpuinfo.c')
-rw-r--r--sysdeps/x86/tst-cpu-features-cpuinfo.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/x86/tst-cpu-features-cpuinfo.c b/sysdeps/x86/tst-cpu-features-cpuinfo.c
index e963592c4b..18d64375ca 100644
--- a/sysdeps/x86/tst-cpu-features-cpuinfo.c
+++ b/sysdeps/x86/tst-cpu-features-cpuinfo.c
@@ -96,6 +96,11 @@ check_proc (const char *proc_name, const char *search_name, int flag,
 	      CPU_FEATURE_USABLE (name), \
 	      "HAS_CPU_FEATURE (" #name ")")
 
+#define CHECK_PROC_ACTIVE(str, name) \
+  check_proc (#str, " "#str" ", CPU_FEATURE_USABLE (name), \
+	      CPU_FEATURE_USABLE (name), \
+	      "CPU_FEATURE_USABLE (" #name ")")
+
 static int
 do_test (int argc, char **argv)
 {
@@ -298,6 +303,8 @@ do_test (int argc, char **argv)
   fails += CHECK_PROC (xsaves, XSAVES);
   fails += CHECK_PROC (xtpr, XTPRUPDCTRL);
 
+  fails += CHECK_PROC_ACTIVE (fsgsbase, FSGSBASE);
+
   printf ("%d differences between /proc/cpuinfo and glibc code.\n", fails);
 
   return (fails != 0);