Message ID | 20200724050553.1724168-3-jarkko.sakkinen@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arch/x86: kprobes: Remove MODULES dependency | expand |
On Fri, Jul 24, 2020 at 08:05:49AM +0300, Jarkko Sakkinen wrote: > Introduce functions for allocating memory for dynamic trampolines, such > as kprobes. An arch can promote the availability of these functions with > CONFIG_ARCH_HAS_TEXT_ALLOC. As it was pointed out at the discussion on the previous version [1], text_alloc() alone won't necessarily suit other architectures. I don't see a point in defining a "generic" interface that apriory could not be imeplemented by several architectures. [1] https://lore.kernel.org/lkml/20200714094625.1443261-1-jarkko.sakkinen@linux.intel.com/ > Cc: linux-mm@kvack.org > Cc: Andi Kleen <ak@linux.intel.com> > Cc: Masami Hiramatsu <mhiramat@kernel.org> > Suggested-by: Peter Zijlstra <peterz@infradead.org> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > --- > include/linux/vmalloc.h | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h > index 0221f852a7e1..6c151a0ac02a 100644 > --- a/include/linux/vmalloc.h > +++ b/include/linux/vmalloc.h > @@ -249,4 +249,21 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) > int register_vmap_purge_notifier(struct notifier_block *nb); > int unregister_vmap_purge_notifier(struct notifier_block *nb); > > +/* > + * These functions can be optionally implemented by an arch in order to > + * provide specialized functions for allocating trampoline code. > + */ > + > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC > +/* > + * Allocate memory to be used for trampoline code. > + */ > +void *text_alloc(unsigned long size); > + > +/* > + * Free memory returned from text_alloc(). > + */ > +void text_free(void *region); > +#endif /* CONFIG_ARCH_HAS_TEXT_ALLOC */ > + > #endif /* _LINUX_VMALLOC_H */ > -- > 2.25.1 >
On Fri, Jul 24, 2020 at 01:22:43PM +0300, Mike Rapoport wrote: > On Fri, Jul 24, 2020 at 08:05:49AM +0300, Jarkko Sakkinen wrote: > > Introduce functions for allocating memory for dynamic trampolines, such > > as kprobes. An arch can promote the availability of these functions with > > CONFIG_ARCH_HAS_TEXT_ALLOC. > > As it was pointed out at the discussion on the previous version [1], > text_alloc() alone won't necessarily suit other architectures. > > I don't see a point in defining a "generic" interface that apriory could > not be imeplemented by several architectures. > > [1] https://lore.kernel.org/lkml/20200714094625.1443261-1-jarkko.sakkinen@linux.intel.com/ These changes do actually acknowledge the feedback [1][2][3]. They do not interfere with module_alloc() and are fully optional. [1] https://lore.kernel.org/linux-riscv/20200714102826.GB4756@willie-the-truck/ [2] https://lore.kernel.org/linux-riscv/20200714164245.GE1551@shell.armlinux.org.uk/ [3] https://lore.kernel.org/linux-riscv/20200714135651.GA27819@linux-8ccs/ /Jarkko
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 0221f852a7e1..6c151a0ac02a 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -249,4 +249,21 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms) int register_vmap_purge_notifier(struct notifier_block *nb); int unregister_vmap_purge_notifier(struct notifier_block *nb); +/* + * These functions can be optionally implemented by an arch in order to + * provide specialized functions for allocating trampoline code. + */ + +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC +/* + * Allocate memory to be used for trampoline code. + */ +void *text_alloc(unsigned long size); + +/* + * Free memory returned from text_alloc(). + */ +void text_free(void *region); +#endif /* CONFIG_ARCH_HAS_TEXT_ALLOC */ + #endif /* _LINUX_VMALLOC_H */
Introduce functions for allocating memory for dynamic trampolines, such as kprobes. An arch can promote the availability of these functions with CONFIG_ARCH_HAS_TEXT_ALLOC. Cc: linux-mm@kvack.org Cc: Andi Kleen <ak@linux.intel.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> --- include/linux/vmalloc.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)