All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinyang He <hejinyang@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	Qing Zhang <zhangqing@loongson.cn>
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Subject: [PATCH v2 3/6] LoongArch: Adjust PC value when unwind next frame in prologue unwinder
Date: Thu, 29 Dec 2022 14:15:14 +0800	[thread overview]
Message-ID: <20221229061516.31671-4-hejinyang@loongson.cn> (raw)
In-Reply-To: <20221229061516.31671-1-hejinyang@loongson.cn>

When state->first is not set, the PC is a return address in the
previous frame. We need to adjust it value in case overflow to the
next symbol.

Signed-off-by: Jinyang He <hejinyang@loongson.cn>
---
 arch/loongarch/kernel/unwind_prologue.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/kernel/unwind_prologue.c b/arch/loongarch/kernel/unwind_prologue.c
index 3fbb9c65d64e..f7994ed05f04 100644
--- a/arch/loongarch/kernel/unwind_prologue.c
+++ b/arch/loongarch/kernel/unwind_prologue.c
@@ -48,7 +48,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;
@@ -70,6 +70,10 @@ 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 it 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;
 
-- 
2.34.3


  parent reply	other threads:[~2022-12-29  6:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29  6:15 [PATCH v2 0/5] LoongArch: Some fix and new features for unwinders Jinyang He
2022-12-29  6:15 ` [PATCH v2 1/6] LoongArch: Get frame info in unwind_start when regs is not supported Jinyang He
2022-12-29  6:15 ` [PATCH v2 2/6] LoongArch: Use correct sp value to get graph addr in unwinder guess Jinyang He
2022-12-29  6:15 ` Jinyang He [this message]
2022-12-29  6:15 ` [PATCH v2 4/6] LoongArch: Strip guess_unwinder out from prologue_unwinder Jinyang He
2023-01-01  9:56   ` Huacai Chen
2023-01-03  8:40     ` Jinyang He
2023-01-03  8:58       ` Huacai Chen
2022-12-29  6:15 ` [PATCH v2 5/6] LoongArch: Add generic ex-handler unwind in prologue unwinder Jinyang He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221229061516.31671-4-hejinyang@loongson.cn \
    --to=hejinyang@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zhangqing@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.