~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/execmem.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/linux/execmem.h (Architecture mips) and /include/linux/execmem.h (Architecture alpha)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _LINUX_EXECMEM_ALLOC_H                      2 #ifndef _LINUX_EXECMEM_ALLOC_H
  3 #define _LINUX_EXECMEM_ALLOC_H                      3 #define _LINUX_EXECMEM_ALLOC_H
  4                                                     4 
  5 #include <linux/types.h>                            5 #include <linux/types.h>
  6 #include <linux/moduleloader.h>                     6 #include <linux/moduleloader.h>
  7                                                     7 
  8 #if (defined(CONFIG_KASAN_GENERIC) || defined(      8 #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
  9                 !defined(CONFIG_KASAN_VMALLOC)      9                 !defined(CONFIG_KASAN_VMALLOC)
 10 #include <linux/kasan.h>                           10 #include <linux/kasan.h>
 11 #define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADO     11 #define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT)
 12 #else                                              12 #else
 13 #define MODULE_ALIGN PAGE_SIZE                     13 #define MODULE_ALIGN PAGE_SIZE
 14 #endif                                             14 #endif
 15                                                    15 
 16 /**                                                16 /**
 17  * enum execmem_type - types of executable mem     17  * enum execmem_type - types of executable memory ranges
 18  *                                                 18  *
 19  * There are several subsystems that allocate      19  * There are several subsystems that allocate executable memory.
 20  * Architectures define different restrictions     20  * Architectures define different restrictions on placement,
 21  * permissions, alignment and other parameters     21  * permissions, alignment and other parameters for memory that can be used
 22  * by these subsystems.                            22  * by these subsystems.
 23  * Types in this enum identify subsystems that     23  * Types in this enum identify subsystems that allocate executable memory
 24  * and let architectures define parameters for     24  * and let architectures define parameters for ranges suitable for
 25  * allocations by each subsystem.                  25  * allocations by each subsystem.
 26  *                                                 26  *
 27  * @EXECMEM_DEFAULT: default parameters that w     27  * @EXECMEM_DEFAULT: default parameters that would be used for types that
 28  * are not explicitly defined.                     28  * are not explicitly defined.
 29  * @EXECMEM_MODULE_TEXT: parameters for module     29  * @EXECMEM_MODULE_TEXT: parameters for module text sections
 30  * @EXECMEM_KPROBES: parameters for kprobes        30  * @EXECMEM_KPROBES: parameters for kprobes
 31  * @EXECMEM_FTRACE: parameters for ftrace          31  * @EXECMEM_FTRACE: parameters for ftrace
 32  * @EXECMEM_BPF: parameters for BPF                32  * @EXECMEM_BPF: parameters for BPF
 33  * @EXECMEM_MODULE_DATA: parameters for module     33  * @EXECMEM_MODULE_DATA: parameters for module data sections
 34  * @EXECMEM_TYPE_MAX:                              34  * @EXECMEM_TYPE_MAX:
 35  */                                                35  */
 36 enum execmem_type {                                36 enum execmem_type {
 37         EXECMEM_DEFAULT,                           37         EXECMEM_DEFAULT,
 38         EXECMEM_MODULE_TEXT = EXECMEM_DEFAULT,     38         EXECMEM_MODULE_TEXT = EXECMEM_DEFAULT,
 39         EXECMEM_KPROBES,                           39         EXECMEM_KPROBES,
 40         EXECMEM_FTRACE,                            40         EXECMEM_FTRACE,
 41         EXECMEM_BPF,                               41         EXECMEM_BPF,
 42         EXECMEM_MODULE_DATA,                       42         EXECMEM_MODULE_DATA,
 43         EXECMEM_TYPE_MAX,                          43         EXECMEM_TYPE_MAX,
 44 };                                                 44 };
 45                                                    45 
 46 /**                                                46 /**
 47  * enum execmem_range_flags - options for exec     47  * enum execmem_range_flags - options for executable memory allocations
 48  * @EXECMEM_KASAN_SHADOW:       allocate kasan     48  * @EXECMEM_KASAN_SHADOW:       allocate kasan shadow
 49  */                                                49  */
 50 enum execmem_range_flags {                         50 enum execmem_range_flags {
 51         EXECMEM_KASAN_SHADOW    = (1 << 0),        51         EXECMEM_KASAN_SHADOW    = (1 << 0),
 52 };                                                 52 };
 53                                                    53 
 54 /**                                                54 /**
 55  * struct execmem_range - definition of an add     55  * struct execmem_range - definition of an address space suitable for code and
 56  *                        related data allocat     56  *                        related data allocations
 57  * @start:      address space start                57  * @start:      address space start
 58  * @end:        address space end (inclusive)      58  * @end:        address space end (inclusive)
 59  * @fallback_start: start of the secondary add     59  * @fallback_start: start of the secondary address space range for fallback
 60  *                  allocations on architectur     60  *                  allocations on architectures that require it
 61  * @fallback_end:   start of the secondary add     61  * @fallback_end:   start of the secondary address space (inclusive)
 62  * @pgprot:     permissions for memory in this     62  * @pgprot:     permissions for memory in this address space
 63  * @alignment:  alignment required for text al     63  * @alignment:  alignment required for text allocations
 64  * @flags:      options for memory allocations     64  * @flags:      options for memory allocations for this range
 65  */                                                65  */
 66 struct execmem_range {                             66 struct execmem_range {
 67         unsigned long   start;                     67         unsigned long   start;
 68         unsigned long   end;                       68         unsigned long   end;
 69         unsigned long   fallback_start;            69         unsigned long   fallback_start;
 70         unsigned long   fallback_end;              70         unsigned long   fallback_end;
 71         pgprot_t        pgprot;                    71         pgprot_t        pgprot;
 72         unsigned int    alignment;                 72         unsigned int    alignment;
 73         enum execmem_range_flags flags;            73         enum execmem_range_flags flags;
 74 };                                                 74 };
 75                                                    75 
 76 /**                                                76 /**
 77  * struct execmem_info - architecture paramete     77  * struct execmem_info - architecture parameters for code allocations
 78  * @ranges: array of parameter sets defining a     78  * @ranges: array of parameter sets defining architecture specific
 79  * parameters for executable memory allocation     79  * parameters for executable memory allocations. The ranges that are not
 80  * explicitly initialized by an architecture u     80  * explicitly initialized by an architecture use parameters defined for
 81  * @EXECMEM_DEFAULT.                               81  * @EXECMEM_DEFAULT.
 82  */                                                82  */
 83 struct execmem_info {                              83 struct execmem_info {
 84         struct execmem_range    ranges[EXECMEM     84         struct execmem_range    ranges[EXECMEM_TYPE_MAX];
 85 };                                                 85 };
 86                                                    86 
 87 /**                                                87 /**
 88  * execmem_arch_setup - define parameters for      88  * execmem_arch_setup - define parameters for allocations of executable memory
 89  *                                                 89  *
 90  * A hook for architectures to define paramete     90  * A hook for architectures to define parameters for allocations of
 91  * executable memory. These parameters should      91  * executable memory. These parameters should be filled into the
 92  * @execmem_info structure.                        92  * @execmem_info structure.
 93  *                                                 93  *
 94  * For architectures that do not implement thi     94  * For architectures that do not implement this method a default set of
 95  * parameters will be used                         95  * parameters will be used
 96  *                                                 96  *
 97  * Return: a structure defining architecture p     97  * Return: a structure defining architecture parameters and restrictions
 98  * for allocations of executable memory            98  * for allocations of executable memory
 99  */                                                99  */
100 struct execmem_info *execmem_arch_setup(void);    100 struct execmem_info *execmem_arch_setup(void);
101                                                   101 
102 /**                                               102 /**
103  * execmem_alloc - allocate executable memory     103  * execmem_alloc - allocate executable memory
104  * @type: type of the allocation                  104  * @type: type of the allocation
105  * @size: how many bytes of memory are require    105  * @size: how many bytes of memory are required
106  *                                                106  *
107  * Allocates memory that will contain executab    107  * Allocates memory that will contain executable code, either generated or
108  * loaded from kernel modules.                    108  * loaded from kernel modules.
109  *                                                109  *
110  * Allocates memory that will contain data cou    110  * Allocates memory that will contain data coupled with executable code,
111  * like data sections in kernel modules.          111  * like data sections in kernel modules.
112  *                                                112  *
113  * The memory will have protections defined by    113  * The memory will have protections defined by architecture for executable
114  * region of the @type.                           114  * region of the @type.
115  *                                                115  *
116  * Return: a pointer to the allocated memory o    116  * Return: a pointer to the allocated memory or %NULL
117  */                                               117  */
118 void *execmem_alloc(enum execmem_type type, si    118 void *execmem_alloc(enum execmem_type type, size_t size);
119                                                   119 
120 /**                                               120 /**
121  * execmem_free - free executable memory          121  * execmem_free - free executable memory
122  * @ptr: pointer to the memory that should be     122  * @ptr: pointer to the memory that should be freed
123  */                                               123  */
124 void execmem_free(void *ptr);                     124 void execmem_free(void *ptr);
125                                                   125 
126 #if defined(CONFIG_EXECMEM) && !defined(CONFIG    126 #if defined(CONFIG_EXECMEM) && !defined(CONFIG_ARCH_WANTS_EXECMEM_LATE)
127 void execmem_init(void);                          127 void execmem_init(void);
128 #else                                             128 #else
129 static inline void execmem_init(void) {}          129 static inline void execmem_init(void) {}
130 #endif                                            130 #endif
131                                                   131 
132 #endif /* _LINUX_EXECMEM_ALLOC_H */               132 #endif /* _LINUX_EXECMEM_ALLOC_H */
133                                                   133 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php