Module Name:    src
Committed By:   maxv
Date:           Thu Feb 21 14:31:55 UTC 2019

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

Log Message:
Remove wrong KASSERT in EPT, and reorder the code to reduce duplication.


To generate a diff of this commit:
cvs rdiff -u -r1.324 -r1.325 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.324 src/sys/arch/x86/x86/pmap.c:1.325
--- src/sys/arch/x86/x86/pmap.c:1.324	Mon Feb 18 19:03:12 2019
+++ src/sys/arch/x86/x86/pmap.c	Thu Feb 21 14:31:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.324 2019/02/18 19:03:12 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.325 2019/02/21 14:31:54 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.324 2019/02/18 19:03:12 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.325 2019/02/21 14:31:54 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -3643,25 +3643,25 @@ pmap_sync_pv(struct pv_pte *pvpte, paddr
 	pt_entry_t expect;
 	bool need_shootdown;
 
-	expect = pmap_pa2pte(pa) | PG_V;
 	ptp = pvpte->pte_ptp;
 	va = pvpte->pte_va;
 	KASSERT(ptp == NULL || ptp->uobject != NULL);
 	KASSERT(ptp == NULL || ptp_va2o(va, 1) == ptp->offset);
 	pmap = ptp_to_pmap(ptp);
+	KASSERT(kpreempt_disabled());
 
 	if (__predict_false(pmap->pm_sync_pv != NULL)) {
 		return (*pmap->pm_sync_pv)(ptp, va, pa, clearbits, oattrs,
 		    optep);
 	}
 
+	expect = pmap_pa2pte(pa) | PG_V;
+
 	if (clearbits != ~0) {
 		KASSERT((clearbits & ~(PP_ATTRS_M|PP_ATTRS_U|PP_ATTRS_W)) == 0);
 		clearbits = pmap_pp_attrs_to_pte(clearbits);
 	}
 
-	KASSERT(kpreempt_disabled());
-
 	ptep = pmap_map_pte(pmap, ptp, va);
 	do {
 		opte = *ptep;
@@ -5487,13 +5487,8 @@ pmap_ept_sync_pv(struct vm_page *ptp, va
 	bool need_shootdown;
 
 	expect = pmap_pa2pte(pa) | EPT_R;
-	KASSERT(ptp == NULL || ptp->uobject != NULL);
-	KASSERT(ptp == NULL || ptp_va2o(va, 1) == ptp->offset);
 	pmap = ptp_to_pmap(ptp);
 
-	KASSERT(clearbits == ~0 || (clearbits & ~(EPT_D | EPT_A | EPT_W)) == 0);
-	KASSERT(kpreempt_disabled());
-
 	if (clearbits != ~0) {
 		KASSERT((clearbits & ~(PP_ATTRS_M|PP_ATTRS_U|PP_ATTRS_W)) == 0);
 		clearbits = pmap_pp_attrs_to_ept(clearbits);

Reply via email to