* [RFC PATCH 0/2] Fix objtool warnings if LTO is enabled for LoongArch (Part 2) @ 2025-08-26 6:46 Tiezhu Yang 2025-08-26 6:46 ` [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() Tiezhu Yang 2025-08-26 6:46 ` [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S Tiezhu Yang 0 siblings, 2 replies; 14+ messages in thread From: Tiezhu Yang @ 2025-08-26 6:46 UTC (permalink / raw) To: Huacai Chen, Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor Cc: loongarch, linux-kernel The previous series is to fix most of the warnings (total 3030): sibling call from callable instruction with modified stack frame This series is a follow up to fix 2 kinds of warnings (total 24), it only touches the LoongArch related code: falls through to next function unreachable instruction With this series, there is only 1 kind of warning (total 3), it does not only touch the LoongArch related code: missing __noreturn in .c/.h or NORETURN() in noreturns.h In order to silence the above warnings, it needs to change the related code to give the functions __noreturn attribute, and have a NORETURN() annotation in tools/objtool/noreturns.h. IMO, it will touch all of the archs and the generic code, so this needs much more work to avoid the side effect or regression, once it is done I will send out the patch. Tiezhu Yang (2): objtool/LoongArch: Fix fall through warning about efi_boot_kernel() objtool/LoongArch: Fix unreachable instruction warnings about head.S arch/loongarch/kernel/head.S | 8 ++++---- drivers/firmware/efi/libstub/loongarch.c | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) -- 2.42.0 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() 2025-08-26 6:46 [RFC PATCH 0/2] Fix objtool warnings if LTO is enabled for LoongArch (Part 2) Tiezhu Yang @ 2025-08-26 6:46 ` Tiezhu Yang 2025-08-26 8:32 ` Huacai Chen 2025-08-26 6:46 ` [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S Tiezhu Yang 1 sibling, 1 reply; 14+ messages in thread From: Tiezhu Yang @ 2025-08-26 6:46 UTC (permalink / raw) To: Huacai Chen, Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor Cc: loongarch, linux-kernel When compiling with LLVM and CONFIG_LTO_CLANG is set, there exists the following objtool warning: vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() falls through to next function __efistub_exit_boot_func() This is because efi_boot_kernel() doesn't end with a return instruction or an unconditional jump, then objtool has determined that the function can fall through into the next function. Actually, efi_boot_kernel()'s last instruction is "jirl $ra, $a3, 0", it is a call to a noreturn function pointer real_kernel_entry() which points to the symbol kernel_entry() in arch/loongarch/kernel/head.S. drivers/firmware/efi/libstub/loongarch.c: typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, unsigned long systab); efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image, unsigned long kernel_addr, char *cmdline_ptr) { kernel_entry_t real_kernel_entry; ... real_kernel_entry = (void *)kernel_entry_address(kernel_addr, image); real_kernel_entry(true, (unsigned long)cmdline_ptr, (unsigned long)efi_system_table); } According to the description of tools/objtool/Documentation/objtool.txt, in order to silence this warning, at the beginning just add the noreturn real_kernel_entry() to objtool's hard-coded global_noreturns array, but there is no effect, because it is not a valid symbol. There exists an alternative way to silence this warning, the first thing is to remove the attribute __noreturn for real_kernel_entry(), otherwise the compiler can not generate instructions after that, and then just add "while (1);" at the end of efi_boot_kernel(), so that efi_boot_kernel() ends with an unconditional jump instruction "b". Note that at the end of efi_boot_kernel(), using unreachable() has no effect because it can still generate fall-through code, using BUG() is not proper because it will generate the following ld.lld warning: vmlinux.o:(.init__bug_table) is being placed in '.init__bug_table' Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> --- drivers/firmware/efi/libstub/loongarch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/efi/libstub/loongarch.c index 3782d0a187d1..e309fd78fca7 100644 --- a/drivers/firmware/efi/libstub/loongarch.c +++ b/drivers/firmware/efi/libstub/loongarch.c @@ -10,7 +10,7 @@ #include "efistub.h" #include "loongarch-stub.h" -typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, +typedef void (*kernel_entry_t)(bool efi, unsigned long cmdline, unsigned long systab); efi_status_t check_platform_features(void) @@ -81,4 +81,7 @@ efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image, real_kernel_entry(true, (unsigned long)cmdline_ptr, (unsigned long)efi_system_table); + + /* We should never get here */ + while (1); } -- 2.42.0 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() 2025-08-26 6:46 ` [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() Tiezhu Yang @ 2025-08-26 8:32 ` Huacai Chen 2025-08-26 12:33 ` Tiezhu Yang 0 siblings, 1 reply; 14+ messages in thread From: Huacai Chen @ 2025-08-26 8:32 UTC (permalink / raw) To: Tiezhu Yang Cc: Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel 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 exists > the following objtool warning: > > vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() > falls through to next function __efistub_exit_boot_func() > > This is because efi_boot_kernel() doesn't end with a return instruction > or an unconditional jump, then objtool has determined that the function > can fall through into the next function. > > Actually, efi_boot_kernel()'s last instruction is "jirl $ra, $a3, 0", it > is a call to a noreturn function pointer real_kernel_entry() which points > to the symbol kernel_entry() in arch/loongarch/kernel/head.S. > > drivers/firmware/efi/libstub/loongarch.c: > > typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, > unsigned long systab); > > efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image, > unsigned long kernel_addr, char *cmdline_ptr) > { > kernel_entry_t real_kernel_entry; > ... > real_kernel_entry = (void *)kernel_entry_address(kernel_addr, image); > > real_kernel_entry(true, (unsigned long)cmdline_ptr, > (unsigned long)efi_system_table); > } > > According to the description of tools/objtool/Documentation/objtool.txt, > in order to silence this warning, at the beginning just add the noreturn > real_kernel_entry() to objtool's hard-coded global_noreturns array, but > there is no effect, because it is not a valid symbol. > > There exists an alternative way to silence this warning, the first thing > is to remove the attribute __noreturn for real_kernel_entry(), otherwise > the compiler can not generate instructions after that, and then just add > "while (1);" at the end of efi_boot_kernel(), so that efi_boot_kernel() > ends with an unconditional jump instruction "b". > > Note that at the end of efi_boot_kernel(), using unreachable() has no > effect because it can still generate fall-through code, using BUG() is > not proper because it will generate the following ld.lld warning: > > vmlinux.o:(.init__bug_table) is being placed in '.init__bug_table' > > Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> > --- > drivers/firmware/efi/libstub/loongarch.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/efi/libstub/loongarch.c > index 3782d0a187d1..e309fd78fca7 100644 > --- a/drivers/firmware/efi/libstub/loongarch.c > +++ b/drivers/firmware/efi/libstub/loongarch.c > @@ -10,7 +10,7 @@ > #include "efistub.h" > #include "loongarch-stub.h" > > -typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, > +typedef void (*kernel_entry_t)(bool efi, unsigned long cmdline, > unsigned long systab); From my point of view this is incorrect, this function is indeed a noreturn function, and this modification makes LoongArch different to other architectures. Maybe it is better to let objtool ignore the whole drivers/firmware/efi/libstub directory. Because efistub is discarded at runtime so it is useless for stack unwinder. Huacai > > efi_status_t check_platform_features(void) > @@ -81,4 +81,7 @@ efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image, > > real_kernel_entry(true, (unsigned long)cmdline_ptr, > (unsigned long)efi_system_table); > + > + /* We should never get here */ > + while (1); > } > -- > 2.42.0 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() 2025-08-26 8:32 ` Huacai Chen @ 2025-08-26 12:33 ` Tiezhu Yang 2025-08-26 13:03 ` Huacai Chen 0 siblings, 1 reply; 14+ messages in thread From: Tiezhu Yang @ 2025-08-26 12:33 UTC (permalink / raw) To: Huacai Chen Cc: Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel On 2025/8/26 下午4:32, 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 exists >> the following objtool warning: >> >> vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() >> falls through to next function __efistub_exit_boot_func() ... >> -typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, >> +typedef void (*kernel_entry_t)(bool efi, unsigned long cmdline, >> unsigned long systab); > From my point of view this is incorrect, this function is indeed a > noreturn function, and this modification makes LoongArch different to > other architectures. > > Maybe it is better to let objtool ignore the whole > drivers/firmware/efi/libstub directory. Because efistub is discarded > at runtime so it is useless for stack unwinder. I tested the following change but there is no effect, the objtool warning still exists, this is because OBJECT_FILES_NON_STANDARD does not work for link time validation of vmlinux.o according to tools/objtool/Documentation/objtool.txt. diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 8efbcf699e4f..f1fff48eea76 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -10,6 +10,8 @@ # KASAN_SANITIZE_runtime-wrappers.o := n +OBJECT_FILES_NON_STANDARD := y + obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o obj-$(CONFIG_EFI) += efi.o vars.o reboot.o memattr.o tpm.o obj-$(CONFIG_EFI) += memmap.o Thanks, Tiezhu ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() 2025-08-26 12:33 ` Tiezhu Yang @ 2025-08-26 13:03 ` Huacai Chen 2025-08-26 23:39 ` Josh Poimboeuf 0 siblings, 1 reply; 14+ messages in thread From: Huacai Chen @ 2025-08-26 13:03 UTC (permalink / raw) To: Tiezhu Yang Cc: Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel On Tue, Aug 26, 2025 at 8:33 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > On 2025/8/26 下午4:32, 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 exists > >> the following objtool warning: > >> > >> vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() > >> falls through to next function __efistub_exit_boot_func() > > ... > > >> -typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, > >> +typedef void (*kernel_entry_t)(bool efi, unsigned long cmdline, > >> unsigned long systab); > > From my point of view this is incorrect, this function is indeed a > > noreturn function, and this modification makes LoongArch different to > > other architectures. > > > > Maybe it is better to let objtool ignore the whole > > drivers/firmware/efi/libstub directory. Because efistub is discarded > > at runtime so it is useless for stack unwinder. > > I tested the following change but there is no effect, the objtool > warning still exists, this is because OBJECT_FILES_NON_STANDARD > does not work for link time validation of vmlinux.o according to > tools/objtool/Documentation/objtool.txt. Then I think objtool needs to be improved to handle this case, this problem is not arch specific. Huacai > > diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile > index 8efbcf699e4f..f1fff48eea76 100644 > --- a/drivers/firmware/efi/Makefile > +++ b/drivers/firmware/efi/Makefile > @@ -10,6 +10,8 @@ > # > KASAN_SANITIZE_runtime-wrappers.o := n > > +OBJECT_FILES_NON_STANDARD := y > + > obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o > obj-$(CONFIG_EFI) += efi.o vars.o reboot.o > memattr.o tpm.o > obj-$(CONFIG_EFI) += memmap.o > > Thanks, > Tiezhu > > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() 2025-08-26 13:03 ` Huacai Chen @ 2025-08-26 23:39 ` Josh Poimboeuf 2025-08-28 2:01 ` Tiezhu Yang 0 siblings, 1 reply; 14+ messages in thread From: Josh Poimboeuf @ 2025-08-26 23:39 UTC (permalink / raw) To: Huacai Chen Cc: Tiezhu Yang, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel On Tue, Aug 26, 2025 at 09:03:34PM +0800, Huacai Chen wrote: > On Tue, Aug 26, 2025 at 8:33 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote: > > > > On 2025/8/26 下午4:32, 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 exists > > >> the following objtool warning: > > >> > > >> vmlinux.o: warning: objtool: __efistub_efi_boot_kernel() > > >> falls through to next function __efistub_exit_boot_func() > > > > ... > > > > >> -typedef void __noreturn (*kernel_entry_t)(bool efi, unsigned long cmdline, > > >> +typedef void (*kernel_entry_t)(bool efi, unsigned long cmdline, > > >> unsigned long systab); > > > From my point of view this is incorrect, this function is indeed a > > > noreturn function, and this modification makes LoongArch different to > > > other architectures. > > > > > > Maybe it is better to let objtool ignore the whole > > > drivers/firmware/efi/libstub directory. Because efistub is discarded > > > at runtime so it is useless for stack unwinder. > > > > I tested the following change but there is no effect, the objtool > > warning still exists, this is because OBJECT_FILES_NON_STANDARD > > does not work for link time validation of vmlinux.o according to > > tools/objtool/Documentation/objtool.txt. > Then I think objtool needs to be improved to handle this case, this > problem is not arch specific. Yeah, objtool should really be ignoring this code altogether. On x86, that's not a problem because the EFI stub code isn't linked into vmlinux.o. It gets linked in separately: $ git grep vmlinux-libs arch/x86/boot/compressed/Makefile:vmlinux-libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a arch/x86/boot/compressed/Makefile:vmlinux-libs-$(CONFIG_X86_64) += $(objtree)/arch/x86/boot/startup/lib.a arch/x86/boot/compressed/Makefile:$(obj)/vmlinux: $(vmlinux-objs-y) $(vmlinux-libs-y) FORCE IMO, the proper fix is to change the loongarch build to do the same. vmlinux.o is intended to be proper kernel code. -- Josh ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() 2025-08-26 23:39 ` Josh Poimboeuf @ 2025-08-28 2:01 ` Tiezhu Yang 0 siblings, 0 replies; 14+ messages in thread From: Tiezhu Yang @ 2025-08-28 2:01 UTC (permalink / raw) To: Josh Poimboeuf, Huacai Chen Cc: Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel On 2025/8/27 上午7:39, Josh Poimboeuf wrote: > On Tue, Aug 26, 2025 at 09:03:34PM +0800, Huacai Chen wrote: ... >> Then I think objtool needs to be improved to handle this case, this >> problem is not arch specific. > > Yeah, objtool should really be ignoring this code altogether. On x86, > that's not a problem because the EFI stub code isn't linked into > vmlinux.o. It gets linked in separately: > > $ git grep vmlinux-libs > arch/x86/boot/compressed/Makefile:vmlinux-libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a > arch/x86/boot/compressed/Makefile:vmlinux-libs-$(CONFIG_X86_64) += $(objtree)/arch/x86/boot/startup/lib.a > arch/x86/boot/compressed/Makefile:$(obj)/vmlinux: $(vmlinux-objs-y) $(vmlinux-libs-y) FORCE > > IMO, the proper fix is to change the loongarch build to do the same. > vmlinux.o is intended to be proper kernel code. Thank you very much, that is to say, these EFISTUB functions can be ignored by objtool, I will do it. Thanks, Tiezhu ^ permalink raw reply [flat|nested] 14+ messages in thread
* [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 6:46 [RFC PATCH 0/2] Fix objtool warnings if LTO is enabled for LoongArch (Part 2) Tiezhu Yang 2025-08-26 6:46 ` [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() Tiezhu Yang @ 2025-08-26 6:46 ` Tiezhu Yang 2025-08-26 8:20 ` Peter Zijlstra 2025-08-26 8:26 ` Huacai Chen 1 sibling, 2 replies; 14+ messages in thread From: Tiezhu Yang @ 2025-08-26 6:46 UTC (permalink / raw) To: Huacai Chen, Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor Cc: loongarch, linux-kernel 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 6:46 ` [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S Tiezhu Yang @ 2025-08-26 8:20 ` Peter Zijlstra 2025-08-26 12:27 ` Tiezhu Yang 2025-08-26 8:26 ` Huacai Chen 1 sibling, 1 reply; 14+ messages in thread From: Peter Zijlstra @ 2025-08-26 8:20 UTC (permalink / raw) To: Tiezhu Yang Cc: Huacai Chen, Josh Poimboeuf, Nathan Chancellor, loongarch, linux-kernel 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 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 8:20 ` Peter Zijlstra @ 2025-08-26 12:27 ` Tiezhu Yang 0 siblings, 0 replies; 14+ messages in thread From: Tiezhu Yang @ 2025-08-26 12:27 UTC (permalink / raw) To: Peter Zijlstra Cc: Huacai Chen, Josh Poimboeuf, Nathan Chancellor, loongarch, linux-kernel 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 6:46 ` [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S Tiezhu Yang 2025-08-26 8:20 ` Peter Zijlstra @ 2025-08-26 8:26 ` Huacai Chen 2025-08-26 12:30 ` Tiezhu Yang 1 sibling, 1 reply; 14+ messages in thread From: Huacai Chen @ 2025-08-26 8:26 UTC (permalink / raw) To: Tiezhu Yang Cc: Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel 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 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 8:26 ` Huacai Chen @ 2025-08-26 12:30 ` Tiezhu Yang 2025-08-26 23:43 ` Josh Poimboeuf 0 siblings, 1 reply; 14+ messages in thread From: Tiezhu Yang @ 2025-08-26 12:30 UTC (permalink / raw) To: Huacai Chen Cc: Josh Poimboeuf, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 12:30 ` Tiezhu Yang @ 2025-08-26 23:43 ` Josh Poimboeuf 2025-08-28 2:01 ` Tiezhu Yang 0 siblings, 1 reply; 14+ messages in thread From: Josh Poimboeuf @ 2025-08-26 23:43 UTC (permalink / raw) To: Tiezhu Yang Cc: Huacai Chen, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S 2025-08-26 23:43 ` Josh Poimboeuf @ 2025-08-28 2:01 ` Tiezhu Yang 0 siblings, 0 replies; 14+ messages in thread From: Tiezhu Yang @ 2025-08-28 2:01 UTC (permalink / raw) To: Josh Poimboeuf Cc: Huacai Chen, Peter Zijlstra, Nathan Chancellor, loongarch, linux-kernel 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-08-28 2:01 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-08-26 6:46 [RFC PATCH 0/2] Fix objtool warnings if LTO is enabled for LoongArch (Part 2) Tiezhu Yang 2025-08-26 6:46 ` [RFC PATCH 1/2] objtool/LoongArch: Fix fall through warning about efi_boot_kernel() Tiezhu Yang 2025-08-26 8:32 ` Huacai Chen 2025-08-26 12:33 ` Tiezhu Yang 2025-08-26 13:03 ` Huacai Chen 2025-08-26 23:39 ` Josh Poimboeuf 2025-08-28 2:01 ` Tiezhu Yang 2025-08-26 6:46 ` [RFC PATCH 2/2] objtool/LoongArch: Fix unreachable instruction warnings about head.S Tiezhu Yang 2025-08-26 8:20 ` Peter Zijlstra 2025-08-26 12:27 ` Tiezhu Yang 2025-08-26 8:26 ` Huacai Chen 2025-08-26 12:30 ` Tiezhu Yang 2025-08-26 23:43 ` Josh Poimboeuf 2025-08-28 2:01 ` Tiezhu Yang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®