Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/dev/kinst/trampoline.c
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
kinst_trampchunk_alloc(void) | kinst_trampchunk_alloc(void) | ||||
{ | { | ||||
struct trampchunk *chunk; | struct trampchunk *chunk; | ||||
vm_offset_t trampaddr; | vm_offset_t trampaddr; | ||||
int error __diagused; | int error __diagused; | ||||
sx_assert(&kinst_tramp_sx, SX_XLOCKED); | sx_assert(&kinst_tramp_sx, SX_XLOCKED); | ||||
#ifdef __amd64__ | |||||
/* | /* | ||||
* Allocate virtual memory for the trampoline chunk. The returned | * To simplify population of trampolines, we follow the amd64 kernel's | ||||
* address is saved in "trampaddr". To simplify population of | * code model and allocate them above KERNBASE, i.e., in the top 2GB of | ||||
* trampolines, we follow the amd64 kernel's code model and allocate | * the kernel's virtual address space (not the case for other | ||||
* them above KERNBASE, i.e., in the top 2GB of the kernel's virtual | * platforms). | ||||
* address space. Trampolines must be executable so max_prot must | |||||
* include VM_PROT_EXECUTE. | |||||
*/ | */ | ||||
trampaddr = KERNBASE; | trampaddr = KERNBASE; | ||||
#else | |||||
trampaddr = VM_MIN_KERNEL_ADDRESS; | |||||
#endif | |||||
/* | |||||
* Allocate virtual memory for the trampoline chunk. The returned | |||||
* address is saved in "trampaddr". Trampolines must be executable so | |||||
* max_prot must include VM_PROT_EXECUTE. | |||||
*/ | |||||
error = vm_map_find(kernel_map, NULL, 0, &trampaddr, | error = vm_map_find(kernel_map, NULL, 0, &trampaddr, | ||||
KINST_TRAMPCHUNK_SIZE, 0, VMFS_ANY_SPACE, VM_PROT_ALL, VM_PROT_ALL, | KINST_TRAMPCHUNK_SIZE, 0, VMFS_ANY_SPACE, VM_PROT_ALL, VM_PROT_ALL, | ||||
0); | 0); | ||||
if (error != KERN_SUCCESS) { | if (error != KERN_SUCCESS) { | ||||
KINST_LOG("trampoline chunk allocation failed: %d", error); | KINST_LOG("trampoline chunk allocation failed: %d", error); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines |