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-21 22:13:44
Also in: bpf, linux-arm-kernel, linux-mips, linux-mm, linux-modules, linux-riscv, linux-s390, linux-trace-kernel, lkml, loongarch, netdev, sparclinux

On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport [off-list ref] wrote:
[...]
+
+#include <linux/mm.h>
+#include <linux/vmalloc.h>
+#include <linux/execmem.h>
+#include <linux/moduleloader.h>
+
+static void *execmem_alloc(size_t size)
+{
+       return module_alloc(size);
+}
+
+void *execmem_text_alloc(enum execmem_type type, size_t size)
+{
+       return execmem_alloc(size);
+}
execmem_text_alloc (and later execmem_data_alloc) both take "type" as
input. I guess we can just use execmem_alloc(type, size) for everything?

Thanks,
Song
+
+void execmem_free(void *ptr)
+{
+       /*
+        * This memory may be RO, and freeing RO memory in an interrupt is not
+        * supported by vmalloc.
+        */
+       WARN_ON(in_interrupt());
+       vfree(ptr);
+}
--
2.39.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help