Changeset View
Changeset View
Standalone View
Standalone View
head/sys/i386/i386/trap.c
Show First 20 Lines • Show All 738 Lines • ▼ Show 20 Lines | trap_pfault(struct trapframe *frame, int usermode, vm_offset_t eva) | ||||
struct proc *p; | struct proc *p; | ||||
vm_offset_t va; | vm_offset_t va; | ||||
vm_map_t map; | vm_map_t map; | ||||
int rv; | int rv; | ||||
vm_prot_t ftype; | vm_prot_t ftype; | ||||
td = curthread; | td = curthread; | ||||
p = td->td_proc; | p = td->td_proc; | ||||
rv = 0; | |||||
if (__predict_false((td->td_pflags & TDP_NOFAULTING) != 0)) { | if (__predict_false((td->td_pflags & TDP_NOFAULTING) != 0)) { | ||||
/* | /* | ||||
* Due to both processor errata and lazy TLB invalidation when | * Due to both processor errata and lazy TLB invalidation when | ||||
* access restrictions are removed from virtual pages, memory | * access restrictions are removed from virtual pages, memory | ||||
* accesses that are allowed by the physical mapping layer may | * accesses that are allowed by the physical mapping layer may | ||||
* nonetheless cause one spurious page fault per virtual page. | * nonetheless cause one spurious page fault per virtual page. | ||||
* When the thread is executing a "no faulting" section that | * When the thread is executing a "no faulting" section that | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (va >= KERNBASE) { | ||||
* treat it is as an illegal instruction, and not a page | * treat it is as an illegal instruction, and not a page | ||||
* fault. | * fault. | ||||
*/ | */ | ||||
#if defined(I586_CPU) && !defined(NO_F00F_HACK) | #if defined(I586_CPU) && !defined(NO_F00F_HACK) | ||||
if ((eva == (unsigned int)&idt[6]) && has_f00f_bug) | if ((eva == (unsigned int)&idt[6]) && has_f00f_bug) | ||||
return (-2); | return (-2); | ||||
#endif | #endif | ||||
if (usermode) | if (usermode) | ||||
goto nogo; | return (SIGSEGV); | ||||
map = kernel_map; | map = kernel_map; | ||||
} else { | } else { | ||||
map = &p->p_vmspace->vm_map; | map = &p->p_vmspace->vm_map; | ||||
/* | /* | ||||
* When accessing a user-space address, kernel must be | * When accessing a user-space address, kernel must be | ||||
* ready to accept the page fault, and provide a | * ready to accept the page fault, and provide a | ||||
Show All 40 Lines | if (ftype == VM_PROT_READ || ftype == VM_PROT_WRITE) { | ||||
frame); | frame); | ||||
else | else | ||||
PMC_SOFT_CALL_TF( , , page_fault, write, | PMC_SOFT_CALL_TF( , , page_fault, write, | ||||
frame); | frame); | ||||
} | } | ||||
#endif | #endif | ||||
return (0); | return (0); | ||||
} | } | ||||
nogo: | |||||
if (!usermode) { | if (!usermode) { | ||||
if (td->td_intr_nesting_level == 0 && | if (td->td_intr_nesting_level == 0 && | ||||
curpcb->pcb_onfault != NULL) { | curpcb->pcb_onfault != NULL) { | ||||
frame->tf_eip = (int)curpcb->pcb_onfault; | frame->tf_eip = (int)curpcb->pcb_onfault; | ||||
return (0); | return (0); | ||||
} | } | ||||
trap_fatal(frame, eva); | trap_fatal(frame, eva); | ||||
return (-1); | return (-1); | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |