summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJinyang He <hejinyang@loongson.cn>2023-01-17 11:42:16 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2023-01-17 11:42:16 +0800
commite2f27392275c7ffceb4afac1567eb325722b9ae1 (patch)
treeaf6240939a091efe2689efa358e2c8bf23ed12ee
parent3200983fa8e2c8aa17ed911b617b4a248bcb1267 (diff)
downloadlinux-stable-e2f27392275c7ffceb4afac1567eb325722b9ae1.tar.gz
linux-stable-e2f27392275c7ffceb4afac1567eb325722b9ae1.tar.bz2
linux-stable-e2f27392275c7ffceb4afac1567eb325722b9ae1.zip
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 <hejinyang@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
-rw-r--r--arch/loongarch/kernel/unwind_prologue.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/loongarch/kernel/unwind_prologue.c b/arch/loongarch/kernel/unwind_prologue.c
index 0f8d1451ebb8..e98b00432c88 100644
--- a/arch/loongarch/kernel/unwind_prologue.c
+++ b/arch/loongarch/kernel/unwind_prologue.c
@@ -56,7 +56,7 @@ static bool unwind_by_prologue(struct unwind_state *state)
{
long frame_ra = -1;
unsigned long frame_size = 0;
- unsigned long size, offset, pc = state->pc;
+ unsigned long size, offset, pc;
struct pt_regs *regs;
struct stack_info *info = &state->stack_info;
union loongarch_instruction *ip, *ip_end;
@@ -78,6 +78,11 @@ static bool unwind_by_prologue(struct unwind_state *state)
return true;
}
+ /*
+ * When 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.
+ */
+ pc = state->pc - (state->first ? 0 : LOONGARCH_INSN_SIZE);
if (!kallsyms_lookup_size_offset(pc, &size, &offset))
return false;