Skip to content

Commit 29c92a4

Browse files
Avenger-285714chenhuacai
authored andcommitted
LoongArch: Rework the arch_kgdb_breakpoint() implementation
The arch_kgdb_breakpoint() function defines the kgdb_breakinst symbol using inline assembly. 1. There's a potential issue where the compiler might inline arch_kgdb_breakpoint(), which would then define the kgdb_breakinst symbol multiple times, leading to a linker error. To prevent this, declare arch_kgdb_breakpoint() as noinline. Fix follow error with LLVM-19 *only* when LTO_CLANG_FULL: LD vmlinux.o ld.lld-19: error: ld-temp.o <inline asm>:3:1: symbol 'kgdb_breakinst' is already defined kgdb_breakinst: break 2 ^ 2. Remove "nop" in the inline assembly because it's meaningless for LoongArch here. 3. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to avoid the objtool warning. Fixes: e14dd07 ("LoongArch: Add basic KGDB & KDB support") Tested-by: Binbin Zhou <zhoubinbin@loongson.cn> Co-developed-by: Winston Wen <wentao@uniontech.com> Signed-off-by: Winston Wen <wentao@uniontech.com> Co-developed-by: Wentao Guan <guanwentao@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com> Signed-off-by: Yuli Wang <wangyuli@uniontech.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 2e3bc71 commit 29c92a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/loongarch/kernel/kgdb.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/hw_breakpoint.h>
99
#include <linux/kdebug.h>
1010
#include <linux/kgdb.h>
11+
#include <linux/objtool.h>
1112
#include <linux/processor.h>
1213
#include <linux/ptrace.h>
1314
#include <linux/sched.h>
@@ -224,13 +225,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
224225
regs->csr_era = pc;
225226
}
226227

227-
void arch_kgdb_breakpoint(void)
228+
noinline void arch_kgdb_breakpoint(void)
228229
{
229230
__asm__ __volatile__ ( \
230231
".globl kgdb_breakinst\n\t" \
231-
"nop\n" \
232232
"kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */
233233
}
234+
STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint);
234235

235236
/*
236237
* Calls linux_debug_hook before the kernel dies. If KGDB is enabled,

0 commit comments

Comments
 (0)