Re: [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation

2021-05-12 Thread Masami Hiramatsu
On Thu, 13 May 2021 03:04:51 +0800
kernel test robot  wrote:

> Hi Christophe,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on powerpc/next]
> [also build test WARNING on linus/master v5.13-rc1 next-20210512]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:
> https://github.com/0day-ci/linux/commits/Christophe-Leroy/kprobes-Allow-architectures-to-override-optinsn-page-allocation/20210512-223121
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
> config: i386-randconfig-r012-20210512 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
> # 
> https://github.com/0day-ci/linux/commit/2a1f135a9ce3c4d86d3bdefed561aa17760f430f
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review 
> Christophe-Leroy/kprobes-Allow-architectures-to-override-optinsn-page-allocation/20210512-223121
> git checkout 2a1f135a9ce3c4d86d3bdefed561aa17760f430f
> # save the attached .config to linux build tree
> make W=1 W=1 ARCH=i386 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> All warnings (new ones prefixed by >>):
> 
> >> kernel/kprobes.c:324:14: warning: no previous prototype for 
> >> 'alloc_optinsn_page' [-Wmissing-prototypes]
>  324 | void __weak *alloc_optinsn_page(void)
>  |  ^~
> >> kernel/kprobes.c:329:13: warning: no previous prototype for 
> >> 'free_optinsn_page' [-Wmissing-prototypes]
>  329 | void __weak free_optinsn_page(void *page)
>  | ^

Ah, we need a prototype for those in include/linux/kprobes.h
as same as alloc_insn_page() and free_insn_page().

Thank you,

-- 
Masami Hiramatsu 


Re: [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation

2021-05-12 Thread Masami Hiramatsu
On Wed, 12 May 2021 14:29:26 + (UTC)
Christophe Leroy  wrote:

> Some architectures like powerpc require a non standard
> allocation of optinsn page, because module pages are
> too far from the kernel for direct branches.
> 
> Define weak alloc_optinsn_page() and free_optinsn_page(), that
> fall back on alloc_insn_page() and free_insn_page() when not
> overriden by the architecture.
> 

Looks good to me :)

Acked-by: Masami Hiramatsu 

> Suggested-by: Masami Hiramatsu 
> Signed-off-by: Christophe Leroy 
> ---
>  kernel/kprobes.c | 14 --
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 745f08fdd7a6..8c0a6fdef771 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -321,11 +321,21 @@ int kprobe_cache_get_kallsym(struct kprobe_insn_cache 
> *c, unsigned int *symnum,
>  }
>  
>  #ifdef CONFIG_OPTPROBES
> +void __weak *alloc_optinsn_page(void)
> +{
> + return alloc_insn_page();
> +}
> +
> +void __weak free_optinsn_page(void *page)
> +{
> + free_insn_page(page);
> +}
> +
>  /* For optimized_kprobe buffer */
>  struct kprobe_insn_cache kprobe_optinsn_slots = {
>   .mutex = __MUTEX_INITIALIZER(kprobe_optinsn_slots.mutex),
> - .alloc = alloc_insn_page,
> - .free = free_insn_page,
> + .alloc = alloc_optinsn_page,
> + .free = free_optinsn_page,
>   .sym = KPROBE_OPTINSN_PAGE_SYM,
>   .pages = LIST_HEAD_INIT(kprobe_optinsn_slots.pages),
>   /* .insn_size is initialized later */
> -- 
> 2.25.0
> 


-- 
Masami Hiramatsu 


Re: [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation

2021-05-12 Thread kernel test robot
Hi Christophe,

I love your patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[also build test WARNING on linus/master v5.13-rc1 next-20210512]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Christophe-Leroy/kprobes-Allow-architectures-to-override-optinsn-page-allocation/20210512-223121
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: i386-randconfig-r012-20210512 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/2a1f135a9ce3c4d86d3bdefed561aa17760f430f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Christophe-Leroy/kprobes-Allow-architectures-to-override-optinsn-page-allocation/20210512-223121
git checkout 2a1f135a9ce3c4d86d3bdefed561aa17760f430f
# save the attached .config to linux build tree
make W=1 W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> kernel/kprobes.c:324:14: warning: no previous prototype for 
>> 'alloc_optinsn_page' [-Wmissing-prototypes]
 324 | void __weak *alloc_optinsn_page(void)
 |  ^~
>> kernel/kprobes.c:329:13: warning: no previous prototype for 
>> 'free_optinsn_page' [-Wmissing-prototypes]
 329 | void __weak free_optinsn_page(void *page)
 | ^


vim +/alloc_optinsn_page +324 kernel/kprobes.c

   322  
   323  #ifdef CONFIG_OPTPROBES
 > 324  void __weak *alloc_optinsn_page(void)
   325  {
   326  return alloc_insn_page();
   327  }
   328  
 > 329  void __weak free_optinsn_page(void *page)
   330  {
   331  free_insn_page(page);
   332  }
   333  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation

2021-05-12 Thread Christophe Leroy
Some architectures like powerpc require a non standard
allocation of optinsn page, because module pages are
too far from the kernel for direct branches.

Define weak alloc_optinsn_page() and free_optinsn_page(), that
fall back on alloc_insn_page() and free_insn_page() when not
overriden by the architecture.

Suggested-by: Masami Hiramatsu 
Signed-off-by: Christophe Leroy 
---
 kernel/kprobes.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 745f08fdd7a6..8c0a6fdef771 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -321,11 +321,21 @@ int kprobe_cache_get_kallsym(struct kprobe_insn_cache *c, 
unsigned int *symnum,
 }
 
 #ifdef CONFIG_OPTPROBES
+void __weak *alloc_optinsn_page(void)
+{
+   return alloc_insn_page();
+}
+
+void __weak free_optinsn_page(void *page)
+{
+   free_insn_page(page);
+}
+
 /* For optimized_kprobe buffer */
 struct kprobe_insn_cache kprobe_optinsn_slots = {
.mutex = __MUTEX_INITIALIZER(kprobe_optinsn_slots.mutex),
-   .alloc = alloc_insn_page,
-   .free = free_insn_page,
+   .alloc = alloc_optinsn_page,
+   .free = free_optinsn_page,
.sym = KPROBE_OPTINSN_PAGE_SYM,
.pages = LIST_HEAD_INIT(kprobe_optinsn_slots.pages),
/* .insn_size is initialized later */
-- 
2.25.0