]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/pmap_x86_common.c
xnu-2422.100.13.tar.gz
[apple/xnu.git] / osfmk / i386 / pmap_x86_common.c
index 65291caf39eb28bb0a6bc8b0f88fa73edd466e0a..7994bfbd7a90eaa4224f41a6aa112251f2171618 100644 (file)
@@ -454,7 +454,7 @@ pmap_enter_options(
        /* 2MiB mappings are confined to x86_64 by VM */
        boolean_t               superpage = flags & VM_MEM_SUPERPAGE;
        vm_object_t             delpage_pm_obj = NULL;
-       int                     delpage_pde_index = 0;
+       uint64_t                delpage_pde_index = 0;
        pt_entry_t              old_pte;
        kern_return_t           kr_expand;
 
@@ -538,7 +538,7 @@ Retry:
                 * Remember the PDE and the PDE index, so that we
                 * can free the page at the end of this function.
                 */
-               delpage_pde_index = (int)pdeidx(pmap, vaddr);
+               delpage_pde_index = pdeidx(pmap, vaddr);
                delpage_pm_obj = pmap->pm_obj;
                *pte = 0;
        }
@@ -614,6 +614,10 @@ Retry:
                }
                if (superpage)          /* this path can not be used */
                        template |= INTEL_PTE_PS;       /* to change the page size! */
+
+               if (old_attributes == template)
+                       goto dont_update_pte;
+
                /* Determine delta, PV locked */
                need_tlbflush =
                    ((old_attributes ^ template) != INTEL_PTE_WIRED);
@@ -629,6 +633,7 @@ Retry:
                        opte = *pte;
                        npte = template | (opte & (INTEL_PTE_REF | INTEL_PTE_MOD));
                } while (!pmap_cmpx_pte(pte, opte, npte));
+dont_update_pte:
                if (old_pa_locked) {
                        UNLOCK_PVH(pai);
                        old_pa_locked = FALSE;
@@ -901,7 +906,7 @@ Done:
                vm_page_t m;
 
                vm_object_lock(delpage_pm_obj);
-               m = vm_page_lookup(delpage_pm_obj, delpage_pde_index);
+               m = vm_page_lookup(delpage_pm_obj, (delpage_pde_index * PAGE_SIZE));
                if (m == VM_PAGE_NULL)
                    panic("pmap_enter: pte page not in object");
                vm_object_unlock(delpage_pm_obj);