From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 3/4] arm64: ftrace: fix a stack trace result under function graph tracer
Date: Tue, 4 Aug 2015 16:44:08 +0900 [thread overview]
Message-ID: <1438674249-3447-4-git-send-email-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <1438674249-3447-1-git-send-email-takahiro.akashi@linaro.org>
Function graph tracer modifies a saved lr register on stack in order
to hook a function return. This results in finding many bogus entries
in a stack trace list.
This patch replaces such entries with originals values stored in
current->ret_stack[].
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
arch/arm64/kernel/stacktrace.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index 496ab0f..d1790eb 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -100,6 +100,28 @@ static void notrace arm64_stack_index(struct stackframe *frame,
/* should not go beyond this frame */
if (trace->index[x] == THREAD_SIZE)
trace->index[x] = 0;
+
+ if (trace->entries[x] ==
+ ((unsigned long)return_to_handler + 0x8)) {
+ /*
+ * This is a case where return_to_handler() is calling
+ * ftrace_return_to_handler(). As we are already on
+ * an original function's stack, we have no way to fetch
+ * a correct pc value, just skip it.
+ */
+ trace->entries[x] = 0x0;
+ } else if (trace->entries[x] ==
+ (unsigned long)return_to_handler - AARCH64_INSN_SIZE) {
+ /*
+ * This is a case where function graph tracer has
+ * modified lr register on a stack to hook a function
+ * return.
+ * So replace it to original value.
+ */
+ trace->entries[x] =
+ current->ret_stack[data->ret_stack_index--].ret
+ - AARCH64_INSN_SIZE;
+ }
}
#endif /* CONFIG_STACK_TRACER */
--
1.7.9.5
next prev parent reply other threads:[~2015-08-04 7:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 7:44 [RFC v2 0/4] arm64: ftrace: fix incorrect output from stack tracer AKASHI Takahiro
2015-08-04 7:44 ` [RFC v2 1/4] ftrace: allow arch-specific check_stack() AKASHI Takahiro
2015-08-11 17:03 ` Will Deacon
2015-08-17 6:07 ` AKASHI Takahiro
2015-08-18 8:21 ` Will Deacon
2015-08-04 7:44 ` [RFC v2 2/4] arm64: ftrace: add arch-specific stack tracer AKASHI Takahiro
2015-08-04 7:44 ` AKASHI Takahiro [this message]
2015-08-04 7:44 ` [RFC v2 4/4] arm64: ftrace: add a stack frame for exception handler AKASHI Takahiro
2015-08-11 14:57 ` Jungseok Lee
2015-08-17 5:21 ` AKASHI Takahiro
2015-08-11 14:52 ` [RFC v2 0/4] arm64: ftrace: fix incorrect output from stack tracer Jungseok Lee
2015-08-17 4:50 ` AKASHI Takahiro
2015-08-17 15:29 ` Jungseok Lee
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=1438674249-3447-4-git-send-email-takahiro.akashi@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).