[RFC,2/4] x86/percpu: Detect compiler support for named address spaces

Message ID 20231001131620.112484-3-ubizjak@gmail.com
State New
Headers
Series x86/percpu: Use segment qualifiers |

Commit Message

Uros Bizjak Oct. 1, 2023, 1:14 p.m. UTC
  Detect compiler support for named address spaces by trying
to compile a small testcase that includes __seg_gs and __seg_gs
keywords. Reflect successful compilation in CC_HAS_NAMED_AS
and set USE_X86_SEG_SUPPORT to signal when segment qualifiers
should be used.

Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Nadav Amit <namit@vmware.com>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
 arch/x86/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
  

Patch

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 66bfabae8814..f66fa5bf1f78 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2388,6 +2388,13 @@  source "kernel/livepatch/Kconfig"
 
 endmenu
 
+config CC_HAS_NAMED_AS
+	def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -c -o /dev/null)
+
+config USE_X86_SEG_SUPPORT
+	def_bool y
+	depends on CC_HAS_NAMED_AS && SMP
+
 config CC_HAS_SLS
 	def_bool $(cc-option,-mharden-sls=all)