Skip to content

Commit 61a5e4b

Browse files
Avenger-285714vijay-suman
authored andcommitted
riscv: KGDB: Do not inline arch_kgdb_breakpoint()
[ Upstream commit 3af4bec9c1db3f003be4d5ae09b6a737e4be1612 ] The arch_kgdb_breakpoint() function defines the kgdb_compiled_break symbol using inline assembly. There's a potential issue where the compiler might inline arch_kgdb_breakpoint(), which would then define the kgdb_compiled_break symbol multiple times, leading to fail to link vmlinux.o. This isn't merely a potential compilation problem. The intent here is to determine the global symbol address of kgdb_compiled_break, and if this function is inlined multiple times, it would logically be a grave error. Link: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/all/[email protected]/ Fixes: fe89bd2 ("riscv: Add KGDB support") Co-developed-by: Huacai Chen <[email protected]> Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: WangYuli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 854d0f048ead2cfe893d8a5349d5343c032edd4a) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 0732ea1 commit 61a5e4b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

arch/riscv/include/asm/kgdb.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@
1919

2020
#ifndef __ASSEMBLY__
2121

22+
void arch_kgdb_breakpoint(void);
2223
extern unsigned long kgdb_compiled_break;
2324

24-
static inline void arch_kgdb_breakpoint(void)
25-
{
26-
asm(".global kgdb_compiled_break\n"
27-
".option norvc\n"
28-
"kgdb_compiled_break: ebreak\n"
29-
".option rvc\n");
30-
}
31-
3225
#endif /* !__ASSEMBLY__ */
3326

3427
#define DBG_REG_ZERO "zero"

arch/riscv/kernel/kgdb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
273273
regs->epc = pc;
274274
}
275275

276+
noinline void arch_kgdb_breakpoint(void)
277+
{
278+
asm(".global kgdb_compiled_break\n"
279+
".option norvc\n"
280+
"kgdb_compiled_break: ebreak\n"
281+
".option rvc\n");
282+
}
283+
276284
void kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
277285
char *remcom_out_buffer)
278286
{

0 commit comments

Comments
 (0)