Skip to contentSkip to conversation

x86/percpu: Fix "multiple identical address spaces specified for type" clang warning

PATCH RESEND New Uros Bizjak 1 participant 1 message Jun 10, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 x86/percpu: Fix "multiple identical address spaces specified for type" clang warning

The clang build with named address spaces enabled currently fails with:

error: multiple identical address spaces specified for type [-Werror,-Wduplicate-decl-specifier]

The warning is emitted when accessing const_pcpu_hot structure, which is already declared in __seg_gs named address space.

Use specialized accessor for __raw_cpu_read_const() instead, avoiding redeclaring __seg_gs named address space via __raw_cpu_read().

Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Bill Wendling <[email protected]>
Cc Justin Stitt <[email protected]>
---
 arch/x86/include/asm/percpu.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/include/asm/percpu.h +4 -1
index c55a79d5feae..aeea5c8a17de 100644
@@ -160,7 +160,10 @@ do {									\
 	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val);	\
 } while (0)
 
-#define __raw_cpu_read_const(pcp)	__raw_cpu_read(, , pcp)
+#define __raw_cpu_read_const(pcp)					\
+({									\
+	*(typeof(pcp) *)(__force uintptr_t)(&(pcp));			\
+})
 
 #else /* !CONFIG_USE_X86_SEG_SUPPORT: */
 
Signature · 1 line
2.45.2