Skip to content

Commit 370a3b8

Browse files
seehearfeelchenhuacai
authored andcommitted
LoongArch: Check unwind_error() in arch_stack_walk()
We can see the following messages with CONFIG_PROVE_LOCKING=y on LoongArch: BUG: MAX_STACK_TRACE_ENTRIES too low! turning off the locking correctness validator. This is because stack_trace_save() returns a big value after call arch_stack_walk(), here is the call trace: save_trace() stack_trace_save() arch_stack_walk() stack_trace_consume_entry() arch_stack_walk() should return immediately if unwind_next_frame() failed, no need to do the useless loops to increase the value of c->len in stack_trace_consume_entry(), then we can fix the above problem. Cc: [email protected] Reported-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent e32b3b8 commit 370a3b8

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

arch/loongarch/kernel/stacktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
3030

3131
regs->regs[1] = 0;
3232
for (unwind_start(&state, task, regs);
33-
!unwind_done(&state); unwind_next_frame(&state)) {
33+
!unwind_done(&state) && !unwind_error(&state); unwind_next_frame(&state)) {
3434
addr = unwind_get_return_address(&state);
3535
if (!addr || !consume_entry(cookie, addr))
3636
break;

arch/loongarch/kernel/unwind.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ bool default_next_frame(struct unwind_state *state)
2828

2929
} while (!get_stack_info(state->sp, state->task, info));
3030

31+
state->error = true;
3132
return false;
3233
}

arch/loongarch/kernel/unwind_prologue.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static bool next_frame(struct unwind_state *state)
211211
pc = regs->csr_era;
212212

213213
if (user_mode(regs) || !__kernel_text_address(pc))
214-
return false;
214+
goto out;
215215

216216
state->first = true;
217217
state->pc = pc;
@@ -226,6 +226,8 @@ static bool next_frame(struct unwind_state *state)
226226

227227
} while (!get_stack_info(state->sp, state->task, info));
228228

229+
out:
230+
state->error = true;
229231
return false;
230232
}
231233

0 commit comments

Comments
 (0)