When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the
following objtool warnings after silencing all of the other warnings:
LD vmlinux.o
vmlinux.o: warning: objtool: .head.text+0x0: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x18: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x38: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x3c: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x40: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x44: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x54: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x58: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x6c: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x84: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x94: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x9c: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0xc4: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0xf8: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0xfc: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x104: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x10c: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x11c: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x120: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x124: unreachable instruction
vmlinux.o: warning: objtool: .head.text+0x144: unreachable instruction
vmlinux.o: warning: objtool: kernel_entry+0x0: unreachable instruction
vmlinux.o: warning: objtool: smpboot_entry+0x0: unreachable instruction
All of the above instructions are in arch/loongarch/kernel/head.S,
and there is "OBJECT_FILES_NON_STANDARD_head.o := y" in Makefile
to skip objtool checking for head.o, but OBJECT_FILES_NON_STANDARD
does not work for link time validation of vmlinux.o according to
tools/objtool/Documentation/objtool.txt.
Just give a proper unwind hint to silence the above warnings. By the way,
the previous instructions of kernel_entry+0xf4 and smpboot_entry+0x68 are
the 'bl' instructions, the call destination symbols are start_kernel() and
start_secondary() which are noreturn functions, then the 'bl' instructions
are marked as dead end in annotate_call_site(), so actually ASM_BUG() can
be removed due to unnecessary, otherwise there are following warnings:
kernel_entry+0xf4: start_kernel() missing __noreturn
in .c/.h or NORETURN() in noreturns.h
smpboot_entry+0x68: start_secondary() missing __noreturn
in .c/.h or NORETURN() in noreturns.h
Link: https://lore.kernel.org/lkml/20250814083651.GR4067720@noisy.programming.kicks-ass.net/
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
arch/loongarch/kernel/head.S | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S
index e3865e92a917..566a1dbf5fa0 100644
--- a/arch/loongarch/kernel/head.S
+++ b/arch/loongarch/kernel/head.S
@@ -20,6 +20,7 @@
__HEAD
_head:
+ UNWIND_HINT_UNDEFINED
.word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */
.org 0x8
.dword _kernel_entry /* Kernel entry point (physical address) */
@@ -30,6 +31,7 @@ _head:
.long pe_header - _head /* Offset to the PE header */
pe_header:
+ UNWIND_HINT_UNDEFINED
__EFI_PE_HEADER
SYM_DATA(kernel_asize, .long _kernel_asize);
@@ -42,6 +44,7 @@ SYM_DATA(kernel_fsize, .long _kernel_fsize);
.align 12
SYM_CODE_START(kernel_entry) # kernel entry point
+ UNWIND_HINT_UNDEFINED
/* Config direct window and set PG */
SETUP_DMWINS t0
@@ -109,8 +112,6 @@ SYM_CODE_START(kernel_entry) # kernel entry point
#endif
bl start_kernel
- ASM_BUG()
-
SYM_CODE_END(kernel_entry)
#ifdef CONFIG_SMP
@@ -120,6 +121,7 @@ SYM_CODE_END(kernel_entry)
* function after setting up the stack and tp registers.
*/
SYM_CODE_START(smpboot_entry)
+ UNWIND_HINT_UNDEFINED
SETUP_DMWINS t0
JUMP_VIRT_ADDR t0, t1
@@ -142,8 +144,6 @@ SYM_CODE_START(smpboot_entry)
ld.d tp, t0, CPU_BOOT_TINFO
bl start_secondary
- ASM_BUG()
-
SYM_CODE_END(smpboot_entry)
#endif /* CONFIG_SMP */
--
2.42.0
On Tue, Aug 26, 2025 at 2:46 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the > following objtool warnings after silencing all of the other warnings: > > LD vmlinux.o > vmlinux.o: warning: objtool: .head.text+0x0: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x18: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x38: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x3c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x40: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x44: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x54: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x58: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x6c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x84: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x94: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x9c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0xc4: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0xf8: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0xfc: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x104: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x10c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x11c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x120: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x124: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x144: unreachable instruction > vmlinux.o: warning: objtool: kernel_entry+0x0: unreachable instruction > vmlinux.o: warning: objtool: smpboot_entry+0x0: unreachable instruction > > All of the above instructions are in arch/loongarch/kernel/head.S, > and there is "OBJECT_FILES_NON_STANDARD_head.o := y" in Makefile > to skip objtool checking for head.o, but OBJECT_FILES_NON_STANDARD > does not work for link time validation of vmlinux.o according to > tools/objtool/Documentation/objtool.txt. > > Just give a proper unwind hint to silence the above warnings. By the way, > the previous instructions of kernel_entry+0xf4 and smpboot_entry+0x68 are > the 'bl' instructions, the call destination symbols are start_kernel() and > start_secondary() which are noreturn functions, then the 'bl' instructions > are marked as dead end in annotate_call_site(), so actually ASM_BUG() can > be removed due to unnecessary, otherwise there are following warnings: > > kernel_entry+0xf4: start_kernel() missing __noreturn > in .c/.h or NORETURN() in noreturns.h > > smpboot_entry+0x68: start_secondary() missing __noreturn > in .c/.h or NORETURN() in noreturns.h > > Link: https://lore.kernel.org/lkml/20250814083651.GR4067720@noisy.programming.kicks-ass.net/ > Suggested-by: Peter Zijlstra <peterz@infradead.org> > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > arch/loongarch/kernel/head.S | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S > index e3865e92a917..566a1dbf5fa0 100644 > --- a/arch/loongarch/kernel/head.S > +++ b/arch/loongarch/kernel/head.S > @@ -20,6 +20,7 @@ > __HEAD > > _head: > + UNWIND_HINT_UNDEFINED > .word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */ > .org 0x8 > .dword _kernel_entry /* Kernel entry point (physical address) */ > @@ -30,6 +31,7 @@ _head: > .long pe_header - _head /* Offset to the PE header */ > > pe_header: > + UNWIND_HINT_UNDEFINED > __EFI_PE_HEADER The efi header is completely not code, the annotations are very strange. Huacai > > SYM_DATA(kernel_asize, .long _kernel_asize); > @@ -42,6 +44,7 @@ SYM_DATA(kernel_fsize, .long _kernel_fsize); > .align 12 > > SYM_CODE_START(kernel_entry) # kernel entry point > + UNWIND_HINT_UNDEFINED > > /* Config direct window and set PG */ > SETUP_DMWINS t0 > @@ -109,8 +112,6 @@ SYM_CODE_START(kernel_entry) # kernel entry point > #endif > > bl start_kernel > - ASM_BUG() > - > SYM_CODE_END(kernel_entry) > > #ifdef CONFIG_SMP > @@ -120,6 +121,7 @@ SYM_CODE_END(kernel_entry) > * function after setting up the stack and tp registers. > */ > SYM_CODE_START(smpboot_entry) > + UNWIND_HINT_UNDEFINED > > SETUP_DMWINS t0 > JUMP_VIRT_ADDR t0, t1 > @@ -142,8 +144,6 @@ SYM_CODE_START(smpboot_entry) > ld.d tp, t0, CPU_BOOT_TINFO > > bl start_secondary > - ASM_BUG() > - > SYM_CODE_END(smpboot_entry) > > #endif /* CONFIG_SMP */ > -- > 2.42.0 >
On 2025/8/26 下午4:26, Huacai Chen wrote: > On Tue, Aug 26, 2025 at 2:46 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: >> >> When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the >> following objtool warnings after silencing all of the other warnings: ... >> arch/loongarch/kernel/head.S | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S >> index e3865e92a917..566a1dbf5fa0 100644 >> --- a/arch/loongarch/kernel/head.S >> +++ b/arch/loongarch/kernel/head.S >> @@ -20,6 +20,7 @@ >> __HEAD >> >> _head: >> + UNWIND_HINT_UNDEFINED >> .word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */ >> .org 0x8 >> .dword _kernel_entry /* Kernel entry point (physical address) */ >> @@ -30,6 +31,7 @@ _head: >> .long pe_header - _head /* Offset to the PE header */ >> >> pe_header: >> + UNWIND_HINT_UNDEFINED >> __EFI_PE_HEADER > The efi header is completely not code, the annotations are very strange. Yes, I think so too, but the aim is only to not checking for objtool, it seems no other better way. Thanks, Tiezhu
On Tue, Aug 26, 2025 at 08:30:23PM +0800, Tiezhu Yang wrote: > On 2025/8/26 下午4:26, Huacai Chen wrote: > > On Tue, Aug 26, 2025 at 2:46 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > > > > > When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the > > > following objtool warnings after silencing all of the other warnings: > > ... > > > > arch/loongarch/kernel/head.S | 8 ++++---- > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S > > > index e3865e92a917..566a1dbf5fa0 100644 > > > --- a/arch/loongarch/kernel/head.S > > > +++ b/arch/loongarch/kernel/head.S > > > @@ -20,6 +20,7 @@ > > > __HEAD > > > > > > _head: > > > + UNWIND_HINT_UNDEFINED > > > .word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */ > > > .org 0x8 > > > .dword _kernel_entry /* Kernel entry point (physical address) */ > > > @@ -30,6 +31,7 @@ _head: > > > .long pe_header - _head /* Offset to the PE header */ > > > > > > pe_header: > > > + UNWIND_HINT_UNDEFINED > > > __EFI_PE_HEADER > > The efi header is completely not code, the annotations are very strange. > > Yes, I think so too, but the aim is only to not checking for objtool, > it seems no other better way. Objtool is only getting confused because there's data in a text section. Why not put that in a data section? -- Josh
On 2025/8/27 上午7:43, Josh Poimboeuf wrote: > On Tue, Aug 26, 2025 at 08:30:23PM +0800, Tiezhu Yang wrote: >> On 2025/8/26 下午4:26, Huacai Chen wrote: >>> On Tue, Aug 26, 2025 at 2:46 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: >>>> >>>> When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the >>>> following objtool warnings after silencing all of the other warnings: >> >> ... >> >>>> arch/loongarch/kernel/head.S | 8 ++++---- >>>> 1 file changed, 4 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S >>>> index e3865e92a917..566a1dbf5fa0 100644 >>>> --- a/arch/loongarch/kernel/head.S >>>> +++ b/arch/loongarch/kernel/head.S >>>> @@ -20,6 +20,7 @@ >>>> __HEAD >>>> >>>> _head: >>>> + UNWIND_HINT_UNDEFINED >>>> .word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */ >>>> .org 0x8 >>>> .dword _kernel_entry /* Kernel entry point (physical address) */ >>>> @@ -30,6 +31,7 @@ _head: >>>> .long pe_header - _head /* Offset to the PE header */ >>>> >>>> pe_header: >>>> + UNWIND_HINT_UNDEFINED >>>> __EFI_PE_HEADER >>> The efi header is completely not code, the annotations are very strange. >> >> Yes, I think so too, but the aim is only to not checking for objtool, >> it seems no other better way. > > Objtool is only getting confused because there's data in a text section. > Why not put that in a data section? Thank you very much, that is to say, these EFISTUB instructions can be ignored by objtool, I will do it. Thanks, Tiezhu
On Tue, Aug 26, 2025 at 02:46:31PM +0800, Tiezhu Yang wrote: > When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the > following objtool warnings after silencing all of the other warnings: > > LD vmlinux.o > vmlinux.o: warning: objtool: .head.text+0x0: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x18: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x38: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x3c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x40: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x44: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x54: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x58: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x6c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x84: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x94: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x9c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0xc4: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0xf8: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0xfc: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x104: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x10c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x11c: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x120: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x124: unreachable instruction > vmlinux.o: warning: objtool: .head.text+0x144: unreachable instruction > vmlinux.o: warning: objtool: kernel_entry+0x0: unreachable instruction > vmlinux.o: warning: objtool: smpboot_entry+0x0: unreachable instruction > > All of the above instructions are in arch/loongarch/kernel/head.S, > and there is "OBJECT_FILES_NON_STANDARD_head.o := y" in Makefile > to skip objtool checking for head.o, but OBJECT_FILES_NON_STANDARD > does not work for link time validation of vmlinux.o according to > tools/objtool/Documentation/objtool.txt. > > Just give a proper unwind hint to silence the above warnings. By the way, > the previous instructions of kernel_entry+0xf4 and smpboot_entry+0x68 are > the 'bl' instructions, the call destination symbols are start_kernel() and > start_secondary() which are noreturn functions, then the 'bl' instructions > are marked as dead end in annotate_call_site(), so actually ASM_BUG() can > be removed due to unnecessary, otherwise there are following warnings: > > kernel_entry+0xf4: start_kernel() missing __noreturn > in .c/.h or NORETURN() in noreturns.h > > smpboot_entry+0x68: start_secondary() missing __noreturn > in .c/.h or NORETURN() in noreturns.h > > Link: https://lore.kernel.org/lkml/20250814083651.GR4067720@noisy.programming.kicks-ass.net/ > Suggested-by: Peter Zijlstra <peterz@infradead.org> > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > arch/loongarch/kernel/head.S | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) At this point you should also be able to remove that Makefile thing, right? > diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S > index e3865e92a917..566a1dbf5fa0 100644 > --- a/arch/loongarch/kernel/head.S > +++ b/arch/loongarch/kernel/head.S > @@ -20,6 +20,7 @@ > __HEAD > > _head: > + UNWIND_HINT_UNDEFINED > .word IMAGE_DOS_SIGNATURE /* "MZ", MS-DOS header */ > .org 0x8 > .dword _kernel_entry /* Kernel entry point (physical address) */ > @@ -30,6 +31,7 @@ _head: > .long pe_header - _head /* Offset to the PE header */ > > pe_header: > + UNWIND_HINT_UNDEFINED > __EFI_PE_HEADER > > SYM_DATA(kernel_asize, .long _kernel_asize); > @@ -42,6 +44,7 @@ SYM_DATA(kernel_fsize, .long _kernel_fsize); > .align 12 > > SYM_CODE_START(kernel_entry) # kernel entry point > + UNWIND_HINT_UNDEFINED > > /* Config direct window and set PG */ > SETUP_DMWINS t0 > @@ -109,8 +112,6 @@ SYM_CODE_START(kernel_entry) # kernel entry point > #endif > > bl start_kernel > - ASM_BUG() > - > SYM_CODE_END(kernel_entry) > > #ifdef CONFIG_SMP > @@ -120,6 +121,7 @@ SYM_CODE_END(kernel_entry) > * function after setting up the stack and tp registers. > */ > SYM_CODE_START(smpboot_entry) > + UNWIND_HINT_UNDEFINED > > SETUP_DMWINS t0 > JUMP_VIRT_ADDR t0, t1 > @@ -142,8 +144,6 @@ SYM_CODE_START(smpboot_entry) > ld.d tp, t0, CPU_BOOT_TINFO > > bl start_secondary > - ASM_BUG() > - > SYM_CODE_END(smpboot_entry) > > #endif /* CONFIG_SMP */ > -- > 2.42.0 >
On 2025/8/26 下午4:20, Peter Zijlstra wrote: > On Tue, Aug 26, 2025 at 02:46:31PM +0800, Tiezhu Yang wrote: >> When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the >> following objtool warnings after silencing all of the other warnings: ... >> Just give a proper unwind hint to silence the above warnings. By the way, >> the previous instructions of kernel_entry+0xf4 and smpboot_entry+0x68 are >> the 'bl' instructions, the call destination symbols are start_kernel() and >> start_secondary() which are noreturn functions, then the 'bl' instructions >> are marked as dead end in annotate_call_site(), so actually ASM_BUG() can >> be removed due to unnecessary, otherwise there are following warnings: ... >> Link: https://lore.kernel.org/lkml/20250814083651.GR4067720@noisy.programming.kicks-ass.net/ >> Suggested-by: Peter Zijlstra <peterz@infradead.org> >> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> >> --- >> arch/loongarch/kernel/head.S | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) > > At this point you should also be able to remove that Makefile thing, > right? Yes, you are right, will do it in the next version if this patch makes sense. Thanks, Tiezhu
© 2016 - 2025 Red Hat, Inc.