Skip to content

Commit e2f2739

Browse files
MQ-mengqingchenhuacai
authored andcommitted
LoongArch: Adjust PC value when unwind next frame in unwinder
When state->first is not set, the PC is a return address in the previous frame. We need to adjust its value in case overflow to the next symbol. Signed-off-by: Jinyang He <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 3200983 commit e2f2739

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/loongarch/kernel/unwind_prologue.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static bool unwind_by_prologue(struct unwind_state *state)
5656
{
5757
long frame_ra = -1;
5858
unsigned long frame_size = 0;
59-
unsigned long size, offset, pc = state->pc;
59+
unsigned long size, offset, pc;
6060
struct pt_regs *regs;
6161
struct stack_info *info = &state->stack_info;
6262
union loongarch_instruction *ip, *ip_end;
@@ -78,6 +78,11 @@ static bool unwind_by_prologue(struct unwind_state *state)
7878
return true;
7979
}
8080

81+
/*
82+
* When first is not set, the PC is a return address in the previous frame.
83+
* We need to adjust its value in case overflow to the next symbol.
84+
*/
85+
pc = state->pc - (state->first ? 0 : LOONGARCH_INSN_SIZE);
8186
if (!kallsyms_lookup_size_offset(pc, &size, &offset))
8287
return false;
8388

0 commit comments

Comments
 (0)