x86: Set FSGSBASE to active if enabled by kernel
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Mar 2023 00:42:54 +0000 (17:42 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 3 Apr 2023 18:36:48 +0000 (11:36 -0700)
commit743113d42e6cad77477769a3de5542d33443ae76
tree02f5ac20ff2715acfd54dd50fb670eb49ee43c94
parent5d1ccdda7b0c625751661d50977f3dfbc73f8eae
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>
sysdeps/unix/sysv/linux/x86/dl-hwcap2.h [new file with mode: 0644]
sysdeps/x86/cpu-features.c
sysdeps/x86/dl-hwcap2.h [new file with mode: 0644]
sysdeps/x86/tst-cpu-features-cpuinfo.c