From: takahiro.akashi@linaro.org (AKASHI Takahiro)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v7 1/6] arm64: ftrace: modify a stack frame in a safe way
Date: Tue, 15 Dec 2015 17:33:39 +0900 [thread overview]
Message-ID: <1450168424-10010-2-git-send-email-takahiro.akashi@linaro.org> (raw)
In-Reply-To: <1450168424-10010-1-git-send-email-takahiro.akashi@linaro.org>
Function graph tracer modifies a return address (LR) in a stack frame by
calling ftrace_prepare_return() in a traced function's function prologue.
The current code does this modification before preserving an original
address at ftrace_push_return_trace() and there is always a small window
of inconsistency when an interrupt occurs.
This doesn't matter, as far as an interrupt stack is introduced, because
stack tracer won't be invoked in an interrupt context. But it would be
better to proactively minimize such a window by moving the LR modification
after ftrace_push_return_trace().
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
arch/arm64/kernel/ftrace.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index c851be7..314f82d 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -125,23 +125,20 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
* on other archs. It's unlikely on AArch64.
*/
old = *parent;
- *parent = return_hooker;
trace.func = self_addr;
trace.depth = current->curr_ret_stack + 1;
/* Only trace if the calling function expects to */
- if (!ftrace_graph_entry(&trace)) {
- *parent = old;
+ if (!ftrace_graph_entry(&trace))
return;
- }
err = ftrace_push_return_trace(old, self_addr, &trace.depth,
frame_pointer);
- if (err == -EBUSY) {
- *parent = old;
+ if (err == -EBUSY)
return;
- }
+ else
+ *parent = return_hooker;
}
#ifdef CONFIG_DYNAMIC_FTRACE
--
1.7.9.5
next prev parent reply other threads:[~2015-12-15 8:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-15 8:33 [PATCH v7 0/6] arm64: ftrace: fix incorrect output from stack tracer AKASHI Takahiro
2015-12-15 8:33 ` AKASHI Takahiro [this message]
2015-12-15 8:33 ` [PATCH v7 2/6] arm64: pass a task parameter to unwind_frame() AKASHI Takahiro
2015-12-15 8:33 ` [PATCH v7 3/6] arm64: ftrace: fix a stack tracer's output under function graph tracer AKASHI Takahiro
2015-12-15 8:33 ` [PATCH v7 4/6] arm64: insn: add instruction decoders for ldp/stp and add/sub AKASHI Takahiro
2015-12-15 8:33 ` [PATCH v7 5/6] arm64: ftrace: add arch-specific stack tracer AKASHI Takahiro
2015-12-21 12:04 ` Will Deacon
2015-12-22 6:41 ` AKASHI Takahiro
2015-12-22 9:48 ` Will Deacon
2015-12-15 8:33 ` [PATCH v7 6/6] arm64: ftrace: add a test of function prologue analyzer AKASHI Takahiro
2015-12-21 12:05 ` [PATCH v7 0/6] arm64: ftrace: fix incorrect output from stack tracer Will Deacon
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=1450168424-10010-2-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 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.