#include <kern/kext_alloc.h>

kern/kext_alloc.h Kernel.framework

includes: Kernel/mach/kern_return.h, mach/vm_types.h
6 functions

functionget_address_from_kext_map

vm_offset_t get_address_from_kext_map(vm_size_t fsize)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kext_alloc.c
Returns a virtual address in the kext allocation map at which a kext collection of size fsize could be mapped: performs a probing kext_alloc/kext_free pair and returns the resulting address advanced and truncated to a map page boundary. Returns 0 if the probe allocation fails.

functionkext_alloc_init

void kext_alloc_init(void)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kext_alloc.c
Startup-time initialization for kext memory allocation. On configurations with a kext basement (x86_64), carves out a submap of the kernel map covering 2GB below the top of the kernel's __TEXT segment so kext text remains within 2GB of kernel text, arranging for post-boot allocations to fall past any prelinked kexts; panics if the submap cannot be reserved. On other configurations the kernel map itself is used with no basement.

functionkext_alloc

kern_return_t kext_alloc(vm_offset_t *addr, vm_size_t size, boolean_t fixed)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kext_alloc.c
Allocates size bytes of pageable wired-allocatable kernel virtual memory for a kext in the kext map, tagged VM_KERN_MEMORY_KEXT. If fixed is TRUE the allocation is made at *addr; otherwise a range is chosen (past the prelinked kexts when a kext basement is configured) and returned in *addr. Fails with KERN_INVALID_ADDRESS, releasing the memory, if the resulting range would not be reachable by kernel text; otherwise returns the mach_vm_allocate/mach_vm_map result.

functionkext_free

void kext_free(vm_offset_t addr, vm_size_t size)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kext_alloc.c
Deallocates a kext memory range previously obtained from kext_alloc, via mach_vm_deallocate on the kext map. Asserts that the deallocation succeeds.

functionkext_receipt

kern_return_t kext_receipt(void **addrp, size_t *sizep)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kext_alloc.c
Returns through addrp/sizep the address and size of the auxiliary kext collection (AuxKC) receipt section (kAuxKCReceiptSection). Returns KERN_MISSING_KC if no AuxKC mach header is present, KERN_INVALID_KC if the AuxKC UUID was not validated against the boot kext collection at early boot or the section is missing, and KERN_SUCCESS otherwise. On failure the receipt is marked queried so third-party kext loading is not held up waiting for a consumer.

functionkext_receipt_set_queried

kern_return_t kext_receipt_set_queried(void)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/kext_alloc.c
Marks the AuxKC receipt as having been queried, allowing third-party kexts to load; called by the consumer of kext_receipt to confirm the round trip. Returns KERN_FAILURE if the flag was already set.