All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/extable: prefer local labels in .set directives
@ 2022-03-29 20:21 Nick Desaulniers
  2022-03-29 20:41 ` Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nick Desaulniers @ 2022-03-29 20:21 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Nick Desaulniers, Bernardo Meurer Costa, Nathan Chancellor,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Josh Poimboeuf, linux-kernel

Bernardo reported an error that Nathan bisected down to
(x86_64) defconfig+LTO_CLANG_FULL+X86_PMEM_LEGACY.

    LTO     vmlinux.o
  ld.lld: error: <instantiation>:1:13: redefinition of 'found'
  .set found, 0
              ^

  <inline asm>:29:1: while in macro instantiation
  extable_type_reg reg=%eax, type=(17 | ((0) << 16))
  ^

This appears to be another LTO specific issue similar to what was folded
into commit 4b5305decc84 ("x86/extable: Extend extable functionality"),
where the `.set found, 0` in DEFINE_EXTABLE_TYPE_REG in
arch/x86/include/asm/asm.h conflicts with the symbol for the static
function `found` in arch/x86/kernel/pmem.c.

Assembler .set directive declare symbols with global visibility, so the
assembler may not rename such symbols in the event of a conflict. LTO
could rename static functions if there was a conflict in C sources, but
it cannot see into symbols defined in inline asm.

The symbols are also retained in the symbol table, regardless of LTO.

Give the symbols .L prefixes making them locally visible, so that they
may be renamed for LTO to avoid conflicts, and to drop them from the
symbol table regardless of LTO.

Fixes: 4b5305decc84 ("x86/extable: Extend extable functionality")
Link: https://github.com/ClangBuiltLinux/linux/issues/1612
Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Symbol-Names
Reported-by: Bernardo Meurer Costa <beme@google.com>
Debugged-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 arch/x86/include/asm/asm.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index c878fed3056f..fbcfec4dc4cc 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -154,24 +154,24 @@
 
 # define DEFINE_EXTABLE_TYPE_REG \
 	".macro extable_type_reg type:req reg:req\n"						\
-	".set found, 0\n"									\
-	".set regnr, 0\n"									\
+	".set .Lfound, 0\n"									\
+	".set .Lregnr, 0\n"									\
 	".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n"		\
 	".ifc \\reg, %%\\rs\n"									\
-	".set found, found+1\n"									\
-	".long \\type + (regnr << 8)\n"								\
+	".set .Lfound, .Lfound+1\n"								\
+	".long \\type + (.Lregnr << 8)\n"							\
 	".endif\n"										\
-	".set regnr, regnr+1\n"									\
+	".set .Lregnr, .Lregnr+1\n"								\
 	".endr\n"										\
-	".set regnr, 0\n"									\
+	".set .Lregnr, 0\n"									\
 	".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n"	\
 	".ifc \\reg, %%\\rs\n"									\
-	".set found, found+1\n"									\
-	".long \\type + (regnr << 8)\n"								\
+	".set .Lfound, .Lfound+1\n"								\
+	".long \\type + (.Lregnr << 8)\n"							\
 	".endif\n"										\
-	".set regnr, regnr+1\n"									\
+	".set .Lregnr, .Lregnr+1\n"								\
 	".endr\n"										\
-	".if (found != 1)\n"									\
+	".if (.Lfound != 1)\n"									\
 	".error \"extable_type_reg: bad register argument\"\n"					\
 	".endif\n"										\
 	".endm\n"
-- 
2.35.1.1021.g381101b075-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/extable: prefer local labels in .set directives
  2022-03-29 20:21 [PATCH] x86/extable: prefer local labels in .set directives Nick Desaulniers
@ 2022-03-29 20:41 ` Nathan Chancellor
  2022-04-06 10:27 ` Peter Zijlstra
  2022-04-07  9:46 ` [tip: x86/urgent] x86/extable: Prefer " tip-bot2 for Nick Desaulniers
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2022-03-29 20:41 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Peter Zijlstra, Bernardo Meurer Costa, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Josh Poimboeuf, linux-kernel

On Tue, Mar 29, 2022 at 01:21:45PM -0700, Nick Desaulniers wrote:
> Bernardo reported an error that Nathan bisected down to
> (x86_64) defconfig+LTO_CLANG_FULL+X86_PMEM_LEGACY.
> 
>     LTO     vmlinux.o
>   ld.lld: error: <instantiation>:1:13: redefinition of 'found'
>   .set found, 0
>               ^
> 
>   <inline asm>:29:1: while in macro instantiation
>   extable_type_reg reg=%eax, type=(17 | ((0) << 16))
>   ^
> 
> This appears to be another LTO specific issue similar to what was folded
> into commit 4b5305decc84 ("x86/extable: Extend extable functionality"),
> where the `.set found, 0` in DEFINE_EXTABLE_TYPE_REG in
> arch/x86/include/asm/asm.h conflicts with the symbol for the static
> function `found` in arch/x86/kernel/pmem.c.
> 
> Assembler .set directive declare symbols with global visibility, so the
> assembler may not rename such symbols in the event of a conflict. LTO
> could rename static functions if there was a conflict in C sources, but
> it cannot see into symbols defined in inline asm.
> 
> The symbols are also retained in the symbol table, regardless of LTO.
> 
> Give the symbols .L prefixes making them locally visible, so that they
> may be renamed for LTO to avoid conflicts, and to drop them from the
> symbol table regardless of LTO.
> 
> Fixes: 4b5305decc84 ("x86/extable: Extend extable functionality")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1612
> Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Symbol-Names
> Reported-by: Bernardo Meurer Costa <beme@google.com>
> Debugged-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

This resolves the build error for me and it passes a smoke test boot in
QEMU.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

Should this have an explicit "Cc: stable@vger.kernel.org"? The build
error was reported against Linux 5.17.

> ---
>  arch/x86/include/asm/asm.h | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
> index c878fed3056f..fbcfec4dc4cc 100644
> --- a/arch/x86/include/asm/asm.h
> +++ b/arch/x86/include/asm/asm.h
> @@ -154,24 +154,24 @@
>  
>  # define DEFINE_EXTABLE_TYPE_REG \
>  	".macro extable_type_reg type:req reg:req\n"						\
> -	".set found, 0\n"									\
> -	".set regnr, 0\n"									\
> +	".set .Lfound, 0\n"									\
> +	".set .Lregnr, 0\n"									\
>  	".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n"		\
>  	".ifc \\reg, %%\\rs\n"									\
> -	".set found, found+1\n"									\
> -	".long \\type + (regnr << 8)\n"								\
> +	".set .Lfound, .Lfound+1\n"								\
> +	".long \\type + (.Lregnr << 8)\n"							\
>  	".endif\n"										\
> -	".set regnr, regnr+1\n"									\
> +	".set .Lregnr, .Lregnr+1\n"								\
>  	".endr\n"										\
> -	".set regnr, 0\n"									\
> +	".set .Lregnr, 0\n"									\
>  	".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n"	\
>  	".ifc \\reg, %%\\rs\n"									\
> -	".set found, found+1\n"									\
> -	".long \\type + (regnr << 8)\n"								\
> +	".set .Lfound, .Lfound+1\n"								\
> +	".long \\type + (.Lregnr << 8)\n"							\
>  	".endif\n"										\
> -	".set regnr, regnr+1\n"									\
> +	".set .Lregnr, .Lregnr+1\n"								\
>  	".endr\n"										\
> -	".if (found != 1)\n"									\
> +	".if (.Lfound != 1)\n"									\
>  	".error \"extable_type_reg: bad register argument\"\n"					\
>  	".endif\n"										\
>  	".endm\n"
> -- 
> 2.35.1.1021.g381101b075-goog
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/extable: prefer local labels in .set directives
  2022-03-29 20:21 [PATCH] x86/extable: prefer local labels in .set directives Nick Desaulniers
  2022-03-29 20:41 ` Nathan Chancellor
@ 2022-04-06 10:27 ` Peter Zijlstra
  2022-04-07  9:46 ` [tip: x86/urgent] x86/extable: Prefer " tip-bot2 for Nick Desaulniers
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2022-04-06 10:27 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Bernardo Meurer Costa, Nathan Chancellor, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Josh Poimboeuf, linux-kernel

On Tue, Mar 29, 2022 at 01:21:45PM -0700, Nick Desaulniers wrote:
> Bernardo reported an error that Nathan bisected down to
> (x86_64) defconfig+LTO_CLANG_FULL+X86_PMEM_LEGACY.
> 
>     LTO     vmlinux.o
>   ld.lld: error: <instantiation>:1:13: redefinition of 'found'
>   .set found, 0
>               ^
> 
>   <inline asm>:29:1: while in macro instantiation
>   extable_type_reg reg=%eax, type=(17 | ((0) << 16))
>   ^
> 
> This appears to be another LTO specific issue similar to what was folded
> into commit 4b5305decc84 ("x86/extable: Extend extable functionality"),
> where the `.set found, 0` in DEFINE_EXTABLE_TYPE_REG in
> arch/x86/include/asm/asm.h conflicts with the symbol for the static
> function `found` in arch/x86/kernel/pmem.c.
> 
> Assembler .set directive declare symbols with global visibility, so the
> assembler may not rename such symbols in the event of a conflict. LTO
> could rename static functions if there was a conflict in C sources, but
> it cannot see into symbols defined in inline asm.
> 
> The symbols are also retained in the symbol table, regardless of LTO.
> 
> Give the symbols .L prefixes making them locally visible, so that they
> may be renamed for LTO to avoid conflicts, and to drop them from the
> symbol table regardless of LTO.
> 
> Fixes: 4b5305decc84 ("x86/extable: Extend extable functionality")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1612
> Link: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Local-Symbol-Names
> Reported-by: Bernardo Meurer Costa <beme@google.com>
> Debugged-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: x86/urgent] x86/extable: Prefer local labels in .set directives
  2022-03-29 20:21 [PATCH] x86/extable: prefer local labels in .set directives Nick Desaulniers
  2022-03-29 20:41 ` Nathan Chancellor
  2022-04-06 10:27 ` Peter Zijlstra
@ 2022-04-07  9:46 ` tip-bot2 for Nick Desaulniers
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Nick Desaulniers @ 2022-04-07  9:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bernardo Meurer Costa, Nick Desaulniers, Peter Zijlstra (Intel),
	Nathan Chancellor, x86, linux-kernel

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

Commit-ID:     334865b2915c33080624e0d06f1c3e917036472c
Gitweb:        https://git.kernel.org/tip/334865b2915c33080624e0d06f1c3e917036472c
Author:        Nick Desaulniers <ndesaulniers@google.com>
AuthorDate:    Tue, 29 Mar 2022 13:21:45 -07:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 07 Apr 2022 11:27:02 +02:00

x86/extable: Prefer local labels in .set directives

Bernardo reported an error that Nathan bisected down to
(x86_64) defconfig+LTO_CLANG_FULL+X86_PMEM_LEGACY.

    LTO     vmlinux.o
  ld.lld: error: <instantiation>:1:13: redefinition of 'found'
  .set found, 0
              ^

  <inline asm>:29:1: while in macro instantiation
  extable_type_reg reg=%eax, type=(17 | ((0) << 16))
  ^

This appears to be another LTO specific issue similar to what was folded
into commit 4b5305decc84 ("x86/extable: Extend extable functionality"),
where the `.set found, 0` in DEFINE_EXTABLE_TYPE_REG in
arch/x86/include/asm/asm.h conflicts with the symbol for the static
function `found` in arch/x86/kernel/pmem.c.

Assembler .set directive declare symbols with global visibility, so the
assembler may not rename such symbols in the event of a conflict. LTO
could rename static functions if there was a conflict in C sources, but
it cannot see into symbols defined in inline asm.

The symbols are also retained in the symbol table, regardless of LTO.

Give the symbols .L prefixes making them locally visible, so that they
may be renamed for LTO to avoid conflicts, and to drop them from the
symbol table regardless of LTO.

Fixes: 4b5305decc84 ("x86/extable: Extend extable functionality")
Reported-by: Bernardo Meurer Costa <beme@google.com>
Debugged-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20220329202148.2379697-1-ndesaulniers@google.com
---
 arch/x86/include/asm/asm.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h
index c878fed..fbcfec4 100644
--- a/arch/x86/include/asm/asm.h
+++ b/arch/x86/include/asm/asm.h
@@ -154,24 +154,24 @@
 
 # define DEFINE_EXTABLE_TYPE_REG \
 	".macro extable_type_reg type:req reg:req\n"						\
-	".set found, 0\n"									\
-	".set regnr, 0\n"									\
+	".set .Lfound, 0\n"									\
+	".set .Lregnr, 0\n"									\
 	".irp rs,rax,rcx,rdx,rbx,rsp,rbp,rsi,rdi,r8,r9,r10,r11,r12,r13,r14,r15\n"		\
 	".ifc \\reg, %%\\rs\n"									\
-	".set found, found+1\n"									\
-	".long \\type + (regnr << 8)\n"								\
+	".set .Lfound, .Lfound+1\n"								\
+	".long \\type + (.Lregnr << 8)\n"							\
 	".endif\n"										\
-	".set regnr, regnr+1\n"									\
+	".set .Lregnr, .Lregnr+1\n"								\
 	".endr\n"										\
-	".set regnr, 0\n"									\
+	".set .Lregnr, 0\n"									\
 	".irp rs,eax,ecx,edx,ebx,esp,ebp,esi,edi,r8d,r9d,r10d,r11d,r12d,r13d,r14d,r15d\n"	\
 	".ifc \\reg, %%\\rs\n"									\
-	".set found, found+1\n"									\
-	".long \\type + (regnr << 8)\n"								\
+	".set .Lfound, .Lfound+1\n"								\
+	".long \\type + (.Lregnr << 8)\n"							\
 	".endif\n"										\
-	".set regnr, regnr+1\n"									\
+	".set .Lregnr, .Lregnr+1\n"								\
 	".endr\n"										\
-	".if (found != 1)\n"									\
+	".if (.Lfound != 1)\n"									\
 	".error \"extable_type_reg: bad register argument\"\n"					\
 	".endif\n"										\
 	".endm\n"

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-07  9:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 20:21 [PATCH] x86/extable: prefer local labels in .set directives Nick Desaulniers
2022-03-29 20:41 ` Nathan Chancellor
2022-04-06 10:27 ` Peter Zijlstra
2022-04-07  9:46 ` [tip: x86/urgent] x86/extable: Prefer " tip-bot2 for Nick Desaulniers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.