All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Hyeoncheol Lee <cheol.lee@lge.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	Oleg Nesterov <oleg@redhat.com>,
	"zhangwei(Jovi)" <jovi.zhangwei@huawei.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Subject: Re: [PATCH 12/13] tracing/uprobes: Add more fetch functions
Date: Tue, 27 Aug 2013 21:03:32 +0900	[thread overview]
Message-ID: <521C9594.30901@hitachi.com> (raw)
In-Reply-To: <1377593336-16828-13-git-send-email-namhyung@kernel.org>

(2013/08/27 17:48), Namhyung Kim wrote:
> From: Namhyung Kim <namhyung.kim@lge.com>
> 
> Implement uprobe-specific stack and memory fetch functions and add
> them to the uprobes_fetch_type_table.  Other fetch fucntions will be
> shared with kprobes.
> 
> Original-patch-by: Hyeoncheol Lee <cheol.lee@lge.com>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: zhangwei(Jovi) <jovi.zhangwei@huawei.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  kernel/trace/trace_probe.c  |   9 ++-
>  kernel/trace/trace_probe.h  |   1 +
>  kernel/trace/trace_uprobe.c | 188 +++++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 192 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index eaee44d5d9d1..70cd3bfde5a6 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -101,6 +101,10 @@ struct deref_fetch_param {
>  	fetch_func_t		fetch_size;
>  };
>  
> +/*
> + * For uprobes, it'll get a vaddr from first call_fetch() so pass NULL
> + * as a priv on the second dprm->fetch() not to translate it to vaddr again.
> + */
>  #define DEFINE_FETCH_deref(type)					\
>  __kprobes void FETCH_FUNC_NAME(deref, type)(struct pt_regs *regs,	\
>  				    void *data, void *dest, void *priv)	\
> @@ -110,13 +114,14 @@ __kprobes void FETCH_FUNC_NAME(deref, type)(struct pt_regs *regs,	\
>  	call_fetch(&dprm->orig, regs, &addr, priv);			\
>  	if (addr) {							\
>  		addr += dprm->offset;					\
> -		dprm->fetch(regs, (void *)addr, dest, priv);		\
> +		dprm->fetch(regs, (void *)addr, dest, NULL);		\
>  	} else								\
>  		*(type *)dest = 0;					\
>  }
>  DEFINE_BASIC_FETCH_FUNCS(deref)
>  DEFINE_FETCH_deref(string)
>  
> +/* Same as above */
>  __kprobes void FETCH_FUNC_NAME(deref, string_size)(struct pt_regs *regs,
>  					void *data, void *dest, void *priv)
>  {
> @@ -126,7 +131,7 @@ __kprobes void FETCH_FUNC_NAME(deref, string_size)(struct pt_regs *regs,
>  	call_fetch(&dprm->orig, regs, &addr, priv);
>  	if (addr && dprm->fetch_size) {
>  		addr += dprm->offset;
> -		dprm->fetch_size(regs, (void *)addr, dest, priv);
> +		dprm->fetch_size(regs, (void *)addr, dest, NULL);
>  	} else
>  		*(string_size *)dest = 0;
>  }
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index fc7edf3749ef..b1e7d722c354 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -263,6 +263,7 @@ ASSIGN_FETCH_FUNC(bitfield, ftype),			\
>  #define NR_FETCH_TYPES		10
>  
>  extern const struct fetch_type kprobes_fetch_type_table[];
> +extern const struct fetch_type uprobes_fetch_type_table[];
>  
>  static inline __kprobes void call_fetch(struct fetch_param *fprm,
>  				 struct pt_regs *regs, void *dest, void *priv)
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index fc5f8aa62156..89d4b86abbe1 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -530,6 +530,186 @@ static const struct file_operations uprobe_profile_ops = {
>  	.release	= seq_release,
>  };
>  
> +#ifdef CONFIG_STACK_GROWSUP
> +static unsigned long adjust_stack_addr(unsigned long addr, unsigned n)
> +{
> +	return addr - (n * sizeof(long));
> +}
> +
> +static bool within_user_stack(struct vm_area_struct *vma, unsigned long addr,
> +			      unsigned int n)
> +{
> +	return vma->vm_start <= adjust_stack_addr(addr, n);
> +}
> +#else
> +static unsigned long adjust_stack_addr(unsigned long addr, unsigned n)
> +{
> +	return addr + (n * sizeof(long));
> +}
> +
> +static bool within_user_stack(struct vm_area_struct *vma, unsigned long addr,
> +			      unsigned int n)
> +{
> +	return vma->vm_end >= adjust_stack_addr(addr, n);
> +}
> +#endif
> +
> +static unsigned long get_user_stack_nth(struct pt_regs *regs, unsigned int n)
> +{
> +	struct vm_area_struct *vma;
> +	unsigned long addr = GET_USP(regs);

I recommend you to use user_stack_pointer() rather than GET_USP here.
Since some arch seem not to have correct GET_USP implementation (e.g. arm),
kernel build will be failed.

And at least trace_probe.c part is good for me.

Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thank you,

-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



  reply	other threads:[~2013-08-27 12:03 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-27  8:48 [PATCHSET 00/13] tracing/uprobes: Add support for more fetch methods (v4) Namhyung Kim
2013-08-27  8:48 ` [PATCH 01/13] tracing/uprobes: Fix documentation of uprobe registration syntax Namhyung Kim
2013-08-27  8:48 ` [PATCH 02/13] tracing/probes: Fix basic print type functions Namhyung Kim
2013-08-27  8:48 ` [PATCH 03/13] tracing/kprobes: Move fetch functions to trace_kprobe.c Namhyung Kim
2013-08-27  8:48 ` [PATCH 04/13] tracing/kprobes: Add fetch{,_size} member into deref fetch method Namhyung Kim
2013-08-27  8:48 ` [PATCH 05/13] tracing/kprobes: Staticize stack and memory fetch functions Namhyung Kim
2013-08-27  8:48 ` [PATCH 06/13] tracing/kprobes: Factor out struct trace_probe Namhyung Kim
2013-08-27  8:48 ` [PATCH 07/13] tracing/uprobes: Convert to " Namhyung Kim
2013-08-27  8:48 ` [PATCH 08/13] tracing/kprobes: Move common functions to trace_probe.h Namhyung Kim
2013-08-27  8:48 ` [PATCH 09/13] tracing/kprobes: Integrate duplicate set_print_fmt() Namhyung Kim
2013-08-27  8:48 ` [PATCH 10/13] tracing/uprobes: Fetch args before reserving a ring buffer Namhyung Kim
2013-08-27  8:48 ` [PATCH 11/13] tracing/kprobes: Add priv argument to fetch functions Namhyung Kim
2013-08-27  8:48 ` [PATCH 12/13] tracing/uprobes: Add more " Namhyung Kim
2013-08-27 12:03   ` Masami Hiramatsu [this message]
2013-08-28  5:37     ` Namhyung Kim
2013-08-27  8:48 ` [PATCH 13/13] tracing/uprobes: Add support for full argument access methods Namhyung Kim
2013-08-27 11:54   ` Masami Hiramatsu
2013-08-28  5:41     ` Namhyung Kim
2013-08-28 11:17       ` Masami Hiramatsu
  -- strict thread matches above, loose matches on Subject: below --
2013-10-29  6:53 [PATCHSET 00/13] tracing/uprobes: Add support for more fetch methods (v6) Namhyung Kim
2013-10-29  6:53 ` [PATCH 12/13] tracing/uprobes: Add more fetch functions Namhyung Kim
2013-10-31 18:22   ` Oleg Nesterov
2013-11-04  8:50     ` Namhyung Kim
2013-11-04 16:44       ` Oleg Nesterov
2013-11-04 17:17         ` Steven Rostedt
2013-11-05  2:19           ` Namhyung Kim
2013-11-05  2:17         ` Namhyung Kim
2013-11-01 17:53   ` Oleg Nesterov
2013-09-03  5:44 [PATCHSET 00/13] tracing/uprobes: Add support for more fetch methods (v5) Namhyung Kim
2013-09-03  5:44 ` [PATCH 12/13] tracing/uprobes: Add more fetch functions Namhyung Kim
2013-08-09  8:44 [PATCHSET 00/13] tracing/uprobes: Add support for more fetch methods (v3) Namhyung Kim
2013-08-09  8:45 ` [PATCH 12/13] tracing/uprobes: Add more fetch functions Namhyung Kim

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=521C9594.30901@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=acme@ghostprotocols.net \
    --cc=cheol.lee@lge.com \
    --cc=jovi.zhangwei@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.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 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.