Revert sys/arch/x86/x86/pmap.c 1.185; a CPU needs to get pmap updates, trunk
authorbouyer <bouyer@NetBSD.org>
Thu, 27 Nov 2014 16:29:44 +0000
branchtrunk
changeset 231881 d17421a4ac3b
parent 231880 1df22ac3c731
child 231882 3e151c06afec
Revert sys/arch/x86/x86/pmap.c 1.185; a CPU needs to get pmap updates, especially for pmap_kernel(), as soon as it is up. Instead move all pmap-related cpu_info initialisations, including initializing ci_kpm_mtx, in cpu_attach_common() from cpu_init() (ci_pmap and ci_tlbstate as already initialized in cpu_attach_common()).
sys/arch/x86/x86/pmap.c
sys/arch/xen/x86/cpu.c
--- a/sys/arch/x86/x86/pmap.c	Thu Nov 27 15:07:23 2014 +0000
+++ b/sys/arch/x86/x86/pmap.c	Thu Nov 27 16:29:44 2014 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.186 2014/11/27 14:22:09 uebayasi Exp $	*/
+/*	$NetBSD: pmap.c,v 1.187 2014/11/27 16:29:44 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
@@ -171,7 +171,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.186 2014/11/27 14:22:09 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.187 2014/11/27 16:29:44 bouyer Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -4187,7 +4187,8 @@
 			pmap_pte_set(&pdep[i], pte);
 #if defined(PAE) || defined(__x86_64__)
 			if (level == PTP_LEVELS && i >= PDIR_SLOT_KERN) {
-			  if (__predict_true(mp_online == true)) {
+				if (__predict_true(
+				    cpu_info_primary.ci_flags & CPUF_PRESENT)) {
 					/* update per-cpu PMDs on all cpus */
 					xen_kpm_sync(pmap_kernel(), i);
 				} else {
--- a/sys/arch/xen/x86/cpu.c	Thu Nov 27 15:07:23 2014 +0000
+++ b/sys/arch/xen/x86/cpu.c	Thu Nov 27 16:29:44 2014 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.99 2014/10/18 08:33:27 snj Exp $	*/
+/*	$NetBSD: cpu.c,v 1.100 2014/11/27 16:29:44 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.99 2014/10/18 08:33:27 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.100 2014/11/27 16:29:44 bouyer Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -425,6 +425,13 @@
 	}
 
 	KASSERT(ci->ci_cpuid == ci->ci_index);
+#ifdef __x86_64__
+	/* No user PGD mapped for this CPU yet */
+	ci->ci_xen_current_user_pgd = 0;
+#endif
+#if defined(__x86_64__) || defined(PAE)
+	mutex_init(&ci->ci_kpm_mtx, MUTEX_DEFAULT, IPL_VM);
+#endif
 	pmap_reference(pmap_kernel());
 	ci->ci_pmap = pmap_kernel();
 	ci->ci_tlbstate = TLBSTATE_STALE;
@@ -543,14 +550,6 @@
 			lcr4(rcr4() | CR4_OSXMMEXCPT);
 	}
 
-#ifdef __x86_64__
-	/* No user PGD mapped for this CPU yet */
-	ci->ci_xen_current_user_pgd = 0;
-#endif
-#if defined(__x86_64__) || defined(PAE)
-	mutex_init(&ci->ci_kpm_mtx, MUTEX_DEFAULT, IPL_VM);
-#endif
-
 	atomic_or_32(&ci->ci_flags, CPUF_RUNNING);
 }