Initialize earlier macppc's and powerpc64's pmap_hash_lock
authorgkoehler <gkoehler@openbsd.org>
Wed, 3 Apr 2024 19:30:59 +0000 (19:30 +0000)
committergkoehler <gkoehler@openbsd.org>
Wed, 3 Apr 2024 19:30:59 +0000 (19:30 +0000)
At boot, the powerpc64 kernel was calling
  pmap_bootstrap -> pmap_kenter_pa -> mtx_enter(&pmap_hash_lock)
before it did
  pmap_init -> mtx_init(&pmap_hash_lock, IPL_HIGH)

Change from mtx_init to MUTEX_INITIALIZER.  This allows an option
WITNESS kernel to boot without warning of an uninitialized mutex.

Also change macppc's pmap_hash_lock from __ppc_lock_init to
PPC_LOCK_INITIALIZER, though WITNESS doesn't see this lock.

ok mpi@

sys/arch/powerpc/include/mplock.h
sys/arch/powerpc/powerpc/lock_machdep.c
sys/arch/powerpc/powerpc/pmap.c
sys/arch/powerpc64/powerpc64/pmap.c

index 962270e..4a7c303 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: mplock.h,v 1.5 2021/05/21 00:39:35 gkoehler Exp $     */
+/*     $OpenBSD: mplock.h,v 1.6 2024/04/03 19:30:59 gkoehler Exp $     */
 
 /*
  * Copyright (c) 2004 Niklas Hallqvist.  All rights reserved.
@@ -42,7 +42,8 @@ struct __ppc_lock {
 
 #ifndef _LOCORE
 
-void __ppc_lock_init(struct __ppc_lock *);
+#define PPC_LOCK_INITIALIZER   { NULL, 0 }
+
 void __ppc_lock(struct __ppc_lock *);
 void __ppc_unlock(struct __ppc_lock *);
 
index de008c5..7f1462a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: lock_machdep.c,v 1.11 2023/04/11 00:45:07 jsg Exp $   */
+/*     $OpenBSD: lock_machdep.c,v 1.12 2024/04/03 19:30:59 gkoehler Exp $      */
 
 /*
  * Copyright (c) 2021 George Koehler <gkoehler@openbsd.org>
  * Released the lock:  mpl->mpl_cpu == NULL
  */
 
-void
-__ppc_lock_init(struct __ppc_lock *lock)
-{
-       lock->mpl_cpu = NULL;
-       lock->mpl_count = 0;
-}
-
 #if defined(MP_LOCKDEBUG)
 #ifndef DDB
 #error "MP_LOCKDEBUG requires DDB"
index f160e2e..fa77311 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pmap.c,v 1.182 2023/02/21 04:49:43 gkoehler Exp $ */
+/*     $OpenBSD: pmap.c,v 1.183 2024/04/03 19:30:59 gkoehler Exp $ */
 
 /*
  * Copyright (c) 2015 Martin Pieuchot
@@ -186,9 +186,7 @@ int physmem;
 int physmaxaddr;
 
 #ifdef MULTIPROCESSOR
-struct __ppc_lock pmap_hash_lock;
-
-#define        PMAP_HASH_LOCK_INIT()           __ppc_lock_init(&pmap_hash_lock)
+struct __ppc_lock pmap_hash_lock = PPC_LOCK_INITIALIZER;
 
 #define        PMAP_HASH_LOCK(s)                                               \
 do {                                                                   \
@@ -224,7 +222,6 @@ do {                                                                        \
 
 #else /* ! MULTIPROCESSOR */
 
-#define        PMAP_HASH_LOCK_INIT()           /* nothing */
 #define        PMAP_HASH_LOCK(s)               (void)s
 #define        PMAP_HASH_UNLOCK(s)             /* nothing */
 
@@ -2207,8 +2204,6 @@ pmap_init()
            "pted", NULL);
        pool_setlowat(&pmap_pted_pool, 20);
 
-       PMAP_HASH_LOCK_INIT();
-
        pmap_initialized = 1;
 }
 
index 3e17df7..53c2bad 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: pmap.c,v 1.60 2023/04/13 15:23:22 miod Exp $ */
+/*     $OpenBSD: pmap.c,v 1.61 2024/04/03 19:30:59 gkoehler Exp $ */
 
 /*
  * Copyright (c) 2015 Martin Pieuchot
@@ -67,9 +67,7 @@ extern char _start[], _etext[], _erodata[], _end[];
 
 #ifdef MULTIPROCESSOR
 
-struct mutex pmap_hash_lock;
-
-#define PMAP_HASH_LOCK_INIT()  mtx_init(&pmap_hash_lock, IPL_HIGH)
+struct mutex pmap_hash_lock = MUTEX_INITIALIZER(IPL_HIGH);
 
 #define        PMAP_HASH_LOCK(s)                                               \
 do {                                                                   \
@@ -104,7 +102,6 @@ do {                                                                        \
 
 #else
 
-#define        PMAP_HASH_LOCK_INIT()           /* nothing */
 #define        PMAP_HASH_LOCK(s)               (void)s
 #define        PMAP_HASH_UNLOCK(s)             /* nothing */
 
@@ -1036,8 +1033,6 @@ pmap_init(void)
            "slbd", NULL);
        pool_setlowat(&pmap_slbd_pool, 5);
 
-       PMAP_HASH_LOCK_INIT();
-
        LIST_INIT(&pmap_kernel()->pm_slbd);
        for (i = 0; i < nitems(kernel_slb_desc); i++) {
                LIST_INSERT_HEAD(&pmap_kernel()->pm_slbd,