X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0b4e3aa066abc0728aacb4bbeb86f53f9737156e..5d5c5d0d5b79ade9a973d55186ffda2638ba2b6e:/osfmk/i386/read_fault.c diff --git a/osfmk/i386/read_fault.c b/osfmk/i386/read_fault.c index 2049a1ff1..da1ad246a 100644 --- a/osfmk/i386/read_fault.c +++ b/osfmk/i386/read_fault.c @@ -1,23 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the + * License may not be used to create, or enable the creation or + * redistribution of, unlawful or unlicensed copies of an Apple operating + * system, or to circumvent, violate, or enable the circumvention or + * violation of, any terms of an Apple operating system software license + * agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ */ /* * @OSF_COPYRIGHT@ @@ -84,14 +92,26 @@ intel_read_fault( vm_object_offset_t offset; /* Top-level offset */ vm_prot_t prot; /* Protection for mapping */ vm_behavior_t behavior; /* Expected paging behavior */ - vm_object_offset_t lo_offset, hi_offset; + vm_map_offset_t lo_offset, hi_offset; vm_page_t result_page; /* Result of vm_fault_page */ vm_page_t top_page; /* Placeholder page */ boolean_t wired; /* Is map region wired? */ kern_return_t result; register vm_page_t m; - vm_map_t pmap_map; + vm_map_t map_pmap; vm_map_t original_map = map; + thread_t cur_thread; + boolean_t funnel_set; + funnel_t *curflock = NULL; + + cur_thread = current_thread(); + if ((cur_thread->funnel_state & TH_FN_OWNED) == TH_FN_OWNED) { + funnel_set = TRUE; + curflock = cur_thread->funnel_lock; + thread_funnel_set( curflock , FALSE); + } else { + funnel_set = FALSE; + } RetryFault: @@ -105,17 +125,19 @@ intel_read_fault( result = vm_map_lookup_locked(&map, vaddr, VM_PROT_READ, &version, &object, &offset, &prot, &wired, &behavior, &lo_offset, - &hi_offset, &pmap_map); + &hi_offset, &map_pmap); vm_map_unlock_read(map); if (result != KERN_SUCCESS) { - return (result); + if (funnel_set) + thread_funnel_set( curflock, TRUE); + return (result); } - if(pmap_map != map) { - vm_map_reference(pmap_map); - vm_map_unlock_read(pmap_map); + if(map_pmap != map) { + vm_map_reference(map_pmap); + vm_map_unlock_read(map_pmap); } /* @@ -135,14 +157,16 @@ intel_read_fault( if (result != VM_FAULT_SUCCESS) { vm_object_deallocate(object); - if(pmap_map != map) { - vm_map_deallocate(pmap_map); + if(map_pmap != map) { + vm_map_deallocate(map_pmap); } switch (result) { case VM_FAULT_RETRY: goto RetryFault; case VM_FAULT_INTERRUPTED: + if (funnel_set) + thread_funnel_set( curflock, TRUE); return (KERN_SUCCESS); case VM_FAULT_MEMORY_SHORTAGE: VM_PAGE_WAIT(); @@ -192,8 +216,8 @@ intel_read_fault( vm_object_offset_t retry_offset; vm_prot_t retry_prot; - if (map != pmap_map) { - vm_map_deallocate(pmap_map); + if (map != map_pmap) { + vm_map_deallocate(map_pmap); } map = original_map; @@ -202,18 +226,20 @@ intel_read_fault( result = vm_map_lookup_locked(&map, vaddr, VM_PROT_READ, &version, &retry_object, &retry_offset, &retry_prot, &wired, &behavior, &lo_offset, - &hi_offset, &pmap_map); + &hi_offset, &map_pmap); if (result != KERN_SUCCESS) { vm_map_unlock_read(map); vm_object_lock(m->object); RELEASE_PAGE(m); UNLOCK_AND_DEALLOCATE; + if (funnel_set) + thread_funnel_set( curflock, TRUE); return (result); } - if (map != pmap_map) { - vm_map_reference(pmap_map); + if (map != map_pmap) { + vm_map_reference(map_pmap); } vm_object_unlock(retry_object); @@ -222,9 +248,9 @@ intel_read_fault( vm_object_lock(m->object); RELEASE_PAGE(m); vm_map_unlock_read(map); - if(pmap_map != map) { - vm_map_unlock_read(pmap_map); - vm_map_deallocate(pmap_map); + if(map_pmap != map) { + vm_map_unlock_read(map_pmap); + vm_map_deallocate(map_pmap); } UNLOCK_AND_DEALLOCATE; goto RetryFault; @@ -235,11 +261,11 @@ intel_read_fault( * Put the page in the physical map. */ - PMAP_ENTER(pmap_map->pmap, vaddr, m, VM_PROT_READ, wired); + PMAP_ENTER(map_pmap->pmap, vaddr, m, VM_PROT_READ, PMAP_DEFAULT_CACHE, wired); - if(pmap_map != map) { - vm_map_unlock_read(pmap_map); - vm_map_deallocate(pmap_map); + if(map_pmap != map) { + vm_map_unlock_read(map_pmap); + vm_map_deallocate(map_pmap); } vm_object_lock(m->object); @@ -256,6 +282,8 @@ intel_read_fault( #undef UNLOCK_AND_DEALLOCATE #undef RELEASE_PAGE + if (funnel_set) + thread_funnel_set( curflock, TRUE); return (KERN_SUCCESS); }