Module Name:    src
Committed By:   maxv
Date:           Sun Aug 12 12:23:33 UTC 2018

Modified Files:
        src/sys/arch/amd64/include: pmap.h
        src/sys/arch/x86/x86: pmap.c svs.c
        src/sys/arch/xen/x86: cpu.c

Log Message:
Introduce PDIR_SLOT_USERLIM, which indicates the limit of the user slots.
Use it instead of PDIR_SLOT_PTE when we just want to iterate over the
user slots. Also use it in SVS, I had hardcoded 255 because there was no
proper define (which there now is).


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/amd64/include/pmap.h
cvs rdiff -u -r1.299 -r1.300 src/sys/arch/x86/x86/pmap.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/x86/svs.c
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/xen/x86/cpu.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/amd64/include/pmap.h
diff -u src/sys/arch/amd64/include/pmap.h:1.50 src/sys/arch/amd64/include/pmap.h:1.51
--- src/sys/arch/amd64/include/pmap.h:1.50	Sun Aug 12 10:50:35 2018
+++ src/sys/arch/amd64/include/pmap.h	Sun Aug 12 12:23:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.50 2018/08/12 10:50:35 maxv Exp $	*/
+/*	$NetBSD: pmap.h,v 1.51 2018/08/12 12:23:33 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -141,6 +141,7 @@
 #define L4_SLOT_KERN		slotspace.area[SLAREA_MAIN].sslot
 #define L4_SLOT_KERNBASE	511 /* pl4_i(KERNBASE) */
 
+#define PDIR_SLOT_USERLIM	255
 #define PDIR_SLOT_KERN	L4_SLOT_KERN
 #define PDIR_SLOT_PTE	L4_SLOT_PTE
 

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.299 src/sys/arch/x86/x86/pmap.c:1.300
--- src/sys/arch/x86/x86/pmap.c:1.299	Sun Aug 12 11:51:42 2018
+++ src/sys/arch/x86/x86/pmap.c	Sun Aug 12 12:23:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.299 2018/08/12 11:51:42 maxv Exp $	*/
+/*	$NetBSD: pmap.c,v 1.300 2018/08/12 12:23:33 maxv Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -157,7 +157,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.299 2018/08/12 11:51:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.300 2018/08/12 12:23:33 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -2571,7 +2571,7 @@ pmap_check_inuse(struct pmap *pmap)
 		if (ci->ci_pmap == pmap)
 			panic("destroying pmap being used");
 #if defined(XEN) && defined(__x86_64__)
-		for (int i = 0; i < PDIR_SLOT_PTE; i++) {
+		for (int i = 0; i < PDIR_SLOT_USERLIM; i++) {
 			if (pmap->pm_pdir[i] != 0 &&
 			    ci->ci_kpm_pdir[i] == pmap->pm_pdir[i]) {
 				printf("pmap_destroy(%p) pmap_kernel %p "

Index: src/sys/arch/x86/x86/svs.c
diff -u src/sys/arch/x86/x86/svs.c:1.19 src/sys/arch/x86/x86/svs.c:1.20
--- src/sys/arch/x86/x86/svs.c:1.19	Thu Jul 12 19:48:16 2018
+++ src/sys/arch/x86/x86/svs.c	Sun Aug 12 12:23:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: svs.c,v 1.19 2018/07/12 19:48:16 maxv Exp $	*/
+/*	$NetBSD: svs.c,v 1.20 2018/08/12 12:23:33 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.19 2018/07/12 19:48:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svs.c,v 1.20 2018/08/12 12:23:33 maxv Exp $");
 
 #include "opt_svs.h"
 
@@ -460,7 +460,7 @@ svs_pmap_sync(struct pmap *pmap, int ind
 	KASSERT(pmap != pmap_kernel());
 	KASSERT(mutex_owned(pmap->pm_lock));
 	KASSERT(kpreempt_disabled());
-	KASSERT(index < 255);
+	KASSERT(index < PDIR_SLOT_USERLIM);
 
 	for (CPU_INFO_FOREACH(cii, ci)) {
 		cid = cpu_index(ci);
@@ -558,7 +558,7 @@ svs_pdir_switch(struct pmap *pmap)
 	mutex_enter(&ci->ci_svs_mtx);
 
 	/* User slots. */
-	for (i = 0; i < 255; i++) {
+	for (i = 0; i < PDIR_SLOT_USERLIM; i++) {
 		pte = svs_pte_atomic_read(pmap, i);
 		ci->ci_svs_updir[i] = pte;
 	}

Index: src/sys/arch/xen/x86/cpu.c
diff -u src/sys/arch/xen/x86/cpu.c:1.125 src/sys/arch/xen/x86/cpu.c:1.126
--- src/sys/arch/xen/x86/cpu.c:1.125	Fri Jul 27 09:37:31 2018
+++ src/sys/arch/xen/x86/cpu.c	Sun Aug 12 12:23:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.125 2018/07/27 09:37:31 maxv Exp $	*/
+/*	$NetBSD: cpu.c,v 1.126 2018/08/12 12:23:33 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.125 2018/07/27 09:37:31 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.126 2018/08/12 12:23:33 maxv Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1136,7 +1136,7 @@ cpu_load_pmap(struct pmap *pmap, struct 
 	KASSERT(pmap == ci->ci_pmap);
 
 	/* Copy user pmap L4 PDEs (in user addr. range) to per-cpu L4 */
-	for (i = 0; i < PDIR_SLOT_PTE; i++) {
+	for (i = 0; i < PDIR_SLOT_USERLIM; i++) {
 		KASSERT(pmap != pmap_kernel() || new_pgd[i] == 0);
 		if (ci->ci_kpm_pdir[i] != new_pgd[i]) {
 			xpq_queue_pte_update(l4_pd_ma + i * sizeof(pd_entry_t),

Reply via email to