* [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning
@ 2024-05-26 17:55 Uros Bizjak
2024-05-26 17:55 ` [PATCH 2/2] x86/percpu: *DO NOT MERGE* Enable named address spaces for clang Uros Bizjak
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Uros Bizjak @ 2024-05-26 17:55 UTC (permalink / raw)
To: x86, llvm, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
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().
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
---
arch/x86/include/asm/percpu.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index c55a79d5feae..aeea5c8a17de 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -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: */
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] x86/percpu: *DO NOT MERGE* Enable named address spaces for clang
2024-05-26 17:55 [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Uros Bizjak
@ 2024-05-26 17:55 ` Uros Bizjak
2024-05-30 15:57 ` [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Nathan Chancellor
2024-07-17 14:40 ` Ingo Molnar
2 siblings, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2024-05-26 17:55 UTC (permalink / raw)
To: x86, llvm, linux-kernel
Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
Enable named address spaces feature for clang.
However, someone from clang side should qualify the compiler
before this feature is enabled for real.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
---
arch/x86/Kconfig | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e8837116704c..08455e62f994 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2433,7 +2433,6 @@ endmenu
config CC_HAS_NAMED_AS
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
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning
2024-05-26 17:55 [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Uros Bizjak
2024-05-26 17:55 ` [PATCH 2/2] x86/percpu: *DO NOT MERGE* Enable named address spaces for clang Uros Bizjak
@ 2024-05-30 15:57 ` Nathan Chancellor
2024-07-17 14:40 ` Ingo Molnar
2 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2024-05-30 15:57 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, llvm, linux-kernel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, H. Peter Anvin, Nick Desaulniers,
Bill Wendling, Justin Stitt
On Sun, May 26, 2024 at 07:55:52PM +0200, Uros Bizjak wrote:
> 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().
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Thanks, this resolves the warning for me when patch 2 is applied.
Acked-by: Nathan Chancellor <nathan@kernel.org>
However, as both of us have noticed [1][2], there is a problem in LLVM's
x86 backend with the address space casting that the kernel does, so
patch 2 should not be merged.
[1]: https://github.com/ClangBuiltLinux/linux/issues/2013
[2]: https://github.com/llvm/llvm-project/issues/93449
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Cc: Bill Wendling <morbo@google.com>
> Cc: Justin Stitt <justinstitt@google.com>
> ---
> arch/x86/include/asm/percpu.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index c55a79d5feae..aeea5c8a17de 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -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: */
>
> --
> 2.42.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning
2024-05-26 17:55 [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Uros Bizjak
2024-05-26 17:55 ` [PATCH 2/2] x86/percpu: *DO NOT MERGE* Enable named address spaces for clang Uros Bizjak
2024-05-30 15:57 ` [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Nathan Chancellor
@ 2024-07-17 14:40 ` Ingo Molnar
2024-07-17 15:53 ` Uros Bizjak
2 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2024-07-17 14:40 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, llvm, linux-kernel, Thomas Gleixner, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
* Uros Bizjak <ubizjak@gmail.com> wrote:
> 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().
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Cc: Bill Wendling <morbo@google.com>
> Cc: Justin Stitt <justinstitt@google.com>
> ---
> arch/x86/include/asm/percpu.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> index c55a79d5feae..aeea5c8a17de 100644
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -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)); \
> +})
So shouldn't this be carried together with the patch that enables named
address spaces on Clang? Is it possible that this patch might not be needed
in a Clang version where named address spaces work as expected?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning
2024-07-17 14:40 ` Ingo Molnar
@ 2024-07-17 15:53 ` Uros Bizjak
0 siblings, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2024-07-17 15:53 UTC (permalink / raw)
To: Ingo Molnar
Cc: x86, llvm, linux-kernel, Thomas Gleixner, Borislav Petkov,
Dave Hansen, H. Peter Anvin, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
On Wed, Jul 17, 2024 at 4:40 PM Ingo Molnar <mingo@kernel.org> wrote:
>
>
> * Uros Bizjak <ubizjak@gmail.com> wrote:
>
> > 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().
> >
> > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Borislav Petkov <bp@alien8.de>
> > Cc: Dave Hansen <dave.hansen@linux.intel.com>
> > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > Cc: Nathan Chancellor <nathan@kernel.org>
> > Cc: Nick Desaulniers <ndesaulniers@google.com>
> > Cc: Bill Wendling <morbo@google.com>
> > Cc: Justin Stitt <justinstitt@google.com>
> > ---
> > arch/x86/include/asm/percpu.h | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
> > index c55a79d5feae..aeea5c8a17de 100644
> > --- a/arch/x86/include/asm/percpu.h
> > +++ b/arch/x86/include/asm/percpu.h
> > @@ -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)); \
> > +})
>
> So shouldn't this be carried together with the patch that enables named
> address spaces on Clang? Is it possible that this patch might not be needed
> in a Clang version where named address spaces work as expected?
No, as diagnosed by Clang, there are indeed two identical specifiers,
so the patch also applies as a general patch.
Regarding Clang, before enabling the feature, issue #93449 [1]
(internal compiler error) has to be fixed.
[1] https://github.com/llvm/llvm-project/issues/93449
Uros.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-17 15:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-26 17:55 [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Uros Bizjak
2024-05-26 17:55 ` [PATCH 2/2] x86/percpu: *DO NOT MERGE* Enable named address spaces for clang Uros Bizjak
2024-05-30 15:57 ` [PATCH 1/2] x86/percpu: Fix "multiple identical address spaces specified for type" clang warning Nathan Chancellor
2024-07-17 14:40 ` Ingo Molnar
2024-07-17 15:53 ` Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).