Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Nov 2018 21:40:51 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r341096 - head/sys/amd64/amd64
Message-ID:  <201811272140.wARLepTe097984@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Nov 27 21:40:51 2018
New Revision: 341096
URL: https://svnweb.freebsd.org/changeset/base/341096

Log:
  Fix assert condition in pmap_large_unmap().
  
  pmap_large_unmap() asserts that an unmapping request covers the
  entirety of a 2M or 1G page.  The logic in the asserts was out of date
  with the loop logic.  Correct the test to actually check that
  destroying the current superpage mapping does not unmap addresses
  beyond those requested by the caller.
  
  Submitted by:	D Scott Phillips <d.scott.phillips@intel.com>
  Reviewed by:	alc
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D18345

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

Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c	Tue Nov 27 20:01:05 2018	(r341095)
+++ head/sys/amd64/amd64/pmap.c	Tue Nov 27 21:40:51 2018	(r341096)
@@ -8441,9 +8441,10 @@ pmap_large_unmap(void *svaa, vm_size_t len)
 			KASSERT((va & PDPMASK) == 0,
 			    ("PDPMASK bit set, va %#lx pdpe %#lx pdp %#lx", va,
 			    (u_long)pdpe, pdp));
-			KASSERT(len <= NBPDP,
-			    ("len < NBPDP, sva %#lx va %#lx pdpe %#lx pdp %#lx "
-			    "len %#lx", sva, va, (u_long)pdpe, pdp, len));
+			KASSERT(va + NBPDP <= sva + len,
+			    ("unmap covers partial 1GB page, sva %#lx va %#lx "
+			    "pdpe %#lx pdp %#lx len %#lx", sva, va,
+			    (u_long)pdpe, pdp, len));
 			*pdpe = 0;
 			inc = NBPDP;
 			continue;
@@ -8457,9 +8458,10 @@ pmap_large_unmap(void *svaa, vm_size_t len)
 			KASSERT((va & PDRMASK) == 0,
 			    ("PDRMASK bit set, va %#lx pde %#lx pd %#lx", va,
 			    (u_long)pde, pd));
-			KASSERT(len <= NBPDR,
-			    ("len < NBPDR, sva %#lx va %#lx pde %#lx pd %#lx "
-			    "len %#lx", sva, va, (u_long)pde, pd, len));
+			KASSERT(va + NBPDR <= sva + len,
+			    ("unmap covers partial 2MB page, sva %#lx va %#lx "
+			    "pde %#lx pd %#lx len %#lx", sva, va, (u_long)pde,
+			    pd, len));
 			pde_store(pde, 0);
 			inc = NBPDR;
 			m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pde));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811272140.wARLepTe097984>