Module Name:    src
Committed By:   jym
Date:           Thu Jul 15 21:14:32 UTC 2010

Modified Files:
        src/sys/arch/x86/x86: pmap.c

Log Message:
Check the virtual address 'va' for each PDIR_SLOT_PTE entry. PDP_SIZE
is 4 with PAE (Xen only currently), 1 otherwise: loop should be unrolled
when PDP_SIZE is 1.

pmap_alloc_level() is used by pmap_growkernel(), the PDE is a kernel
mapping: mark it so with PG_k. While here, use pmap_pa2pte() for physical
address 'pa'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/x86/x86/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.111 src/sys/arch/x86/x86/pmap.c:1.112
--- src/sys/arch/x86/x86/pmap.c:1.111	Wed Jul  7 01:14:53 2010
+++ src/sys/arch/x86/x86/pmap.c	Thu Jul 15 21:14:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.111 2010/07/07 01:14:53 chs Exp $	*/
+/*	$NetBSD: pmap.c,v 1.112 2010/07/15 21:14:31 jym Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -149,7 +149,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.111 2010/07/07 01:14:53 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.112 2010/07/15 21:14:31 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3405,6 +3405,7 @@
 	pd_entry_t * const *pdes;
 	struct pv_entry *pv_tofree = NULL;
 	bool result;
+	int i;
 	paddr_t ptppa;
 	vaddr_t blkendva, va = sva;
 	struct vm_page *ptp;
@@ -3470,9 +3471,11 @@
 		 * be VM_MAX_ADDRESS.
 		 */
 
-		if (pl_i(va, PTP_LEVELS) == PDIR_SLOT_PTE)
-			/* XXXCDC: ugly hack to avoid freeing PDP here */
-			continue;
+		/* XXXCDC: ugly hack to avoid freeing PDP here */
+		for (i = 0; i < PDP_SIZE; i++) {
+			if (pl_i(va, PTP_LEVELS) == PDIR_SLOT_PTE+i)
+				continue;
+		}
 
 		lvl = pmap_pdes_invalid(va, pdes, &pde);
 		if (lvl != 0) {
@@ -3829,6 +3832,7 @@
 void
 pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot)
 {
+	int i;
 	pt_entry_t *ptes, *epte;
 	pt_entry_t *spte;
 	pd_entry_t * const *pdes;
@@ -3861,8 +3865,10 @@
 		 */
 
 		/* XXXCDC: ugly hack to avoid freeing PDP here */
-		if (pl_i(va, PTP_LEVELS) == PDIR_SLOT_PTE)
-			continue;
+		for (i = 0; i < PDP_SIZE; i++) {
+			if (pl_i(va, PTP_LEVELS) == PDIR_SLOT_PTE+i)
+				continue;
+		}
 
 		/* empty block? */
 		if (!pmap_pdes_valid(va, pdes, NULL))
@@ -4282,7 +4288,7 @@
 			}
 #endif
 #else /* XEN */
-			pdep[i] = pa | PG_RW | PG_V;
+			pdep[i] = pmap_pa2pte(pa) | PG_k | PG_V | PG_RW;
 #endif /* XEN */
 			KASSERT(level != PTP_LEVELS || nkptp[level - 1] +
 			    pl_i(VM_MIN_KERNEL_ADDRESS, level) == i);

Reply via email to