sparc64 (and arm mem.c) are the only architectures/places where
RWLOCK_INITIALIZER() is used with static function variables, all other
(mem.c) usages place it into the global scope.

sparc64 WITNESS enabled builds fail with:

/sys/arch/sparc64/sparc64/mem.c:93: error: initializer element is not constant
/sys/arch/sparc64/sparc64/mem.c:93: error: (near initialization for 
'physlock.rwl_lock_obj.lo_type')

Diff below adjusts the two architecture's mem.c to align with the rest;
sparc64 then builds fine but dies immediately at boot:

        SPARC T4-2, No Keyboard
        Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights 
reserved.
        OpenBoot 4.38.16, 8.0000 GB memory available, Serial #83392380.
        Ethernet address 0:14:4f:f8:77:7c, Host ID: 84f8777c.




        {0} ok boot
        Boot device: os  File and args: /bsd.witness
        OpenBSD IEEE 1275 Bootblock 2.0
        ..>> OpenBSD BOOT 1.17

        ERROR: /iscsi-hba: No iscsi-network-bootpath property
        Booting /virtual-devices@100/channel-devices@200/disk@0/bsd.witness
        9802360@0x1000000+3464@0x1959278+193344@0x1c00000+4000960@0x1c2f340 
        symbols @ 0xfed62400 165+638136+437394 start=0x1000000
        [ using 1076728 bytes of bsd ELF symbol table ]

        ERROR: Last Trap: Fast Data Access MMU Miss


Index: /sys/arch/sparc64/sparc64/mem.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/sparc64/mem.c,v
retrieving revision 1.19
diff -u -p -r1.19 mem.c
--- /sys/arch/sparc64/sparc64/mem.c     14 Dec 2017 03:30:43 -0000      1.19
+++ /sys/arch/sparc64/sparc64/mem.c     17 May 2020 03:06:35 -0000
@@ -87,10 +87,11 @@ mmclose(dev_t dev, int flag, int mode, s
        return (0);
 }
 
+static struct rwlock physlock = RWLOCK_INITIALIZER("mmrw");
+
 int
 mmrw(dev_t dev, struct uio *uio, int flags)
 {
-       static struct rwlock physlock = RWLOCK_INITIALIZER("mmrw");
        vaddr_t o, v;
        size_t c;
        struct iovec *iov;
Index: conf/GENERIC
===================================================================
RCS file: /cvs/src/sys/conf/GENERIC,v
retrieving revision 1.269
diff -u -p -r1.269 GENERIC
--- conf/GENERIC        9 May 2020 19:48:45 -0000       1.269
+++ conf/GENERIC        17 May 2020 03:21:30 -0000
@@ -14,7 +14,7 @@ option                KTRACE          # system call tracing, a
 option         ACCOUNTING      # acct(2) process accounting
 option         KMEMSTATS       # collect malloc(9) statistics
 option         PTRACE          # ptrace(2) system call
-#option                WITNESS         # witness(4) lock checker
+option         WITNESS         # witness(4) lock checker
 
 #option                KVA_GUARDPAGES  # slow virtual address recycling (+ 
guarding)
 option         POOL_DEBUG      # pool corruption detection

Reply via email to