[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250917112716.24415-3-yangtiezhu@loongson.cn>
Date: Wed, 17 Sep 2025 19:27:15 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Josh Poimboeuf <jpoimboe@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Huacai Chen <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH v3 2/3] LoongArch: Fix unreachable instruction warnings about head.S
When compiling with LLVM and CONFIG_LTO_CLANG is set, there exist the
following objtool warnings:
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.
After many discussions, it is not proper to ignore .head.text section
in objtool or put them from text section to data section, so just give
UNWIND_HINT_UNDEFINED to fix the warnings in the image header and also
give UNWIND_HINT_END_OF_STACK to fix the warnings in the entry points.
By the way, 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
This is because the previous instructions of kernel_entry+0xf4 and
smpboot_entry+0x68 are the 'bl' instructions, start_kernel() and
start_secondary() are the respective call destination symbols which
are noreturn functions, then the 'bl' instructions are already marked
as dead end in annotate_call_site().
For now, it is time to remove "OBJECT_FILES_NON_STANDARD_head.o := y"
in arch/loongarch/kernel/Makefile.
Link: https://lore.kernel.org/lkml/20250814083651.GR4067720@noisy.programming.kicks-ass.net/
Link: https://lore.kernel.org/lkml/CAAhV-H6A_swQmqpWHp6ryAEvc96CAMOMd2ZGyJEVNMsJfLkz6w@mail.gmail.com/
Suggested-by: Peter Zijlstra <peterz@...radead.org>
Suggested-by: Huacai Chen <chenhuacai@...nel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
arch/loongarch/kernel/Makefile | 2 --
arch/loongarch/kernel/head.S | 7 +++----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/loongarch/kernel/Makefile b/arch/loongarch/kernel/Makefile
index 6f5a4574a911..4302c5b0a201 100644
--- a/arch/loongarch/kernel/Makefile
+++ b/arch/loongarch/kernel/Makefile
@@ -3,8 +3,6 @@
# Makefile for the Linux/LoongArch kernel.
#
-OBJECT_FILES_NON_STANDARD_head.o := y
-
always-$(KBUILD_BUILTIN) := vmlinux.lds
obj-y += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S
index e3865e92a917..c62dab32a06b 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) */
@@ -42,6 +43,7 @@ SYM_DATA(kernel_fsize, .long _kernel_fsize);
.align 12
SYM_CODE_START(kernel_entry) # kernel entry point
+ UNWIND_HINT_END_OF_STACK
/* Config direct window and set PG */
SETUP_DMWINS t0
@@ -109,8 +111,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 +120,7 @@ SYM_CODE_END(kernel_entry)
* function after setting up the stack and tp registers.
*/
SYM_CODE_START(smpboot_entry)
+ UNWIND_HINT_END_OF_STACK
SETUP_DMWINS t0
JUMP_VIRT_ADDR t0, t1
@@ -142,8 +143,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
Powered by blists - more mailing lists