Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 May 2012 22:47:57 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r236123 - stable/9/sys/i386/i386
Message-ID:  <201205262247.q4QMlvTX011244@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Sat May 26 22:47:56 2012
New Revision: 236123
URL: http://svn.freebsd.org/changeset/base/236123

Log:
  MFC r228513
    Create large page mappings in pmap_map().

Modified:
  stable/9/sys/i386/i386/pmap.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/i386/i386/pmap.c
==============================================================================
--- stable/9/sys/i386/i386/pmap.c	Sat May 26 21:30:18 2012	(r236122)
+++ stable/9/sys/i386/i386/pmap.c	Sat May 26 22:47:56 2012	(r236123)
@@ -1452,12 +1452,40 @@ vm_offset_t
 pmap_map(vm_offset_t *virt, vm_paddr_t start, vm_paddr_t end, int prot)
 {
 	vm_offset_t va, sva;
+	vm_paddr_t superpage_offset;
+	pd_entry_t newpde;
 
-	va = sva = *virt;
+	va = *virt;
+	/*
+	 * Does the physical address range's size and alignment permit at
+	 * least one superpage mapping to be created?
+	 */ 
+	superpage_offset = start & PDRMASK;
+	if ((end - start) - ((NBPDR - superpage_offset) & PDRMASK) >= NBPDR) {
+		/*
+		 * Increase the starting virtual address so that its alignment
+		 * does not preclude the use of superpage mappings.
+		 */
+		if ((va & PDRMASK) < superpage_offset)
+			va = (va & ~PDRMASK) + superpage_offset;
+		else if ((va & PDRMASK) > superpage_offset)
+			va = ((va + PDRMASK) & ~PDRMASK) + superpage_offset;
+	}
+	sva = va;
 	while (start < end) {
-		pmap_kenter(va, start);
-		va += PAGE_SIZE;
-		start += PAGE_SIZE;
+		if ((start & PDRMASK) == 0 && end - start >= NBPDR &&
+		    pseflag) {
+			KASSERT((va & PDRMASK) == 0,
+			    ("pmap_map: misaligned va %#x", va));
+			newpde = start | PG_PS | pgeflag | PG_RW | PG_V;
+			pmap_kenter_pde(va, newpde);
+			va += NBPDR;
+			start += NBPDR;
+		} else {
+			pmap_kenter(va, start);
+			va += PAGE_SIZE;
+			start += PAGE_SIZE;
+		}
 	}
 	pmap_invalidate_range(kernel_pmap, sva, va);
 	*virt = va;



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