]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/pmap_common.c
xnu-1699.26.8.tar.gz
[apple/xnu.git] / osfmk / i386 / pmap_common.c
index d81248dae7cbef4921a1beef11f91d5e43e9c817..576b9c089858cb919a2f582581816e45049c2592 100644 (file)
@@ -137,7 +137,7 @@ pmap_is_noencrypt(ppnum_t pn)
        pai = ppn_to_pai(pn);
 
        if (!IS_MANAGED_PAGE(pai))
-               return (TRUE);
+               return (FALSE);
 
        if (pmap_phys_attributes[pai] & PHYS_NOENCRYPT)
                return (TRUE);
@@ -171,11 +171,17 @@ pmap_clear_noencrypt(ppnum_t pn)
        pai = ppn_to_pai(pn);
 
        if (IS_MANAGED_PAGE(pai)) {
-               LOCK_PVH(pai);
+               /*
+                * synchronization at VM layer prevents PHYS_NOENCRYPT
+                * from changing state, so we don't need the lock to inspect
+                */
+               if (pmap_phys_attributes[pai] & PHYS_NOENCRYPT) {
+                       LOCK_PVH(pai);
 
-               pmap_phys_attributes[pai] &= ~PHYS_NOENCRYPT;
+                       pmap_phys_attributes[pai] &= ~PHYS_NOENCRYPT;
 
-               UNLOCK_PVH(pai);
+                       UNLOCK_PVH(pai);
+               }
        }
 }