diff options
author | alc <alc@FreeBSD.org> | 2009-11-18 18:05:54 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2009-11-18 18:05:54 +0000 |
commit | ca67dc4da40d836cf1919f08c2fba266a28d19b2 (patch) | |
tree | 3197a0817148614fefed82c9320e8a968b09917e /sys/vm/vm_fault.c | |
parent | 5df0c181df0fabff74fce8340202811f15a55b4e (diff) | |
download | FreeBSD-src-ca67dc4da40d836cf1919f08c2fba266a28d19b2.zip FreeBSD-src-ca67dc4da40d836cf1919f08c2fba266a28d19b2.tar.gz |
Simplify both the invocation and the implementation of vm_fault() for wiring
pages.
(Note: Claims made in the comments about the handling of breakpoints in
wired pages have been false for roughly a decade. This and another bug
involving breakpoints will be fixed in coming changes.)
Reviewed by: kib
Diffstat (limited to 'sys/vm/vm_fault.c')
-rw-r--r-- | sys/vm/vm_fault.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index b10270c..202df3d 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -185,7 +185,7 @@ unlock_and_deallocate(struct faultstate *fs) * default objects are zero-fill, there is no real pager. */ #define TRYPAGER (fs.object->type != OBJT_DEFAULT && \ - (((fault_flags & VM_FAULT_WIRE_MASK) == 0) || wired)) + ((fault_flags & VM_FAULT_CHANGE_WIRING) == 0 || wired)) /* * vm_fault: @@ -238,31 +238,15 @@ RetryFault:; result = vm_map_lookup(&fs.map, vaddr, fault_type, &fs.entry, &fs.first_object, &fs.first_pindex, &prot, &wired); if (result != KERN_SUCCESS) { - if (result != KERN_PROTECTION_FAILURE || - (fault_flags & VM_FAULT_WIRE_MASK) != VM_FAULT_USER_WIRE) { - if (growstack && result == KERN_INVALID_ADDRESS && - map != kernel_map && curproc != NULL) { - result = vm_map_growstack(curproc, vaddr); - if (result != KERN_SUCCESS) - return (KERN_FAILURE); - growstack = FALSE; - goto RetryFault; - } - return (result); + if (growstack && result == KERN_INVALID_ADDRESS && + map != kernel_map) { + result = vm_map_growstack(curproc, vaddr); + if (result != KERN_SUCCESS) + return (KERN_FAILURE); + growstack = FALSE; + goto RetryFault; } - - /* - * If we are user-wiring a r/w segment, and it is COW, then - * we need to do the COW operation. Note that we don't COW - * currently RO sections now, because it is NOT desirable - * to COW .text. We simply keep .text from ever being COW'ed - * and take the heat that one cannot debug wired .text sections. - */ - result = vm_map_lookup(&fs.map, vaddr, - VM_PROT_READ|VM_PROT_WRITE|VM_PROT_OVERRIDE_WRITE, - &fs.entry, &fs.first_object, &fs.first_pindex, &prot, &wired); - if (result != KERN_SUCCESS) - return (result); + return (result); } map_generation = fs.map->timestamp; @@ -919,9 +903,8 @@ vnode_locked: * won't find it (yet). */ pmap_enter(fs.map->pmap, vaddr, fault_type, fs.m, prot, wired); - if (((fault_flags & VM_FAULT_WIRE_MASK) == 0) && (wired == 0)) { + if ((fault_flags & VM_FAULT_CHANGE_WIRING) == 0 && wired == 0) vm_fault_prefault(fs.map->pmap, vaddr, fs.entry); - } VM_OBJECT_LOCK(fs.object); vm_page_lock_queues(); vm_page_flag_set(fs.m, PG_REFERENCED); @@ -930,7 +913,7 @@ vnode_locked: * If the page is not wired down, then put it where the pageout daemon * can find it. */ - if (fault_flags & VM_FAULT_WIRE_MASK) { + if (fault_flags & VM_FAULT_CHANGE_WIRING) { if (wired) vm_page_wire(fs.m); else @@ -1048,7 +1031,7 @@ vm_fault_quick(caddr_t v, int prot) */ int vm_fault_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, - boolean_t user_wire, boolean_t fictitious) + boolean_t fictitious) { vm_offset_t va; int rv; @@ -1059,9 +1042,7 @@ vm_fault_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, * read-only sections. */ for (va = start; va < end; va += PAGE_SIZE) { - rv = vm_fault(map, va, - user_wire ? VM_PROT_READ : VM_PROT_READ | VM_PROT_WRITE, - user_wire ? VM_FAULT_USER_WIRE : VM_FAULT_CHANGE_WIRING); + rv = vm_fault(map, va, VM_PROT_NONE, VM_FAULT_CHANGE_WIRING); if (rv) { if (va != start) vm_fault_unwire(map, start, va, fictitious); |