Thread (49 messages) 49 messages, 7 authors, 2023-11-07

Re: [PATCH v3 02/13] mm: introduce execmem_text_alloc() and execmem_free()

From: Song Liu <song@kernel.org>
Date: 2023-09-23 22:36:20
Also in: bpf, linux-arm-kernel, linux-mips, linux-mm, linux-modules, linux-riscv, linux-s390, linux-trace-kernel, linuxppc-dev, lkml, loongarch, sparclinux

On Sat, Sep 23, 2023 at 8:39 AM Mike Rapoport [off-list ref] wrote:
On Thu, Sep 21, 2023 at 03:34:18PM -0700, Song Liu wrote:
quoted
On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport [off-list ref] wrote:
quoted
[...]
quoted
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index 42215f9404af..db5561d0c233 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -21,6 +21,7 @@
 #include <linux/moduleloader.h>
 #include <linux/bug.h>
 #include <linux/memory.h>
+#include <linux/execmem.h>
 #include <asm/alternative.h>
 #include <asm/nospec-branch.h>
 #include <asm/facility.h>
@@ -76,7 +77,7 @@ void *module_alloc(unsigned long size)
 #ifdef CONFIG_FUNCTION_TRACER
 void module_arch_cleanup(struct module *mod)
 {
-       module_memfree(mod->arch.trampolines_start);
+       execmem_free(mod->arch.trampolines_start);
 }
 #endif
@@ -510,7 +511,7 @@ static int module_alloc_ftrace_hotpatch_trampolines(struct module *me,

        size = FTRACE_HOTPATCH_TRAMPOLINES_SIZE(s->sh_size);
        numpages = DIV_ROUND_UP(size, PAGE_SIZE);
-       start = module_alloc(numpages * PAGE_SIZE);
+       start = execmem_text_alloc(EXECMEM_FTRACE, numpages * PAGE_SIZE);
This should be EXECMEM_MODULE_TEXT?
This is an ftrace trampoline, so I think it should be FTRACE type of
allocation.
Yeah, I was aware of the ftrace trampoline. My point was, ftrace trampoline
doesn't seem to have any special requirements. Therefore, it is probably not
necessary to have a separate type just for it.

AFAICT, kprobe, ftrace, and BPF (JIT and trampoline) can share the same
execmem_type. We may need some work for some archs, but nothing is
fundamentally different among these.

Thanks,
Song
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help