[PATCH] Revert "LoongArch: Remove unnecessary checks for ORC unwinder"

Tiezhu Yang posted 1 patch 4 weeks ago
There is a newer version of this series
arch/loongarch/kernel/unwind_orc.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
[PATCH] Revert "LoongArch: Remove unnecessary checks for ORC unwinder"
Posted by Tiezhu Yang 4 weeks ago
This reverts commit 4cd641a79e69270a062777f64a0dd330abb9044a.

The system can not boot normally with the latest kernel 6.19-rc5 under
different configs, commit 4cd641a79e69 ("LoongArch: Remove unnecessary
checks for ORC unwinder") is the first bad commit since 6.19-rc4, just
revert it first before finding the root cause.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/loongarch/kernel/unwind_orc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/arch/loongarch/kernel/unwind_orc.c b/arch/loongarch/kernel/unwind_orc.c
index 8a6e3429a860..710f82d73797 100644
--- a/arch/loongarch/kernel/unwind_orc.c
+++ b/arch/loongarch/kernel/unwind_orc.c
@@ -352,6 +352,12 @@ static inline unsigned long bt_address(unsigned long ra)
 {
 	extern unsigned long eentry;
 
+	if (__kernel_text_address(ra))
+		return ra;
+
+	if (__module_text_address(ra))
+		return ra;
+
 	if (ra >= eentry && ra < eentry +  EXCCODE_INT_END * VECSIZE) {
 		unsigned long func;
 		unsigned long type = (ra - eentry) / VECSIZE;
@@ -369,13 +375,10 @@ static inline unsigned long bt_address(unsigned long ra)
 			break;
 		}
 
-		ra = func + offset;
+		return func + offset;
 	}
 
-	if (__kernel_text_address(ra))
-		return ra;
-
-	return 0;
+	return ra;
 }
 
 bool unwind_next_frame(struct unwind_state *state)
@@ -498,6 +501,9 @@ bool unwind_next_frame(struct unwind_state *state)
 		goto err;
 	}
 
+	if (!__kernel_text_address(state->pc))
+		goto err;
+
 	return true;
 
 err:
-- 
2.42.0
Re: [PATCH] Revert "LoongArch: Remove unnecessary checks for ORC unwinder"
Posted by Huacai Chen 4 weeks ago
Hi, Tiezhu,

On Mon, Jan 12, 2026 at 5:15 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> This reverts commit 4cd641a79e69270a062777f64a0dd330abb9044a.
>
> The system can not boot normally with the latest kernel 6.19-rc5 under
> different configs, commit 4cd641a79e69 ("LoongArch: Remove unnecessary
> checks for ORC unwinder") is the first bad commit since 6.19-rc4, just
> revert it first before finding the root cause.
Can you show the errors in the boot log?

Huacai
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/loongarch/kernel/unwind_orc.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/arch/loongarch/kernel/unwind_orc.c b/arch/loongarch/kernel/unwind_orc.c
> index 8a6e3429a860..710f82d73797 100644
> --- a/arch/loongarch/kernel/unwind_orc.c
> +++ b/arch/loongarch/kernel/unwind_orc.c
> @@ -352,6 +352,12 @@ static inline unsigned long bt_address(unsigned long ra)
>  {
>         extern unsigned long eentry;
>
> +       if (__kernel_text_address(ra))
> +               return ra;
> +
> +       if (__module_text_address(ra))
> +               return ra;
> +
>         if (ra >= eentry && ra < eentry +  EXCCODE_INT_END * VECSIZE) {
>                 unsigned long func;
>                 unsigned long type = (ra - eentry) / VECSIZE;
> @@ -369,13 +375,10 @@ static inline unsigned long bt_address(unsigned long ra)
>                         break;
>                 }
>
> -               ra = func + offset;
> +               return func + offset;
>         }
>
> -       if (__kernel_text_address(ra))
> -               return ra;
> -
> -       return 0;
> +       return ra;
>  }
>
>  bool unwind_next_frame(struct unwind_state *state)
> @@ -498,6 +501,9 @@ bool unwind_next_frame(struct unwind_state *state)
>                 goto err;
>         }
>
> +       if (!__kernel_text_address(state->pc))
> +               goto err;
> +
>         return true;
>
>  err:
> --
> 2.42.0
>
>
Re: [PATCH] Revert "LoongArch: Remove unnecessary checks for ORC unwinder"
Posted by Tiezhu Yang 3 weeks, 6 days ago
On 2026/1/12 下午5:23, Huacai Chen wrote:
> Hi, Tiezhu,
> 
> On Mon, Jan 12, 2026 at 5:15 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>> This reverts commit 4cd641a79e69270a062777f64a0dd330abb9044a.
>>
>> The system can not boot normally with the latest kernel 6.19-rc5 under
>> different configs, commit 4cd641a79e69 ("LoongArch: Remove unnecessary
>> checks for ORC unwinder") is the first bad commit since 6.19-rc4, just
>> revert it first before finding the root cause.
> Can you show the errors in the boot log?

Please see the coming v2 patch, there are more info in the commit
message.

Thanks,
Tiezhu

Re: [PATCH] Revert "LoongArch: Remove unnecessary checks for ORC unwinder"
Posted by Huacai Chen 3 weeks, 5 days ago
On Tue, Jan 13, 2026 at 9:17 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> On 2026/1/12 下午5:23, Huacai Chen wrote:
> > Hi, Tiezhu,
> >
> > On Mon, Jan 12, 2026 at 5:15 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >>
> >> This reverts commit 4cd641a79e69270a062777f64a0dd330abb9044a.
> >>
> >> The system can not boot normally with the latest kernel 6.19-rc5 under
> >> different configs, commit 4cd641a79e69 ("LoongArch: Remove unnecessary
> >> checks for ORC unwinder") is the first bad commit since 6.19-rc4, just
> >> revert it first before finding the root cause.
> > Can you show the errors in the boot log?
>
> Please see the coming v2 patch, there are more info in the commit
> message.
I also see "cannot find unwind pc at" when I debug KASAN, but since
KASAN is not enabled by default, we don't need to revert it.

And I have dumped one of the call traces of this message, hope it is
helpful for you.

[<9000000004ec3c9c>] show_stack+0x5c/0x190
[<9000000006c1889c>] dump_stack_lvl+0x6c/0x9c
[<9000000004ed6d08>] unwind_next_frame+0x998/0x9c0
[<9000000004ed1fd4>] arch_stack_walk+0xd4/0x1b0
[<90000000050313e4>] stack_trace_save+0x54/0x90
[<90000000052bd880>] kasan_save_stack+0x30/0x60
[<90000000052c0368>] __kasan_record_aux_stack+0x108/0x130
[<9000000004f521c0>] task_work_add+0x100/0x300
[<9000000004f77c58>] sched_tick+0x138/0x440
[<9000000005036460>] update_process_times+0xf0/0x160
[<900000000504fb38>] tick_nohz_handler+0xf8/0x260
[<900000000503731c>] __hrtimer_run_queues+0x20c/0x330
[<9000000005038bb0>] hrtimer_interrupt+0x1a0/0x3f0
[<9000000004ec86ec>] constant_timer_interrupt+0x5c/0x80
[<9000000004fe9dcc>] __handle_irq_event_percpu+0x6c/0x190
[<9000000004fe9f04>] handle_irq_event_percpu+0x14/0xa0
[<9000000004ff3eec>] handle_percpu_irq+0x8c/0xe0
[<9000000004fe8eb0>] generic_handle_domain_irq+0x50/0xc0
[<9000000005caf8b4>] handle_cpu_irq+0x54/0x90
[<9000000006c18d88>] handle_loongarch_irq+0x28/0x40
[<9000000006c18e64>] do_vint+0xc4/0xf0

Huacai

>
> Thanks,
> Tiezhu
>
>