From: Chen Zhongjin <chenzhongjin@huawei.com>
To: Guo Ren <guoren@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>,
<linux-perf-users@vger.kernel.org>, <paul.walmsley@sifive.com>,
<palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
<mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>,
<namhyung@kernel.org>, <jolsa@kernel.org>, <frederic@kernel.org>,
<vincent.chen@sifive.com>, <ardb@kernel.org>,
<mhiramat@kernel.org>, <rostedt@goodmis.org>,
<keescook@chromium.org>, <catalin.marinas@arm.com>
Subject: Re: [PATCH -next 6/7] riscv: stacktrace: Fix unwinding on ftrace_regs_call
Date: Wed, 21 Sep 2022 11:00:19 +0800 [thread overview]
Message-ID: <8b7093a5-291f-6c2f-e915-51b07d912ca1@huawei.com> (raw)
In-Reply-To: <CAJF2gTSQAzqLcJSp4B=8vPTb10+TieZXDJPAigCBgm5iVYpdTg@mail.gmail.com>
Hi,
On 2022/9/21 9:43, Guo Ren wrote:
> On Tue, Sep 20, 2022 at 11:15 PM Chen Zhongjin <chenzhongjin@huawei.com> wrote:
>> When unwinding on ftrace_regs_call, the traced function will be skipped
>> because ftrace_regs_caller doesn't save the fp and ra.
>>
>> Save the encoded fp so that we can get the pt_regs so that we can unwind
>> from ftrace_regs_call to the traced function.
>>
>> Also the pt_regs->status should be set as kernel mode.
>>
>> Stacktrace before this patch:
>>
>> Call Trace:
>> ...
>> [<ffffffff0161a0e0>] handler_pre+0x30/0x4a [kprobe_unwind]
>> [<ffffffff800bce92>] aggr_pre_handler+0x60/0x94
>> [<ffffffff80006df0>] kprobe_ftrace_handler+0x13e/0x188
>> [<ffffffff80008e7e>] ftrace_regs_call+0x8/0x10
>> [<ffffffff80002540>] do_one_initcall+0x4c/0x1f2
>> [<ffffffff8008a4e6>] do_init_module+0x56/0x210
>> ...
>>
>> Stacktrace after this patch:
>>
>> Call Trace:
>> ...
>> [<ffffffff016150e0>] handler_pre+0x30/0x4a [kprobe_unwind]
>> [<ffffffff800bce96>] aggr_pre_handler+0x60/0x94
>> [<ffffffff80006df0>] kprobe_ftrace_handler+0x13e/0x188
>> [<ffffffff80008e82>] ftrace_regs_call+0x8/0x10
>> + [<ffffffff01615000>] empty_call+0x0/0x1e [kprobe_unwind]
>> [<ffffffff80002540>] do_one_initcall+0x4c/0x1f2
>> [<ffffffff8008a4ea>] do_init_module+0x56/0x210
>> ...
>>
>> Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
>> ---
>> arch/riscv/kernel/mcount-dyn.S | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/arch/riscv/kernel/mcount-dyn.S b/arch/riscv/kernel/mcount-dyn.S
>> index d171eca623b6..56a4014c392f 100644
>> --- a/arch/riscv/kernel/mcount-dyn.S
>> +++ b/arch/riscv/kernel/mcount-dyn.S
>> @@ -10,6 +10,8 @@
>> #include <asm/asm-offsets.h>
>> #include <asm-generic/export.h>
>> #include <asm/ftrace.h>
>> +#include <asm/frame.h>
>> +#include <asm/csr.h>
>>
>> .text
>>
>> @@ -97,6 +99,11 @@
>> REG_S x29, PT_T4(sp)
>> REG_S x30, PT_T5(sp)
>> REG_S x31, PT_T6(sp)
>> +
>> +#ifdef CONFIG_FRAME_POINTER
>> + li s0, SR_PP
>> + REG_S s0, PT_STATUS(sp)
> Change another register.
>
>> +#endif
>> .endm
>>
>> .macro RESTORE_ALL
>> @@ -172,6 +179,7 @@ ENDPROC(ftrace_caller)
>> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
>> ENTRY(ftrace_regs_caller)
>> SAVE_ALL
>> + ENCODE_FRAME_POINTER
> Maybe the patch should merge with others, so separated make it hard to review.
Thanks for review!
Happy to see you have approved the ENCODE FP part.
The patches is separated just because I wanted to paste the call trace
result in commit message.
I'll merge the ENCODE_FRAME_POINTER patches all together and do this in
the cover.
Also noticed another email for your ongoing patches. I'll review them
and reply later.
Best,
Chen
next prev parent reply other threads:[~2022-09-21 3:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 15:11 [PATCH -next 0/7] riscv: Improvments for stacktrace Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 1/7] riscv: stacktrace: Replace walk_stackframe with arch_stack_walk Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 2/7] riscv: stacktrace: Introduce unwind functions Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 3/7] riscv: stacktrace: Save pt_regs in encoded fp on irq entry Chen Zhongjin
2022-09-21 2:13 ` Guo Ren
2022-09-20 15:11 ` [PATCH -next 4/7] riscv: syscall: Don't clobber s0 when syscall Chen Zhongjin
2022-09-21 1:30 ` Guo Ren
2022-09-21 2:16 ` Guo Ren
2022-09-20 15:12 ` [PATCH -next 5/7] riscv: stacktrace: Implement stacktrace for irq Chen Zhongjin
2022-09-20 15:12 ` [PATCH -next 6/7] riscv: stacktrace: Fix unwinding on ftrace_regs_call Chen Zhongjin
2022-09-21 1:43 ` Guo Ren
2022-09-21 3:00 ` Chen Zhongjin [this message]
2022-09-20 15:12 ` [PATCH -next 7/7] riscv: stacktrace: Fix unwinding on __kretporbe_trampoline Chen Zhongjin
2022-09-21 2:30 ` [PATCH -next 0/7] riscv: Improvments for stacktrace Guo Ren
2022-09-21 12:33 ` Chen Zhongjin
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=8b7093a5-291f-6c2f-e915-51b07d912ca1@huawei.com \
--to=chenzhongjin@huawei.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=frederic@kernel.org \
--cc=guoren@kernel.org \
--cc=jolsa@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.chen@sifive.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
all inboxes | Powered by JetHome®