xref: /linux-6.15/mm/execmem.c (revision 12af2b83)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2002 Richard Henderson
4  * Copyright (C) 2001 Rusty Russell, 2002, 2010 Rusty Russell IBM.
5  * Copyright (C) 2023 Luis Chamberlain <[email protected]>
6  * Copyright (C) 2024 Mike Rapoport IBM.
7  */
8 
9 #include <linux/mm.h>
10 #include <linux/vmalloc.h>
11 #include <linux/execmem.h>
12 #include <linux/moduleloader.h>
13 
14 static void *__execmem_alloc(size_t size)
15 {
16 	return module_alloc(size);
17 }
18 
19 void *execmem_alloc(enum execmem_type type, size_t size)
20 {
21 	return __execmem_alloc(size);
22 }
23 
24 void execmem_free(void *ptr)
25 {
26 	/*
27 	 * This memory may be RO, and freeing RO memory in an interrupt is not
28 	 * supported by vmalloc.
29 	 */
30 	WARN_ON(in_interrupt());
31 	vfree(ptr);
32 }
33