Author: markj
Date: Fri Sep 18 12:30:39 2020
New Revision: 365878
URL: https://svnweb.freebsd.org/changeset/base/365878

Log:
  Ensure that a protection key is selected in pmap_enter_largepage().
  
  Reviewed by:  alc, kib
  Reported by:  Coverity
  MFC with:     r365518
  Differential Revision:        https://reviews.freebsd.org/D26464

Modified:
  head/sys/amd64/amd64/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c Fri Sep 18 12:30:15 2020        (r365877)
+++ head/sys/amd64/amd64/pmap.c Fri Sep 18 12:30:39 2020        (r365878)
@@ -6537,14 +6537,14 @@ restart:
                                mp->ref_count++;
                }
                KASSERT((origpte & PG_V) == 0 || ((origpte & PG_PS) != 0 &&
-                   (origpte & PG_FRAME) == (newpte & PG_FRAME)),
-                   ("va %#lx changing 1G phys page pdpe %#lx newpte %#lx",
-                   va, origpte, newpte));
-               if ((newpte & PG_W) != 0 && (origpte & PG_W) == 0)
+                   (origpte & PG_FRAME) == (pten & PG_FRAME)),
+                   ("va %#lx changing 1G phys page pdpe %#lx pten %#lx",
+                   va, origpte, pten));
+               if ((pten & PG_W) != 0 && (origpte & PG_W) == 0)
                        pmap->pm_stats.wired_count += NBPDP / PAGE_SIZE;
-               else if ((newpte & PG_W) == 0 && (origpte & PG_W) != 0)
+               else if ((pten & PG_W) == 0 && (origpte & PG_W) != 0)
                        pmap->pm_stats.wired_count -= NBPDP / PAGE_SIZE;
-               *pdpe = newpte;
+               *pdpe = pten;
        } else /* (psind == 1) */ {     /* 2M */
                if (!pmap_pkru_same(pmap, va, va + NBPDR))
                        return (KERN_PROTECTION_FAILURE);
@@ -6573,14 +6573,14 @@ restart:
                                mp->ref_count++;
                }
                KASSERT((origpte & PG_V) == 0 || ((origpte & PG_PS) != 0 &&
-                   (origpte & PG_FRAME) == (newpte & PG_FRAME)),
-                   ("va %#lx changing 2M phys page pde %#lx newpte %#lx",
-                   va, origpte, newpte));
-               if ((newpte & PG_W) != 0 && (origpte & PG_W) == 0)
+                   (origpte & PG_FRAME) == (pten & PG_FRAME)),
+                   ("va %#lx changing 2M phys page pde %#lx pten %#lx",
+                   va, origpte, pten));
+               if ((pten & PG_W) != 0 && (origpte & PG_W) == 0)
                        pmap->pm_stats.wired_count += NBPDR / PAGE_SIZE;
-               else if ((newpte & PG_W) == 0 && (origpte & PG_W) != 0)
+               else if ((pten & PG_W) == 0 && (origpte & PG_W) != 0)
                        pmap->pm_stats.wired_count -= NBPDR / PAGE_SIZE;
-               *pde = newpte;
+               *pde = pten;
        }
        if ((origpte & PG_V) == 0)
                pmap_resident_count_inc(pmap, pagesizes[psind] / PAGE_SIZE);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to