All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Leo Yan <leo.yan@linaro.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 03/13] kprobes: Add symbols for kprobe insn pages
Date: Wed, 26 Feb 2020 16:21:51 +0100	[thread overview]
Message-ID: <20200226152151.GA217283@krava> (raw)
In-Reply-To: <20200212124949.3589-4-adrian.hunter@intel.com>

On Wed, Feb 12, 2020 at 02:49:39PM +0200, Adrian Hunter wrote:
> Symbols are needed for tools to describe instruction addresses. Pages
> allocated for kprobe's purposes need symbols to be created for them.
> Add such symbols to be visible via /proc/kallsyms.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

SNIP

> @@ -272,6 +273,8 @@ static inline bool is_kprobe_##__name##_slot(unsigned long addr)	\
>  {									\
>  	return __is_insn_slot_addr(&kprobe_##__name##_slots, addr);	\
>  }
> +#define KPROBE_INSN_PAGE_SYM		"kprobe_insn_page"
> +#define KPROBE_OPTINSN_PAGE_SYM		"kprobe_optinsn_page"
>  #else /* __ARCH_WANT_KPROBES_INSN_SLOT */
>  #define DEFINE_INSN_CACHE_OPS(__name)					\
>  static inline bool is_kprobe_##__name##_slot(unsigned long addr)	\
> @@ -373,6 +376,13 @@ void dump_kprobe(struct kprobe *kp);
>  void *alloc_insn_page(void);
>  void free_insn_page(void *page);
>  
> +int kprobe_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
> +		       char *sym);
> +int kprobe_cache_get_kallsym(struct kprobe_insn_cache *c, unsigned int *symnum,
> +			     unsigned long *value, char *type, char *sym);
> +
> +int arch_kprobe_get_kallsym(unsigned int *symnum, unsigned long *value,
> +			    char *type, char *sym);
>  #else /* !CONFIG_KPROBES: */
>  
>  static inline int kprobes_built_in(void)
> @@ -435,6 +445,24 @@ static inline bool within_kprobe_blacklist(unsigned long addr)
>  {
>  	return true;
>  }
> +static inline int kprobe_get_kallsym(unsigned int symnum, unsigned long *value,
> +				     char *type, char *sym)
> +{
> +	return 0;
> +}
> +static inline int kprobe_cache_get_kallsym(struct kprobe_insn_cache *c,
> +					   unsigned int *symnum,
> +					   unsigned long *value, char *type,
> +					   char *sym)
> +{
> +	return 0;
> +}
> +static inline int arch_kprobe_get_kallsym(unsigned int *symnum,
> +					  unsigned long *value, char *type,
> +					  char *sym)
> +{
> +	return 0;
> +}

there's another arch_kprobe_get_kallsym marked as __weak,
is above function superfluous?

jirka

SNIP

> +int __weak arch_kprobe_get_kallsym(unsigned int *symnum, unsigned long *value,
> +				   char *type, char *sym)
> +{
> +	return -ERANGE;
> +}
> +
> +int kprobe_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
> +		       char *sym)
> +{
> +#ifdef __ARCH_WANT_KPROBES_INSN_SLOT
> +	if (!kprobe_cache_get_kallsym(&kprobe_insn_slots, &symnum, value, type, sym))
> +		return 0;
> +#ifdef CONFIG_OPTPROBES
> +	if (!kprobe_cache_get_kallsym(&kprobe_optinsn_slots, &symnum, value, type, sym))
> +		return 0;
> +#endif
> +#endif
> +	if (!arch_kprobe_get_kallsym(&symnum, value, type, sym))
> +		return 0;
> +	return -ERANGE;
> +}
> +
>  int __init __weak arch_populate_kprobe_blacklist(void)
>  {
>  	return 0;
> -- 
> 2.17.1
> 


  reply	other threads:[~2020-02-26 15:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 12:49 [PATCH V2 00/13] perf/x86: Add perf text poke events Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 01/13] perf: Add perf text poke event Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 02/13] perf/x86: Add support for perf text poke event for text_poke_bp_batch() callers Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 03/13] kprobes: Add symbols for kprobe insn pages Adrian Hunter
2020-02-26 15:21   ` Jiri Olsa [this message]
2020-02-28 14:02     ` Adrian Hunter
2020-02-26 15:22   ` Jiri Olsa
2020-02-27  7:13     ` Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 04/13] kprobes: Add perf ksymbol events " Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 05/13] perf/x86: Add perf text poke events for kprobes Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 06/13] ftrace: Add symbols for ftrace trampolines Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 07/13] ftrace: Add perf ksymbol events " Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 08/13] ftrace: Add perf text poke " Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 09/13] perf kcore_copy: Fix module map when there are no modules loaded Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 10/13] perf evlist: Disable 'immediate' events last Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 11/13] perf tools: Add support for PERF_RECORD_TEXT_POKE Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 12/13] perf tools: Add support for PERF_RECORD_KSYMBOL_TYPE_OOL Adrian Hunter
2020-02-12 12:49 ` [PATCH V2 13/13] perf intel-pt: Add support for text poke events Adrian Hunter
2020-02-24 13:50 ` [PATCH V2 00/13] perf/x86: Add perf " Adrian Hunter
2020-02-24 14:03   ` Jiri Olsa

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=20200226152151.GA217283@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.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.