]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/pmap.c
xnu-792.22.5.tar.gz
[apple/xnu.git] / osfmk / i386 / pmap.c
index b6a6372e00124258b03f804f4b61ada5e493dcb9..a54c1ef3312a67a0cb3695928920a98d1f81cce6 100644 (file)
@@ -1,23 +1,29 @@
 /*
  * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_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.
+ * 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.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
@@ -1076,7 +1082,7 @@ pmap_bootstrap(
          ml_set_interrupts_enabled(istate);
 
        }
-       kernel_pmap->pm_hold = kernel_pmap->pm_pml4;
+       kernel_pmap->pm_hold = (vm_offset_t)kernel_pmap->pm_pml4;
 
        kprintf("Kernel virtual space from 0x%x to 0x%x.\n",
                        VADDR(KPTDI,0), virtual_end);
@@ -1267,7 +1273,6 @@ pmap_create(
        vm_size_t       size;
        pdpt_entry_t    *pdpt;
        pml4_entry_t    *pml4p;
-       vm_page_t       m;
        int template;
        pd_entry_t      *pdp;
        spl_t s;
@@ -1294,6 +1299,7 @@ pmap_create(
        p->nx_enabled = 1;
        p->pm_64bit = is_64bit;
        p->pm_kernel_cr3 = FALSE;
+       p->pm_shared = FALSE;
 
        if (!cpu_64bit) {
          /* legacy 32 bit setup */
@@ -1428,7 +1434,6 @@ pmap_clear_4GB_pagezero(pmap_t p)
 {
        int             spl;
        pdpt_entry_t    *user_pdptp;
-       uint32_t        cr3;
 
        if (!p->pm_kernel_cr3)
                return;
@@ -2193,6 +2198,7 @@ pmap_enter(
                    if (pv_h->pmap == PMAP_NULL) {
                        panic("pmap_enter: null pv_list!");
                    }
+
                    if (pv_h->va == vaddr && pv_h->pmap == pmap) {
                        /*
                         * Header is the pv_entry.  Copy the next one
@@ -3795,6 +3801,8 @@ kern_return_t pmap_nest(pmap_t grand, pmap_t subord, addr64_t vstart, addr64_t n
        }
        if ((size >> 28) != 1) panic("pmap_nest: size 0x%llx must be 0x%x", size, NBPDE);
 
+       subord->pm_shared = TRUE;
+
        // prepopulate subord pmap pde's if necessary
 
        if (cpu_64bit) {
@@ -3997,7 +4005,8 @@ pmap_flush_tlbs(pmap_t    pmap)
                if (!cpu_datap(cpu)->cpu_running)
                        continue;
                if ((cpu_datap(cpu)->cpu_task_cr3   == pmap_cr3) ||
-                   (cpu_datap(cpu)->cpu_active_cr3 == pmap_cr3) ||
+                   (CPU_GET_ACTIVE_CR3(cpu) == pmap_cr3) ||
+                   (pmap->pm_shared) ||
                    ((pmap == kernel_pmap) &&
                     (!CPU_CR3_IS_ACTIVE(cpu) ||
                      cpu_datap(cpu)->cpu_task_map == TASK_MAP_64BIT_SHARED))) {