From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
yrl.pp-manager.tt@hitachi.com
Subject: Re: [PATCH 6/6][RFC] kprobes: Allow probe on ftrace reserved text (but move it)
Date: Thu, 26 Apr 2012 19:12:41 +0900 [thread overview]
Message-ID: <4F991F99.8050301@hitachi.com> (raw)
In-Reply-To: <20120426023708.577576476@goodmis.org>
(2012/04/26 11:29), Steven Rostedt wrote:
> From: Steven Rostedt <srostedt@redhat.com>
>
> If a probe is placed on a ftrace nop (or ftrace_caller), simply move the
> probe to the next instruction instead of rejecting it. This will allow
> kprobes not to be affected by ftrace using the -mfentry gcc option which
> will put the ftrace nop at the beginning of the function. As a very common
> case for kprobes is to add a probe to the very beginning of a function
> we need a way to handle the case when ftrace takes the first instruction.
Hmm, I think you'd better introduce a flag(KPROBE_FLAG_MOVED) for
adjustment of probed IP address. Caller or handler can fixup its IP
or kprobes itself can do it.
>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> kernel/kprobes.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index c62b854..560d80e 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1319,10 +1319,20 @@ int __kprobes register_kprobe(struct kprobe *p)
> struct kprobe *old_p;
> struct module *probed_mod;
> kprobe_opcode_t *addr;
> + unsigned long ftrace_addr;
>
> addr = kprobe_addr(p);
> if (IS_ERR(addr))
> return PTR_ERR(addr);
> +
> + /*
> + * If the address is located on a ftrace nop, set the
> + * breakpoint to the following instruction.
> + */
> + ftrace_addr = ftrace_location((unsigned long)addr);
> + if (unlikely(ftrace_addr))
> + addr = (kprobe_opcode_t *)(ftrace_addr + MCOUNT_INSN_SIZE);
And also, you may need to use ftrace_text_reserved() here,
or need a void ftrace_location() function for CONFIG_DYNAMIC_FTRACE=n.
> +
> p->addr = addr;
>
> ret = check_kprobe_rereg(p);
> @@ -1333,7 +1343,6 @@ int __kprobes register_kprobe(struct kprobe *p)
> preempt_disable();
> if (!kernel_text_address((unsigned long) p->addr) ||
> in_kprobes_functions((unsigned long) p->addr) ||
> - ftrace_text_reserved(p->addr, p->addr) ||
> jump_label_text_reserved(p->addr, p->addr)) {
> ret = -EINVAL;
> goto cannot_probe;
Thanks,
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2012-04-26 10:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 2:29 [PATCH 0/6][RFC] tracing/kprobes: Get ready for -mfentry Steven Rostedt
2012-04-26 2:29 ` [PATCH 1/6][RFC] ftrace: Sort all function addresses, not just per page Steven Rostedt
2012-04-26 2:29 ` [PATCH 2/6][RFC] ftrace: Remove extra helper functions Steven Rostedt
2012-04-26 2:29 ` [PATCH 3/6][RFC] ftrace: Speed up search by skipping pages by address Steven Rostedt
2012-04-26 2:29 ` [PATCH 4/6][RFC] ftrace: Consolidate ftrace_location() and ftrace_text_reserved() Steven Rostedt
2012-04-26 2:29 ` [PATCH 5/6][RFC] ftrace: Return record ip addr for ftrace_location() Steven Rostedt
2012-04-26 2:29 ` [PATCH 6/6][RFC] kprobes: Allow probe on ftrace reserved text (but move it) Steven Rostedt
2012-04-26 10:12 ` Masami Hiramatsu [this message]
2012-04-27 14:01 ` Steven Rostedt
2012-04-27 15:29 ` Frank Ch. Eigler
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=4F991F99.8050301@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=yrl.pp-manager.tt@hitachi.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