include/linux/execmem.h
Source file repositories/reference/linux-study-clean/include/linux/execmem.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/execmem.h- Extension
.h- Size
- 6746 bytes
- Lines
- 208
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/moduleloader.hlinux/cleanup.hlinux/kasan.h
Detected Declarations
struct execmem_rangestruct execmem_infoenum execmem_typeenum execmem_range_flagsfunction execmem_restore_roxfunction execmem_init
Annotated Snippet
struct execmem_range {
unsigned long start;
unsigned long end;
unsigned long fallback_start;
unsigned long fallback_end;
pgprot_t pgprot;
unsigned int alignment;
enum execmem_range_flags flags;
};
/**
* struct execmem_info - architecture parameters for code allocations
* @ranges: array of parameter sets defining architecture specific
* parameters for executable memory allocations. The ranges that are not
* explicitly initialized by an architecture use parameters defined for
* @EXECMEM_DEFAULT.
*/
struct execmem_info {
struct execmem_range ranges[EXECMEM_TYPE_MAX];
};
/**
* execmem_arch_setup - define parameters for allocations of executable memory
*
* A hook for architectures to define parameters for allocations of
* executable memory. These parameters should be filled into the
* @execmem_info structure.
*
* For architectures that do not implement this method a default set of
* parameters will be used
*
* Return: a structure defining architecture parameters and restrictions
* for allocations of executable memory
*/
struct execmem_info *execmem_arch_setup(void);
/**
* execmem_alloc - allocate executable memory
* @type: type of the allocation
* @size: how many bytes of memory are required
*
* Allocates memory that will contain executable code, either generated or
* loaded from kernel modules.
*
* Allocates memory that will contain data coupled with executable code,
* like data sections in kernel modules.
*
* The memory will have protections defined by architecture for executable
* region of the @type.
*
* Return: a pointer to the allocated memory or %NULL
*/
void *execmem_alloc(enum execmem_type type, size_t size);
/**
* execmem_alloc_rw - allocate writable executable memory
* @type: type of the allocation
* @size: how many bytes of memory are required
*
* Allocates memory that will contain executable code, either generated or
* loaded from kernel modules.
*
* Allocates memory that will contain data coupled with executable code,
* like data sections in kernel modules.
*
* Forces writable permissions on the allocated memory and the caller is
* responsible to manage the permissions afterwards.
*
* For architectures that use ROX cache the permissions will be set to R+W.
* For architectures that don't use ROX cache the default permissions for @type
* will be used as they must be writable.
*
* Return: a pointer to the allocated memory or %NULL
*/
void *execmem_alloc_rw(enum execmem_type type, size_t size);
/**
* execmem_free - free executable memory
* @ptr: pointer to the memory that should be freed
*/
void execmem_free(void *ptr);
DEFINE_FREE(execmem, void *, if (_T) execmem_free(_T));
#ifdef CONFIG_MMU
/**
* execmem_vmap - create virtual mapping for EXECMEM_MODULE_DATA memory
* @size: size of the virtual mapping in bytes
*
* Maps virtually contiguous area in the range suitable for EXECMEM_MODULE_DATA.
Annotation
- Immediate include surface: `linux/types.h`, `linux/moduleloader.h`, `linux/cleanup.h`, `linux/kasan.h`.
- Detected declarations: `struct execmem_range`, `struct execmem_info`, `enum execmem_type`, `enum execmem_range_flags`, `function execmem_restore_rox`, `function execmem_init`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.