* [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation
@ 2025-03-21 14:10 WangYuli
2025-03-22 12:51 ` Huacai Chen
0 siblings, 1 reply; 6+ messages in thread
From: WangYuli @ 2025-03-21 14:10 UTC (permalink / raw)
To: chenhuacai, kernel
Cc: wangyuli, guanwentao, wentao, loongarch, linux-kernel, zhangqing,
zhoubinbin, lihui, rdunlap, chenhuacai, zhanjun, niecheng1
The arch_kgdb_breakpoint() function defines the kgdb_breakinst
symbol using inline assembly.
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 noline.
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
^
Additionally, remove "nop" here because it's meaningless for LoongArch
here.
Fixes: e14dd076964e ("LoongArch: Add basic KGDB & KDB support")
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>
Co-developed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Tested-by: Yuli Wang <wangyuli@uniontech.com>
Tested-by: Binbin Zhou <zhoubinbin@loongson.cn>
Signed-off-by: Yuli Wang <wangyuli@uniontech.com>
---
Changelog:
*v1->v2:
1. Drop the nop which is no effect for LoongArch here.
2. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to
avoid the objtool warning.
---
arch/loongarch/kernel/kgdb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c
index 445c452d72a7..38bd0561d7d5 100644
--- a/arch/loongarch/kernel/kgdb.c
+++ b/arch/loongarch/kernel/kgdb.c
@@ -224,13 +224,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
regs->csr_era = pc;
}
-void arch_kgdb_breakpoint(void)
+noinline void arch_kgdb_breakpoint(void)
{
__asm__ __volatile__ ( \
".globl kgdb_breakinst\n\t" \
- "nop\n" \
"kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */
}
+STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint);
/*
* Calls linux_debug_hook before the kernel dies. If KGDB is enabled,
--
2.49.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation 2025-03-21 14:10 [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation WangYuli @ 2025-03-22 12:51 ` Huacai Chen 2025-03-24 1:42 ` Jinyang He 0 siblings, 1 reply; 6+ messages in thread From: Huacai Chen @ 2025-03-22 12:51 UTC (permalink / raw) To: WangYuli Cc: kernel, guanwentao, wentao, loongarch, linux-kernel, zhoubinbin, lihui, rdunlap, chenhuacai, zhanjun, niecheng1, Tiezhu Yang, Jinyang He Hi, Tiezhu & Jinyang, On Fri, Mar 21, 2025 at 10:11 PM WangYuli <wangyuli@uniontech.com> wrote: > > The arch_kgdb_breakpoint() function defines the kgdb_breakinst > symbol using inline assembly. > > 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 noline. > > 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 > ^ > > Additionally, remove "nop" here because it's meaningless for LoongArch > here. > > Fixes: e14dd076964e ("LoongArch: Add basic KGDB & KDB support") > 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> > Co-developed-by: Huacai Chen <chenhuacai@loongson.cn> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > Tested-by: Yuli Wang <wangyuli@uniontech.com> > Tested-by: Binbin Zhou <zhoubinbin@loongson.cn> > Signed-off-by: Yuli Wang <wangyuli@uniontech.com> > --- > Changelog: > *v1->v2: > 1. Drop the nop which is no effect for LoongArch here. > 2. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to > avoid the objtool warning. > --- > arch/loongarch/kernel/kgdb.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c > index 445c452d72a7..38bd0561d7d5 100644 > --- a/arch/loongarch/kernel/kgdb.c > +++ b/arch/loongarch/kernel/kgdb.c > @@ -224,13 +224,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) > regs->csr_era = pc; > } > > -void arch_kgdb_breakpoint(void) > +noinline void arch_kgdb_breakpoint(void) > { > __asm__ __volatile__ ( \ > ".globl kgdb_breakinst\n\t" \ > - "nop\n" \ > "kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */ > } > +STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint); Is there a better solution than STACK_FRAME_NON_STANDARD()? In the past we can use annotate_reachable() in arch_kgdb_breakpoint(), but annotate_reachable() is no longer exist. Huacai > > /* > * Calls linux_debug_hook before the kernel dies. If KGDB is enabled, > -- > 2.49.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation 2025-03-22 12:51 ` Huacai Chen @ 2025-03-24 1:42 ` Jinyang He 2025-03-24 4:09 ` Huacai Chen 0 siblings, 1 reply; 6+ messages in thread From: Jinyang He @ 2025-03-24 1:42 UTC (permalink / raw) To: Huacai Chen, WangYuli Cc: kernel, guanwentao, wentao, loongarch, linux-kernel, zhoubinbin, lihui, rdunlap, chenhuacai, zhanjun, niecheng1, Tiezhu Yang On 2025-03-22 20:51, Huacai Chen wrote: > Hi, Tiezhu & Jinyang, > > On Fri, Mar 21, 2025 at 10:11 PM WangYuli <wangyuli@uniontech.com> wrote: >> The arch_kgdb_breakpoint() function defines the kgdb_breakinst >> symbol using inline assembly. >> >> 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 noline. >> >> 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 >> ^ >> >> Additionally, remove "nop" here because it's meaningless for LoongArch >> here. >> >> Fixes: e14dd076964e ("LoongArch: Add basic KGDB & KDB support") >> 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> >> Co-developed-by: Huacai Chen <chenhuacai@loongson.cn> >> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> >> Tested-by: Yuli Wang <wangyuli@uniontech.com> >> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn> >> Signed-off-by: Yuli Wang <wangyuli@uniontech.com> >> --- >> Changelog: >> *v1->v2: >> 1. Drop the nop which is no effect for LoongArch here. >> 2. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to >> avoid the objtool warning. >> --- >> arch/loongarch/kernel/kgdb.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c >> index 445c452d72a7..38bd0561d7d5 100644 >> --- a/arch/loongarch/kernel/kgdb.c >> +++ b/arch/loongarch/kernel/kgdb.c >> @@ -224,13 +224,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) >> regs->csr_era = pc; >> } >> >> -void arch_kgdb_breakpoint(void) >> +noinline void arch_kgdb_breakpoint(void) >> { >> __asm__ __volatile__ ( \ >> ".globl kgdb_breakinst\n\t" \ >> - "nop\n" \ >> "kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */ >> } >> +STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint); > Is there a better solution than STACK_FRAME_NON_STANDARD()? In the > past we can use annotate_reachable() in arch_kgdb_breakpoint(), but > annotate_reachable() is no longer exist. Maybe we can parse the imm-code of `break` and set diffrent insn_type in objtool. The BRK_KDB imply the PC will go head, while the BRK_BUG imply PC stop. (arch/loongarch/include/uapi/asm/break.h) Tiezhu, how do you think? > > Huacai > >> /* >> * Calls linux_debug_hook before the kernel dies. If KGDB is enabled, >> -- >> 2.49.0 >> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation 2025-03-24 1:42 ` Jinyang He @ 2025-03-24 4:09 ` Huacai Chen 2025-03-24 4:31 ` Jinyang He 0 siblings, 1 reply; 6+ messages in thread From: Huacai Chen @ 2025-03-24 4:09 UTC (permalink / raw) To: Jinyang He Cc: WangYuli, kernel, guanwentao, wentao, loongarch, linux-kernel, zhoubinbin, lihui, rdunlap, chenhuacai, zhanjun, niecheng1, Tiezhu Yang Hi, Jinyang, On Mon, Mar 24, 2025 at 9:42 AM Jinyang He <hejinyang@loongson.cn> wrote: > > On 2025-03-22 20:51, Huacai Chen wrote: > > > Hi, Tiezhu & Jinyang, > > > > On Fri, Mar 21, 2025 at 10:11 PM WangYuli <wangyuli@uniontech.com> wrote: > >> The arch_kgdb_breakpoint() function defines the kgdb_breakinst > >> symbol using inline assembly. > >> > >> 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 noline. > >> > >> 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 > >> ^ > >> > >> Additionally, remove "nop" here because it's meaningless for LoongArch > >> here. > >> > >> Fixes: e14dd076964e ("LoongArch: Add basic KGDB & KDB support") > >> 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> > >> Co-developed-by: Huacai Chen <chenhuacai@loongson.cn> > >> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > >> Tested-by: Yuli Wang <wangyuli@uniontech.com> > >> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn> > >> Signed-off-by: Yuli Wang <wangyuli@uniontech.com> > >> --- > >> Changelog: > >> *v1->v2: > >> 1. Drop the nop which is no effect for LoongArch here. > >> 2. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to > >> avoid the objtool warning. > >> --- > >> arch/loongarch/kernel/kgdb.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c > >> index 445c452d72a7..38bd0561d7d5 100644 > >> --- a/arch/loongarch/kernel/kgdb.c > >> +++ b/arch/loongarch/kernel/kgdb.c > >> @@ -224,13 +224,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) > >> regs->csr_era = pc; > >> } > >> > >> -void arch_kgdb_breakpoint(void) > >> +noinline void arch_kgdb_breakpoint(void) > >> { > >> __asm__ __volatile__ ( \ > >> ".globl kgdb_breakinst\n\t" \ > >> - "nop\n" \ > >> "kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */ > >> } > >> +STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint); > > Is there a better solution than STACK_FRAME_NON_STANDARD()? In the > > past we can use annotate_reachable() in arch_kgdb_breakpoint(), but > > annotate_reachable() is no longer exist. > > Maybe we can parse the imm-code of `break` and set diffrent insn_type in > objtool. > The BRK_KDB imply the PC will go head, while the BRK_BUG imply PC stop. > (arch/loongarch/include/uapi/asm/break.h) > > Tiezhu, how do you think? Touching objtool may be a little complicated, is ANNOTATE_REACHABLE() the successor of annotate_reachable()? I tried ANNOTATE_REACHABLE(kgdb_breakinst) but there was still a warning. Huacai > > > > > > Huacai > > > >> /* > >> * Calls linux_debug_hook before the kernel dies. If KGDB is enabled, > >> -- > >> 2.49.0 > >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation 2025-03-24 4:09 ` Huacai Chen @ 2025-03-24 4:31 ` Jinyang He 2025-03-24 4:53 ` Huacai Chen 0 siblings, 1 reply; 6+ messages in thread From: Jinyang He @ 2025-03-24 4:31 UTC (permalink / raw) To: Huacai Chen Cc: WangYuli, kernel, guanwentao, wentao, loongarch, linux-kernel, zhoubinbin, lihui, rdunlap, chenhuacai, zhanjun, niecheng1, Tiezhu Yang On 2025-03-24 12:09, Huacai Chen wrote: > Hi, Jinyang, > > On Mon, Mar 24, 2025 at 9:42 AM Jinyang He <hejinyang@loongson.cn> wrote: >> On 2025-03-22 20:51, Huacai Chen wrote: >> >>> Hi, Tiezhu & Jinyang, >>> >>> On Fri, Mar 21, 2025 at 10:11 PM WangYuli <wangyuli@uniontech.com> wrote: >>>> The arch_kgdb_breakpoint() function defines the kgdb_breakinst >>>> symbol using inline assembly. >>>> >>>> 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 noline. >>>> >>>> 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 >>>> ^ >>>> >>>> Additionally, remove "nop" here because it's meaningless for LoongArch >>>> here. >>>> >>>> Fixes: e14dd076964e ("LoongArch: Add basic KGDB & KDB support") >>>> 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> >>>> Co-developed-by: Huacai Chen <chenhuacai@loongson.cn> >>>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> >>>> Tested-by: Yuli Wang <wangyuli@uniontech.com> >>>> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn> >>>> Signed-off-by: Yuli Wang <wangyuli@uniontech.com> >>>> --- >>>> Changelog: >>>> *v1->v2: >>>> 1. Drop the nop which is no effect for LoongArch here. >>>> 2. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to >>>> avoid the objtool warning. >>>> --- >>>> arch/loongarch/kernel/kgdb.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c >>>> index 445c452d72a7..38bd0561d7d5 100644 >>>> --- a/arch/loongarch/kernel/kgdb.c >>>> +++ b/arch/loongarch/kernel/kgdb.c >>>> @@ -224,13 +224,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) >>>> regs->csr_era = pc; >>>> } >>>> >>>> -void arch_kgdb_breakpoint(void) >>>> +noinline void arch_kgdb_breakpoint(void) >>>> { >>>> __asm__ __volatile__ ( \ >>>> ".globl kgdb_breakinst\n\t" \ >>>> - "nop\n" \ >>>> "kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */ >>>> } >>>> +STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint); >>> Is there a better solution than STACK_FRAME_NON_STANDARD()? In the >>> past we can use annotate_reachable() in arch_kgdb_breakpoint(), but >>> annotate_reachable() is no longer exist. >> Maybe we can parse the imm-code of `break` and set diffrent insn_type in >> objtool. >> The BRK_KDB imply the PC will go head, while the BRK_BUG imply PC stop. >> (arch/loongarch/include/uapi/asm/break.h) >> >> Tiezhu, how do you think? > Touching objtool may be a little complicated, is ANNOTATE_REACHABLE() > the successor of annotate_reachable()? I tried > ANNOTATE_REACHABLE(kgdb_breakinst) but there was still a warning. Should it annotate to the next insn of `break`? Like, kgdb_breakinst: break 2 another_label: ANNOTATE_REACHABLE(another_label) Jinyang > > Huacai > >> >>> Huacai >>> >>>> /* >>>> * Calls linux_debug_hook before the kernel dies. If KGDB is enabled, >>>> -- >>>> 2.49.0 >>>> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation 2025-03-24 4:31 ` Jinyang He @ 2025-03-24 4:53 ` Huacai Chen 0 siblings, 0 replies; 6+ messages in thread From: Huacai Chen @ 2025-03-24 4:53 UTC (permalink / raw) To: Jinyang He Cc: WangYuli, kernel, guanwentao, wentao, loongarch, linux-kernel, zhoubinbin, lihui, rdunlap, chenhuacai, zhanjun, niecheng1, Tiezhu Yang On Mon, Mar 24, 2025 at 12:31 PM Jinyang He <hejinyang@loongson.cn> wrote: > > On 2025-03-24 12:09, Huacai Chen wrote: > > > Hi, Jinyang, > > > > On Mon, Mar 24, 2025 at 9:42 AM Jinyang He <hejinyang@loongson.cn> wrote: > >> On 2025-03-22 20:51, Huacai Chen wrote: > >> > >>> Hi, Tiezhu & Jinyang, > >>> > >>> On Fri, Mar 21, 2025 at 10:11 PM WangYuli <wangyuli@uniontech.com> wrote: > >>>> The arch_kgdb_breakpoint() function defines the kgdb_breakinst > >>>> symbol using inline assembly. > >>>> > >>>> 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 noline. > >>>> > >>>> 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 > >>>> ^ > >>>> > >>>> Additionally, remove "nop" here because it's meaningless for LoongArch > >>>> here. > >>>> > >>>> Fixes: e14dd076964e ("LoongArch: Add basic KGDB & KDB support") > >>>> 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> > >>>> Co-developed-by: Huacai Chen <chenhuacai@loongson.cn> > >>>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> > >>>> Tested-by: Yuli Wang <wangyuli@uniontech.com> > >>>> Tested-by: Binbin Zhou <zhoubinbin@loongson.cn> > >>>> Signed-off-by: Yuli Wang <wangyuli@uniontech.com> > >>>> --- > >>>> Changelog: > >>>> *v1->v2: > >>>> 1. Drop the nop which is no effect for LoongArch here. > >>>> 2. Add "STACK_FRAME_NON_STANDARD" for arch_kgdb_breakpoint() to > >>>> avoid the objtool warning. > >>>> --- > >>>> arch/loongarch/kernel/kgdb.c | 4 ++-- > >>>> 1 file changed, 2 insertions(+), 2 deletions(-) > >>>> > >>>> diff --git a/arch/loongarch/kernel/kgdb.c b/arch/loongarch/kernel/kgdb.c > >>>> index 445c452d72a7..38bd0561d7d5 100644 > >>>> --- a/arch/loongarch/kernel/kgdb.c > >>>> +++ b/arch/loongarch/kernel/kgdb.c > >>>> @@ -224,13 +224,13 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc) > >>>> regs->csr_era = pc; > >>>> } > >>>> > >>>> -void arch_kgdb_breakpoint(void) > >>>> +noinline void arch_kgdb_breakpoint(void) > >>>> { > >>>> __asm__ __volatile__ ( \ > >>>> ".globl kgdb_breakinst\n\t" \ > >>>> - "nop\n" \ > >>>> "kgdb_breakinst:\tbreak 2\n\t"); /* BRK_KDB = 2 */ > >>>> } > >>>> +STACK_FRAME_NON_STANDARD(arch_kgdb_breakpoint); > >>> Is there a better solution than STACK_FRAME_NON_STANDARD()? In the > >>> past we can use annotate_reachable() in arch_kgdb_breakpoint(), but > >>> annotate_reachable() is no longer exist. > >> Maybe we can parse the imm-code of `break` and set diffrent insn_type in > >> objtool. > >> The BRK_KDB imply the PC will go head, while the BRK_BUG imply PC stop. > >> (arch/loongarch/include/uapi/asm/break.h) > >> > >> Tiezhu, how do you think? > > Touching objtool may be a little complicated, is ANNOTATE_REACHABLE() > > the successor of annotate_reachable()? I tried > > ANNOTATE_REACHABLE(kgdb_breakinst) but there was still a warning. > Should it annotate to the next insn of `break`? > Like, > > kgdb_breakinst: > break 2 > another_label: > > ANNOTATE_REACHABLE(another_label) Still no help. Huacai > > Jinyang > > > > Huacai > > > >> > >>> Huacai > >>> > >>>> /* > >>>> * Calls linux_debug_hook before the kernel dies. If KGDB is enabled, > >>>> -- > >>>> 2.49.0 > >>>> > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-24 4:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-03-21 14:10 [PATCH v2] LoongArch: KGDB: Rework arch_kgdb_breakpoint() implementation WangYuli 2025-03-22 12:51 ` Huacai Chen 2025-03-24 1:42 ` Jinyang He 2025-03-24 4:09 ` Huacai Chen 2025-03-24 4:31 ` Jinyang He 2025-03-24 4:53 ` Huacai Chen
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®