aboutsummaryrefslogtreecommitdiffstats
path: root/mm/execmem.c
diff options
context:
space:
mode:
authorMike Rapoport (Microsoft) <rppt@kernel.org>2025-07-13 10:17:26 +0300
committerAndrew Morton <akpm@linux-foundation.org>2025-08-02 12:06:11 -0700
commit888b5a847ba9650f454cd0842ccf8497268da959 (patch)
tree1b0510c0dab542c2f0f42440def63133391f327d /mm/execmem.c
parent187fd8521dd8b202cbacd7af57f4301da4d5b52d (diff)
downloadtip-888b5a847ba9650f454cd0842ccf8497268da959.tar.gz
execmem: move execmem_force_rw() and execmem_restore_rox() before use
to avoid static declarations. Link: https://lkml.kernel.org/r/20250713071730.4117334-5-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Daniel Gomez <da.gomez@samsung.com> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Petr Pavlu <petr.pavlu@suse.com> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/execmem.c')
-rw-r--r--mm/execmem.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/mm/execmem.c b/mm/execmem.c
index 52b06ccf614af5..c99b299b113c41 100644
--- a/mm/execmem.c
+++ b/mm/execmem.c
@@ -137,6 +137,27 @@ err_restore:
return err;
}
+static int execmem_force_rw(void *ptr, size_t size)
+{
+ unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
+ unsigned long addr = (unsigned long)ptr;
+ int ret;
+
+ ret = set_memory_nx(addr, nr);
+ if (ret)
+ return ret;
+
+ return set_memory_rw(addr, nr);
+}
+
+int execmem_restore_rox(void *ptr, size_t size)
+{
+ unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
+ unsigned long addr = (unsigned long)ptr;
+
+ return set_memory_rox(addr, nr);
+}
+
static void execmem_cache_clean(struct work_struct *work)
{
struct maple_tree *free_areas = &execmem_cache.free_areas;
@@ -328,8 +349,6 @@ static inline void *pending_free_clear(void *ptr)
return (void *)((unsigned long)ptr & ~PENDING_FREE_MASK);
}
-static int execmem_force_rw(void *ptr, size_t size);
-
static int __execmem_cache_free(struct ma_state *mas, void *ptr, gfp_t gfp_mask)
{
size_t size = mas_range_len(mas);
@@ -415,27 +434,6 @@ static bool execmem_cache_free(void *ptr)
return true;
}
-static int execmem_force_rw(void *ptr, size_t size)
-{
- unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
- unsigned long addr = (unsigned long)ptr;
- int ret;
-
- ret = set_memory_nx(addr, nr);
- if (ret)
- return ret;
-
- return set_memory_rw(addr, nr);
-}
-
-int execmem_restore_rox(void *ptr, size_t size)
-{
- unsigned int nr = PAGE_ALIGN(size) >> PAGE_SHIFT;
- unsigned long addr = (unsigned long)ptr;
-
- return set_memory_rox(addr, nr);
-}
-
#else /* CONFIG_ARCH_HAS_EXECMEM_ROX */
/*
* when ROX cache is not used the permissions defined by architectures for