Skip to contentSkip to conversation

x86/percpu: Enable named address spaces for all capable GCC versions

PATCH Applied Uros Bizjak 3 participants 4 messages May 20, 2024 – May 21, 2024 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/percpu: Enable named address spaces for all capable GCC versions

Enable named address spaces also for GCC 6, GCC 7 and GCC 8 releases. These compilers all produce kernel images that boot without problems.

Use compile-time test to detect compiler support for named address spaces. The test passes with GCC 6 as the earliest compiler version where the support for named address spaces was introduced.

Cc Ingo Molnar <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Josh Poimboeuf <[email protected]>
---
 arch/x86/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Kconfig +2 -1
index 9d16fee6bdb8..c9e0a54f469e 100644
@@ -2430,7 +2430,8 @@ source "kernel/livepatch/Kconfig"
 endmenu
 
 config CC_HAS_NAMED_AS
-	def_bool CC_IS_GCC && GCC_VERSION >= 90100
+	def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -S -o /dev/null)
+	depends on CC_IS_GCC
 
 config CC_HAS_NAMED_AS_FIXED_SANITIZERS
 	def_bool CC_IS_GCC && GCC_VERSION >= 130300
Signature · 1 line
2.45.1
#1 lore raw
Quoted 28 lines · Uros Bizjak

Enable named address spaces also for GCC 6, GCC 7 and GCC 8 releases. These compilers all produce kernel images that boot without problems.

Use compile-time test to detect compiler support for named address spaces. The test passes with GCC 6 as the earliest compiler version where the support for named address spaces was introduced.

Cc Ingo Molnar <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Josh Poimboeuf <[email protected]>
---
 arch/x86/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Kconfig +0 -0
index 9d16fee6bdb8..c9e0a54f469e 100644

arch/x86/Kconfig source "kernel/livepatch/Kconfig" · line 2434

Quoted 6 lines
arch/x86/Kconfig +2 -1
@@ -2430,7 +2430,8 @@ source "kernel/livepatch/Kconfig"
 endmenu
 
 config CC_HAS_NAMED_AS
-	def_bool CC_IS_GCC && GCC_VERSION >= 90100
+	def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -S -o /dev/null)
+	depends on CC_IS_GCC

So ... will this test also trigger on Clang, which might have a __seg_fs/__seg_gs work-alike definition?

Thanks,

Ingo

#2 lore raw
Quoted 34 lines · Ingo Molnar
Quoted 30 lines · Uros Bizjak

Enable named address spaces also for GCC 6, GCC 7 and GCC 8 releases. These compilers all produce kernel images that boot without problems.

Use compile-time test to detect compiler support for named address spaces. The test passes with GCC 6 as the earliest compiler version where the support for named address spaces was introduced.

Cc Ingo Molnar <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Brian Gerst <[email protected]>
Cc Denys Vlasenko <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Josh Poimboeuf <[email protected]>
---
 arch/x86/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Kconfig +0 -0
index 9d16fee6bdb8..c9e0a54f469e 100644
@@ -2430,7 +2430,8 @@ source "kernel/livepatch/Kconfig"
 endmenu
 
Quoted 7 lines

arch/x86/Kconfig source "kernel/livepatch/Kconfig" · line 2434

Quoted 4 lines
arch/x86/Kconfig +2 -1
 config CC_HAS_NAMED_AS
-     def_bool CC_IS_GCC && GCC_VERSION >= 90100
+     def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -S -o /dev/null)
+     depends on CC_IS_GCC

So ... will this test also trigger on Clang, which might have a __seg_fs/__seg_gs work-alike definition?

Yes, but please note the dependence on CC_IS_GCC. This dependence can be removed once CLANG is tested to create correct code for named AS.

Thanks,
Uros.

merge bot Applied
#3 lore raw
In reply to Uros Bizjak
The following commit has been merged into the x86/percpu branch of tip:

The following commit has been merged into the x86/percpu branch of tip:

Commit-ID:     47ff30cc1be7bf426c03ecc84371452109b416e4
Gitweb:        https://git.kernel.org/tip/47ff30cc1be7bf426c03ecc84371452109b416e4
Author:        Uros Bizjak <[email protected]>
AuthorDate:    Mon, 20 May 2024 10:21:14 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 21 May 2024 10:17:01 +02:00

x86/percpu: Enable named address spaces for all capable GCC versions

Enable named address spaces also for GCC 6, GCC 7 and GCC 8 releases. These compilers all produce kernel images that boot without problems.

Use compile-time test to detect compiler support for named address spaces. The test passes with GCC 6 as the earliest compiler version where the support for named address spaces was introduced.

---
 arch/x86/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/Kconfig +2 -1
index 9d16fee..c9e0a54 100644
@@ -2430,7 +2430,8 @@ source "kernel/livepatch/Kconfig"
 endmenu
 
 config CC_HAS_NAMED_AS
-	def_bool CC_IS_GCC && GCC_VERSION >= 90100
+	def_bool $(success,echo 'int __seg_fs fs; int __seg_gs gs;' | $(CC) -x c - -S -o /dev/null)
+	depends on CC_IS_GCC
 
 config CC_HAS_NAMED_AS_FIXED_SANITIZERS
 	def_bool CC_IS_GCC && GCC_VERSION >= 130300