* [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation
@ 2021-05-12 14:29 Christophe Leroy
2021-05-12 14:29 ` [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn Christophe Leroy
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Christophe Leroy @ 2021-05-12 14:29 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat
Cc: clang-built-linux, linuxppc-dev, linux-kernel
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 <mhiramat@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
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
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn 2021-05-12 14:29 [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation Christophe Leroy @ 2021-05-12 14:29 ` Christophe Leroy 2021-05-12 17:29 ` kernel test robot ` (2 more replies) 2021-05-12 19:04 ` [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation kernel test robot 2021-05-12 23:43 ` Masami Hiramatsu 2 siblings, 3 replies; 8+ messages in thread From: Christophe Leroy @ 2021-05-12 14:29 UTC (permalink / raw) To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat Cc: clang-built-linux, linuxppc-dev, linux-kernel 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") 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn 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 2 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-05-12 17:29 UTC (permalink / raw) To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat Cc: linuxppc-dev, kbuild-all, linux-kernel, clang-built-linux [-- Attachment #1: Type: text/plain, Size: 2373 bytes --] 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: powerpc-allyesconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/1cc4bb503e4ee4839247b767883c8b860b26413c 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 1cc4bb503e4ee4839247b767883c8b860b26413c # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=powerpc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> arch/powerpc/kernel/optprobes.c:36:7: warning: no previous prototype for 'alloc_optinsn_page' [-Wmissing-prototypes] 36 | void *alloc_optinsn_page(void) | ^~~~~~~~~~~~~~~~~~ >> arch/powerpc/kernel/optprobes.c:44:6: warning: no previous prototype for 'free_optinsn_page' [-Wmissing-prototypes] 44 | void free_optinsn_page(void *page) | ^~~~~~~~~~~~~~~~~ vim +/alloc_optinsn_page +36 arch/powerpc/kernel/optprobes.c 35 > 36 void *alloc_optinsn_page(void) 37 { 38 if (insn_page_in_use) 39 return NULL; 40 insn_page_in_use = true; 41 return &optinsn_slot; 42 } 43 > 44 void free_optinsn_page(void *page) 45 { 46 insn_page_in_use = false; 47 } 48 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 73383 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn 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 2 siblings, 0 replies; 8+ messages in thread From: kernel test robot @ 2021-05-12 20:11 UTC (permalink / raw) To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat Cc: linuxppc-dev, kbuild-all, linux-kernel, clang-built-linux [-- Attachment #1: Type: text/plain, Size: 2419 bytes --] Hi Christophe, I love your patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR 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: powerpc-ppc64_defconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 9.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/1cc4bb503e4ee4839247b767883c8b860b26413c 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 1cc4bb503e4ee4839247b767883c8b860b26413c # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=powerpc If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> arch/powerpc/kernel/optprobes.c:36:7: error: no previous prototype for 'alloc_optinsn_page' [-Werror=missing-prototypes] 36 | void *alloc_optinsn_page(void) | ^~~~~~~~~~~~~~~~~~ >> arch/powerpc/kernel/optprobes.c:44:6: error: no previous prototype for 'free_optinsn_page' [-Werror=missing-prototypes] 44 | void free_optinsn_page(void *page) | ^~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors vim +/alloc_optinsn_page +36 arch/powerpc/kernel/optprobes.c 35 > 36 void *alloc_optinsn_page(void) 37 { 38 if (insn_page_in_use) 39 return NULL; 40 insn_page_in_use = true; 41 return &optinsn_slot; 42 } 43 > 44 void free_optinsn_page(void *page) 45 { 46 insn_page_in_use = false; 47 } 48 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 26845 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] powerpc/kprobes: Replace ppc_optinsn by common optinsn 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 2 siblings, 0 replies; 8+ messages in thread From: Masami Hiramatsu @ 2021-05-12 23:44 UTC (permalink / raw) To: Christophe Leroy Cc: linux-kernel, anil.s.keshavamurthy, clang-built-linux, Paul Mackerras, mhiramat, naveen.n.rao, linuxppc-dev, davem 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> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation 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 19:04 ` kernel test robot 2021-05-13 0:33 ` Masami Hiramatsu 2021-05-12 23:43 ` Masami Hiramatsu 2 siblings, 1 reply; 8+ messages in thread From: kernel test robot @ 2021-05-12 19:04 UTC (permalink / raw) To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, naveen.n.rao, anil.s.keshavamurthy, davem, mhiramat Cc: linuxppc-dev, kbuild-all, linux-kernel, clang-built-linux [-- Attachment #1: Type: text/plain, Size: 2131 bytes --] 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 <lkp@intel.com> 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-all@lists.01.org [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 34430 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation 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 0 siblings, 0 replies; 8+ messages in thread From: Masami Hiramatsu @ 2021-05-13 0:33 UTC (permalink / raw) To: kernel test robot Cc: kbuild-all, linux-kernel, anil.s.keshavamurthy, clang-built-linux, Paul Mackerras, naveen.n.rao, linuxppc-dev, davem, mhiramat On Thu, 13 May 2021 03:04:51 +0800 kernel test robot <lkp@intel.com> 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 <lkp@intel.com> > > 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 <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation 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 19:04 ` [PATCH 1/2] kprobes: Allow architectures to override optinsn page allocation kernel test robot @ 2021-05-12 23:43 ` Masami Hiramatsu 2 siblings, 0 replies; 8+ messages in thread From: Masami Hiramatsu @ 2021-05-12 23:43 UTC (permalink / raw) To: Christophe Leroy Cc: linux-kernel, anil.s.keshavamurthy, clang-built-linux, Paul Mackerras, mhiramat, naveen.n.rao, linuxppc-dev, davem On Wed, 12 May 2021 14:29:26 +0000 (UTC) Christophe Leroy <christophe.leroy@csgroup.eu> 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 <mhiramat@kernel.org> > Suggested-by: Masami Hiramatsu <mhiramat@kernel.org> > Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> > --- > 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 <mhiramat@kernel.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-05-13 0:34 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).