]> git.baikalelectronics.ru Git - kernel.git/commit
x86/elf: Enumerate kernel FSGSBASE capability in AT_HWCAP2
authorAndi Kleen <ak@linux.intel.com>
Wed, 8 May 2019 10:02:32 +0000 (03:02 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Sat, 22 Jun 2019 09:38:56 +0000 (11:38 +0200)
commit90ec9e6ab5bbee4725687f7663b33d95f334276f
tree020613ca17ce3dd51f1d2a8e75704d1a086512b1
parentcfec649c19dc7121bcc7b5a9f76114689777c562
x86/elf: Enumerate kernel FSGSBASE capability in AT_HWCAP2

The kernel needs to explicitly enable FSGSBASE. So, the application needs
to know if it can safely use these instructions. Just looking at the CPUID
bit is not enough because it may be running in a kernel that does not
enable the instructions.

One way for the application would be to just try and catch the SIGILL.
But that is difficult to do in libraries which may not want to overwrite
the signal handlers of the main application.

Enumerate the enabled FSGSBASE capability in bit 1 of AT_HWCAP2 in the ELF
aux vector. AT_HWCAP2 is already used by PPC for similar purposes.

The application can access it open coded or by using the getauxval()
function in newer versions of glibc.

[ tglx: Massaged changelog ]

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Link: https://lkml.kernel.org/r/1557309753-24073-18-git-send-email-chang.seok.bae@intel.com
arch/x86/include/uapi/asm/hwcap2.h
arch/x86/kernel/cpu/common.c