public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com,
	davem@davemloft.net, mhiramat@kernel.org,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn
Date: Thu, 13 May 2021 08:44:09 +0900	[thread overview]
Message-ID: <20210513084409.0172212de7f567605da9a336@kernel.org> (raw)
In-Reply-To: <46998c941d0a5664daaeb92998391aace015eddf.1620829724.git.christophe.leroy@csgroup.eu>

On Wed, 12 May 2021 14:29:27 +0000 (UTC)
Christophe Leroy <christophe.leroy@csgroup.eu> wrote:

> Commit 51c9c0843993 ("powerpc/kprobes: Implement Optprobes")
> implemented a powerpc specific version of optinsn in order
> to workaround the 32Mb limitation for direct branches.
> 
> Instead of implementing a dedicated powerpc version, use the
> common optinsn and override the allocation and freeing functions.
> 
> This also indirectly remove the CLANG warning about
> is_kprobe_ppc_optinsn_slot() not being use, and the powerpc will
> now benefit from commit 5b485629ba0d ("kprobes, extable: Identify
> kprobes trampolines as kernel text area")
> 

This looks good to me.

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

> Suggested-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
>  arch/powerpc/kernel/optprobes.c | 23 +++++------------------
>  1 file changed, 5 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/optprobes.c b/arch/powerpc/kernel/optprobes.c
> index cdf87086fa33..a370190cd02a 100644
> --- a/arch/powerpc/kernel/optprobes.c
> +++ b/arch/powerpc/kernel/optprobes.c
> @@ -31,11 +31,9 @@
>  #define TMPL_END_IDX		\
>  	(optprobe_template_end - optprobe_template_entry)
>  
> -DEFINE_INSN_CACHE_OPS(ppc_optinsn);
> -
>  static bool insn_page_in_use;
>  
> -static void *__ppc_alloc_insn_page(void)
> +void *alloc_optinsn_page(void)
>  {
>  	if (insn_page_in_use)
>  		return NULL;
> @@ -43,20 +41,11 @@ static void *__ppc_alloc_insn_page(void)
>  	return &optinsn_slot;
>  }
>  
> -static void __ppc_free_insn_page(void *page __maybe_unused)
> +void free_optinsn_page(void *page)
>  {
>  	insn_page_in_use = false;
>  }
>  
> -struct kprobe_insn_cache kprobe_ppc_optinsn_slots = {
> -	.mutex = __MUTEX_INITIALIZER(kprobe_ppc_optinsn_slots.mutex),
> -	.pages = LIST_HEAD_INIT(kprobe_ppc_optinsn_slots.pages),
> -	/* insn_size initialized later */
> -	.alloc = __ppc_alloc_insn_page,
> -	.free = __ppc_free_insn_page,
> -	.nr_garbage = 0,
> -};
> -
>  /*
>   * Check if we can optimize this probe. Returns NIP post-emulation if this can
>   * be optimized and 0 otherwise.
> @@ -136,7 +125,7 @@ NOKPROBE_SYMBOL(optimized_callback);
>  void arch_remove_optimized_kprobe(struct optimized_kprobe *op)
>  {
>  	if (op->optinsn.insn) {
> -		free_ppc_optinsn_slot(op->optinsn.insn, 1);
> +		free_optinsn_slot(op->optinsn.insn, 1);
>  		op->optinsn.insn = NULL;
>  	}
>  }
> @@ -203,14 +192,12 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
>  	unsigned long nip, size;
>  	int rc, i;
>  
> -	kprobe_ppc_optinsn_slots.insn_size = MAX_OPTINSN_SIZE;
> -
>  	nip = can_optimize(p);
>  	if (!nip)
>  		return -EILSEQ;
>  
>  	/* Allocate instruction slot for detour buffer */
> -	buff = get_ppc_optinsn_slot();
> +	buff = get_optinsn_slot();
>  	if (!buff)
>  		return -ENOMEM;
>  
> @@ -297,7 +284,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
>  	return 0;
>  
>  error:
> -	free_ppc_optinsn_slot(buff, 0);
> +	free_optinsn_slot(buff, 0);
>  	return -ERANGE;
>  
>  }
> -- 
> 2.25.0
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  parent reply	other threads:[~2021-05-12 23:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 14:29 [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation Christophe Leroy
2021-05-12 14:29 ` [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn Christophe Leroy
2021-05-12 17:29   ` kernel test robot
2021-05-12 20:11   ` kernel test robot
2021-05-12 23:44   ` Masami Hiramatsu [this message]
2021-05-12 19:04 ` [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation kernel test robot
2021-05-13  0:33   ` Masami Hiramatsu
2021-05-12 23:43 ` Masami Hiramatsu

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=20210513084409.0172212de7f567605da9a336@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=clang-built-linux@googlegroups.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=paulus@samba.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