]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/read_fault.c
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / i386 / read_fault.c
index 2049a1ff1f80700aad11640bea1d6c4c5d64529f..17adc5879867d4a218feee8f169ced91dfeec580 100644 (file)
@@ -3,19 +3,22 @@
  *
  * @APPLE_LICENSE_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.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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. 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 OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * 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_HEADER_END@
  */
@@ -92,6 +95,19 @@ intel_read_fault(
        register vm_page_t      m;
        vm_map_t                pmap_map;
        vm_map_t                original_map = map;
+       thread_t                cur_thread;
+       boolean_t               funnel_set;
+       funnel_t                *curflock;
+
+       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:
 
@@ -110,7 +126,9 @@ intel_read_fault(
        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) {
@@ -143,6 +161,8 @@ intel_read_fault(
                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();
@@ -209,6 +229,8 @@ intel_read_fault(
                        vm_object_lock(m->object);
                        RELEASE_PAGE(m);
                        UNLOCK_AND_DEALLOCATE;
+                       if (funnel_set)
+                               thread_funnel_set( curflock, TRUE);
                        return (result);
            }
 
@@ -235,7 +257,7 @@ intel_read_fault(
         *      Put the page in the physical map.
         */
 
-       PMAP_ENTER(pmap_map->pmap, vaddr, m, VM_PROT_READ, wired);
+       PMAP_ENTER(pmap_map->pmap, vaddr, m, VM_PROT_READ, PMAP_DEFAULT_CACHE, wired);
 
        if(pmap_map != map) {
                vm_map_unlock_read(pmap_map);
@@ -256,6 +278,8 @@ intel_read_fault(
 
 #undef UNLOCK_AND_DEALLOCATE
 #undef RELEASE_PAGE
+       if (funnel_set)
+               thread_funnel_set( curflock, TRUE);
        return (KERN_SUCCESS);
 }