From: Paul Walmsley <pjw@kernel.org>
To: Rui Qi <qirui.001@bytedance.com>
Cc: Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 2/2] riscv: stacktrace: Use %pB for backtrace display
Date: Thu, 4 Jun 2026 18:33:13 -0600 (MDT) [thread overview]
Message-ID: <4197ee54-6c69-cb72-5966-c60ba321a6fa@kernel.org> (raw)
In-Reply-To: <20260603115329.791603-3-qirui.001@bytedance.com>
On Wed, 3 Jun 2026, Rui Qi wrote:
> The print_trace_address callback uses print_ip_sym which formats
> addresses with %pS. This does not adjust the address before symbol
> lookup, so when a noreturn function (e.g. panic, do_exit) is the last
> call in a function, the saved return address can point to the start of
> the next function, and kallsyms resolves it to the wrong symbol.
>
> The kernel provides %pB (sprint_backtrace) specifically for this
> purpose: it subtracts 1 from the address before symbol lookup, which
> is sufficient to fall back into the calling function range. x86 uses
> %pB in its printk_stack_address for the same reason.
>
> Replace print_ip_sym with a direct printk using %pB, matching the
> pattern used by x86.
>
> Signed-off-by: Rui Qi <qirui.001@bytedance.com>
The Sashiko review mentions that the x86 backtrace code uses %pS for exact
instruction pointers coming from registers (show_regs_if_on_stack()), vs.
%pB for return addresses on the stack (printk_stack_address()):
https://sashiko.dev/#/patchset/20260603115329.791603-1-qirui.001%40bytedance.com
Do we need to incorporate similar logic?
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-06-05 0:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 11:53 [PATCH v1 0/2] riscv: stacktrace: Fix return address handling in non-FP unwinder Rui Qi
2026-06-03 11:53 ` [PATCH v1 1/2] riscv: stacktrace: Remove bogus -0x4 offset in non-FP walk_stackframe Rui Qi
2026-06-04 23:41 ` Paul Walmsley
2026-06-03 11:53 ` [PATCH v1 2/2] riscv: stacktrace: Use %pB for backtrace display Rui Qi
2026-06-05 0:33 ` Paul Walmsley [this message]
2026-06-05 8:12 ` Rui Qi
2026-06-05 8:20 ` [PATCH v2 0/2] riscv: stacktrace: Fix return address handling in non-FP unwinder Rui Qi
2026-06-05 8:20 ` [PATCH v2 1/2] riscv: stacktrace: Remove bogus -0x4 offset in non-FP walk_stackframe Rui Qi
2026-06-05 8:20 ` [PATCH v2 2/2] riscv: stacktrace: Use %pB for return addresses and %pS for exact IPs Rui Qi
2026-06-07 5:10 ` [PATCH v2 0/2] riscv: stacktrace: Fix return address handling in non-FP unwinder patchwork-bot+linux-riscv
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=4197ee54-6c69-cb72-5966-c60ba321a6fa@kernel.org \
--to=pjw@kernel.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=qirui.001@bytedance.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox