In pmap_devmap_bootstrap(), cpu_earlydevice_va_p() must not return true until *all* devmap tables have been enabled. trunk
authorryo <ryo@NetBSD.org>
Fri, 13 Sep 2019 18:07:30 +0000
branchtrunk
changeset 454334 895eff92cee4
parent 454333 e68ec3c95752
child 454335 b8b8ce53e293
In pmap_devmap_bootstrap(), cpu_earlydevice_va_p() must not return true until *all* devmap tables have been enabled. console mapping may be present in the last table.
sys/arch/aarch64/aarch64/pmap.c
sys/arch/aarch64/include/cpufunc.h
--- a/sys/arch/aarch64/aarch64/pmap.c	Fri Sep 13 17:32:29 2019 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c	Fri Sep 13 18:07:30 2019 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.44 2019/09/07 09:57:37 ryo Exp $	*/
+/*	$NetBSD: pmap.c,v 1.45 2019/09/13 18:07:30 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.44 2019/09/07 09:57:37 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.45 2019/09/13 18:07:30 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -214,6 +214,7 @@
 
 vaddr_t virtual_avail, virtual_end;
 vaddr_t virtual_devmap_addr;
+bool pmap_devmap_bootstrap_done = false;
 
 static struct pool_cache _pmap_cache;
 static struct pool_cache _pmap_pv_pool;
@@ -338,6 +339,8 @@
 		    table[i].pd_prot,
 		    table[i].pd_flags);
 	}
+
+	pmap_devmap_bootstrap_done = true;
 }
 
 const struct pmap_devmap *
--- a/sys/arch/aarch64/include/cpufunc.h	Fri Sep 13 17:32:29 2019 +0000
+++ b/sys/arch/aarch64/include/cpufunc.h	Fri Sep 13 18:07:30 2019 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.h,v 1.6 2019/09/07 11:10:24 ryo Exp $	*/
+/*	$NetBSD: cpufunc.h,v 1.7 2019/09/13 18:07:30 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org>
@@ -148,14 +148,14 @@
 static inline bool
 cpu_earlydevice_va_p(void)
 {
-	extern vaddr_t virtual_devmap_addr;	/* in pmap.c */
+	extern bool pmap_devmap_bootstrap_done;	/* in pmap.c */
 
 	/* This function may be called before enabling MMU, or mapping KVA */
 	if ((reg_sctlr_el1_read() & SCTLR_M) == 0)
 		return false;
 
 	/* device mapping will be availabled after pmap_devmap_bootstrap() */
-	if (virtual_devmap_addr == 0)
+	if (!pmap_devmap_bootstrap_done)
 		return false;
 
 	return true;