use pmap_protect() instead of pmap_kenter_pa() to remap R/O an exiting trunk
authorbouyer <bouyer@NetBSD.org>
Wed, 22 Feb 2012 18:29:31 +0000
branchtrunk
changeset 209409 64ef6a091cef
parent 209408 f4f51646f304
child 209410 f26cea34d53d
use pmap_protect() instead of pmap_kenter_pa() to remap R/O an exiting page. This gets rid of the last "mapping already present" warnings.
sys/arch/xen/x86/cpu.c
--- a/sys/arch/xen/x86/cpu.c	Wed Feb 22 18:25:12 2012 +0000
+++ b/sys/arch/xen/x86/cpu.c	Wed Feb 22 18:29:31 2012 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.82 2012/02/21 19:10:13 bouyer Exp $	*/
+/*	$NetBSD: cpu.c,v 1.83 2012/02/22 18:29:31 bouyer Exp $	*/
 /* NetBSD: cpu.c,v 1.18 2004/02/20 17:35:01 yamt Exp  */
 
 /*-
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.82 2012/02/21 19:10:13 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.83 2012/02/22 18:29:31 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1324,9 +1324,9 @@
 #endif /* __x86_64__ else PAE */
 
 	/* Xen wants R/O */
-	pmap_kenter_pa((vaddr_t)ci->ci_kpm_pdir, ci->ci_kpm_pdirpa,
-	    VM_PROT_READ, 0);
-
+	pmap_protect(pmap_kernel(), (vaddr_t)ci->ci_kpm_pdir,
+	    (vaddr_t)ci->ci_kpm_pdir + PAGE_SIZE, VM_PROT_READ);
+	pmap_update(pmap_kernel());
 #if defined(PAE)
 	/* Initialise L3 entry 3. This mapping is shared across all
 	 * pmaps and is static, ie; loading a new pmap will not update
@@ -1336,8 +1336,9 @@
 	ci->ci_pae_l3_pdir[3] = xpmap_ptom_masked(ci->ci_kpm_pdirpa) | PG_k | PG_V;
 
 	/* Mark L3 R/O (Xen wants this) */
-	pmap_kenter_pa((vaddr_t)ci->ci_pae_l3_pdir, ci->ci_pae_l3_pdirpa,
-		VM_PROT_READ, 0);
+	pmap_protect(pmap_kernel(), (vaddr_t)ci->ci_pae_l3_pdir,
+	    (vaddr_t)ci->ci_pae_l3_pdir + PAGE_SIZE, VM_PROT_READ);
+	pmap_update(pmap_kernel());
 
 	xpq_queue_pin_l3_table(xpmap_ptom_masked(ci->ci_pae_l3_pdirpa));