svn commit: r212589 - head/sys/mips/mips

Neel Natu neel at FreeBSD.org
Tue Sep 14 01:27:54 UTC 2010


Author: neel
Date: Tue Sep 14 01:27:53 2010
New Revision: 212589
URL: http://svn.freebsd.org/changeset/base/212589

Log:
  Enforce that pmap_mapdev() always returns uncacheable mappings.
  
  Reviewed by:	imp, jchandra, jmallett

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

Modified: head/sys/mips/mips/pmap.c
==============================================================================
--- head/sys/mips/mips/pmap.c	Tue Sep 14 01:10:30 2010	(r212588)
+++ head/sys/mips/mips/pmap.c	Tue Sep 14 01:27:53 2010	(r212589)
@@ -828,8 +828,8 @@ retry:
 /*
  * add a wired page to the kva
  */
- /* PMAP_INLINE */ void
-pmap_kenter(vm_offset_t va, vm_paddr_t pa)
+static void
+pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int attr)
 {
 	pt_entry_t *pte;
 	pt_entry_t opte, npte;
@@ -837,12 +837,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
 #ifdef PMAP_DEBUG
 	printf("pmap_kenter:  va: %p -> pa: %p\n", (void *)va, (void *)pa);
 #endif
-	npte = TLBLO_PA_TO_PFN(pa) | PTE_D | PTE_V | PTE_G | PTE_W;
-
-	if (is_cacheable_mem(pa))
-		npte |= PTE_C_CACHE;
-	else
-		npte |= PTE_C_UNCACHED;
+	npte = TLBLO_PA_TO_PFN(pa) | PTE_D | PTE_V | PTE_G | PTE_W | attr;
 
 	pte = pmap_pte(kernel_pmap, va);
 	opte = *pte;
@@ -851,6 +846,19 @@ pmap_kenter(vm_offset_t va, vm_paddr_t p
 		pmap_update_page(kernel_pmap, va, npte);
 }
 
+void
+pmap_kenter(vm_offset_t va, vm_paddr_t pa)
+{
+	int attr;
+
+	if (is_cacheable_mem(pa))
+		attr = PTE_C_CACHE;
+	else
+		attr = PTE_C_UNCACHED;
+
+	pmap_kenter_attr(va, pa, attr);
+}
+
 /*
  * remove a page from the kernel pagetables
  */
@@ -2863,7 +2871,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t si
 			panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
 		pa = trunc_page(pa);
 		for (tmpva = va; size > 0;) {
-			pmap_kenter(tmpva, pa);
+			pmap_kenter_attr(tmpva, pa, PTE_C_UNCACHED);
 			size -= PAGE_SIZE;
 			tmpva += PAGE_SIZE;
 			pa += PAGE_SIZE;


More information about the svn-src-all mailing list