Module Name:    src
Committed By:   jym
Date:           Sun May  1 18:52:29 UTC 2011

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

Log Message:
- Rather use pmap_pte_set() when modifying a PTE.

- Call pmap_pte_flush() when issuing PTE modifications. While it is a NOOP
for native x86, it is not for Xen. It will flush all operations that are
possibly waiting in the queue, like xpq_queue_pte_update(). Do it for
each level, this function is only called at boot time and is not
performance critical.

While here:
- No need to cast early_zerop to void with memset().
- Move common variables out of the #ifdef's.
- KNF


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 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.120 src/sys/arch/x86/x86/pmap.c:1.121
--- src/sys/arch/x86/x86/pmap.c:1.120	Wed Apr 27 07:42:11 2011
+++ src/sys/arch/x86/x86/pmap.c	Sun May  1 18:52:29 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.120 2011/04/27 07:42:11 plunky Exp $	*/
+/*	$NetBSD: pmap.c,v 1.121 2011/05/01 18:52:29 jym Exp $	*/
 
 /*
  * Copyright (c) 2007 Manuel Bouyer.
@@ -142,7 +142,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.120 2011/04/27 07:42:11 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.121 2011/05/01 18:52:29 jym Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1594,9 +1594,9 @@
 void
 pmap_prealloc_lowmem_ptps(void)
 {
-#ifdef XEN
 	int level;
 	paddr_t newp;
+#ifdef XEN
 	paddr_t pdes_pa;
 
 	pdes_pa = pmap_pdirpa(pmap_kernel(), 0);
@@ -1606,7 +1606,7 @@
 		avail_start += PAGE_SIZE;
 		HYPERVISOR_update_va_mapping ((vaddr_t)early_zerop,
 		    xpmap_ptom_masked(newp) | PG_u | PG_V | PG_RW, UVMF_INVLPG);
-		memset((void *)early_zerop, 0, PAGE_SIZE);
+		memset(early_zerop, 0, PAGE_SIZE);
 		/* Mark R/O before installing */
 		HYPERVISOR_update_va_mapping ((vaddr_t)early_zerop,
 		    xpmap_ptom_masked(newp) | PG_u | PG_V, UVMF_INVLPG);
@@ -1614,9 +1614,10 @@
 			HYPERVISOR_update_va_mapping (newp + KERNBASE,
 			    xpmap_ptom_masked(newp) | PG_u | PG_V, UVMF_INVLPG);
 		xpq_queue_pte_update (
-			xpmap_ptom_masked(pdes_pa)
-			+ (pl_i(0, level) * sizeof (pd_entry_t)),
-			xpmap_ptom_masked(newp) | PG_RW | PG_u | PG_V);
+		    xpmap_ptom_masked(pdes_pa)
+		    + (pl_i(0, level) * sizeof (pd_entry_t)),
+		    xpmap_ptom_masked(newp) | PG_RW | PG_u | PG_V);
+		pmap_pte_flush();
 		level--;
 		if (level <= 1)
 			break;
@@ -1624,15 +1625,14 @@
 	}
 #else /* XEN */
 	pd_entry_t *pdes;
-	int level;
-	paddr_t newp;
 
 	pdes = pmap_kernel()->pm_pdir;
 	level = PTP_LEVELS;
 	for (;;) {
 		newp = avail_start;
 		avail_start += PAGE_SIZE;
-		*early_zero_pte = (newp & PG_FRAME) | PG_V | PG_RW;
+		pmap_pte_set(early_zero_pte, (newp & PG_FRAME) | PG_V | PG_RW);
+		pmap_pte_flush();
 		pmap_update_pg((vaddr_t)early_zerop);
 		memset(early_zerop, 0, PAGE_SIZE);
 		pdes[pl_i(0, level)] = (newp & PG_FRAME) | PG_V | PG_RW;

Reply via email to