Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_fault.c
Show First 20 Lines • Show All 548 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* The map in question must be referenced, and remains so. | * The map in question must be referenced, and remains so. | ||||
* Caller may hold no locks. | * Caller may hold no locks. | ||||
*/ | */ | ||||
int | int | ||||
vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, | vm_fault_trap(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, | ||||
int fault_flags, int *signo, int *ucode) | int fault_flags, int *signo, int *ucode) | ||||
{ | { | ||||
struct thread *td; | |||||
int result; | int result; | ||||
MPASS(signo == NULL || ucode != NULL); | MPASS(signo == NULL || ucode != NULL); | ||||
td = curthread; | |||||
if ((td->td_pflags & TDP_NOFAULTING) != 0) | |||||
return (KERN_PROTECTION_FAILURE); | |||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (map != kernel_map && KTRPOINT(td, KTR_FAULT)) | if (map != kernel_map && KTRPOINT(curthread, KTR_FAULT)) | ||||
ktrfault(vaddr, fault_type); | ktrfault(vaddr, fault_type); | ||||
#endif | #endif | ||||
result = vm_fault(map, trunc_page(vaddr), fault_type, fault_flags, | result = vm_fault(map, trunc_page(vaddr), fault_type, fault_flags, | ||||
NULL); | NULL); | ||||
KASSERT(result == KERN_SUCCESS || result == KERN_FAILURE || | KASSERT(result == KERN_SUCCESS || result == KERN_FAILURE || | ||||
result == KERN_INVALID_ADDRESS || | result == KERN_INVALID_ADDRESS || | ||||
result == KERN_RESOURCE_SHORTAGE || | result == KERN_RESOURCE_SHORTAGE || | ||||
result == KERN_PROTECTION_FAILURE || | result == KERN_PROTECTION_FAILURE || | ||||
result == KERN_OUT_OF_BOUNDS, | result == KERN_OUT_OF_BOUNDS, | ||||
("Unexpected Mach error %d from vm_fault()", result)); | ("Unexpected Mach error %d from vm_fault()", result)); | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
if (map != kernel_map && KTRPOINT(td, KTR_FAULTEND)) | if (map != kernel_map && KTRPOINT(curthread, KTR_FAULTEND)) | ||||
ktrfaultend(result); | ktrfaultend(result); | ||||
#endif | #endif | ||||
if (result != KERN_SUCCESS && signo != NULL) { | if (result != KERN_SUCCESS && signo != NULL) { | ||||
switch (result) { | switch (result) { | ||||
case KERN_FAILURE: | case KERN_FAILURE: | ||||
case KERN_INVALID_ADDRESS: | case KERN_INVALID_ADDRESS: | ||||
*signo = SIGSEGV; | *signo = SIGSEGV; | ||||
*ucode = SEGV_MAPERR; | *ucode = SEGV_MAPERR; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, | ||||
vm_prot_t prot, retry_prot; | vm_prot_t prot, retry_prot; | ||||
int ahead, alloc_req, behind, cluster_offset, error, era, faultcount; | int ahead, alloc_req, behind, cluster_offset, error, era, faultcount; | ||||
int locked, nera, oom, result, rv; | int locked, nera, oom, result, rv; | ||||
u_char behavior; | u_char behavior; | ||||
boolean_t wired; /* Passed by reference. */ | boolean_t wired; /* Passed by reference. */ | ||||
bool dead, hardfault, is_first_object_locked; | bool dead, hardfault, is_first_object_locked; | ||||
VM_CNT_INC(v_vm_faults); | VM_CNT_INC(v_vm_faults); | ||||
if ((curthread->td_pflags & TDP_NOFAULTING) != 0) | |||||
return (KERN_PROTECTION_FAILURE); | |||||
fs.vp = NULL; | fs.vp = NULL; | ||||
faultcount = 0; | faultcount = 0; | ||||
nera = -1; | nera = -1; | ||||
hardfault = false; | hardfault = false; | ||||
RetryFault: | RetryFault: | ||||
oom = 0; | oom = 0; | ||||
RetryFault_oom: | RetryFault_oom: | ||||
▲ Show 20 Lines • Show All 1,250 Lines • Show Last 20 Lines |