From: kettenis Date: Tue, 13 Jan 2015 18:51:27 +0000 (+0000) Subject: Many architectures call initmsgbuf() really really early, before uvm is X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=42be3c458464859479a9fde7deeed8544e1b21b6;p=openbsd Many architectures call initmsgbuf() really really early, before uvm is initialized. Calling malloc(9) at that point is not a good idea. So initialize consbuf later. Fixes dmesg -s on sparc64 (and probably a few other architectures). ok miod@, deraadt@ --- diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index b51700694f8..4c32b6ac321 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.231 2014/12/31 15:32:05 jsing Exp $ */ +/* $OpenBSD: init_main.c,v 1.232 2015/01/13 18:51:27 kettenis Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -72,6 +72,7 @@ #include #endif #include +#include #include #include #include @@ -405,6 +406,8 @@ main(void *framep) if_attachdomain(); splx(s); + initconsbuf(); + #ifdef GPROF /* Initialize kernel profiling. */ kmstartup(); diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 6720d5ede34..8a4746fd93a 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.26 2015/01/13 10:07:58 mpf Exp $ */ +/* $OpenBSD: subr_log.c,v 1.27 2015/01/13 18:51:27 kettenis Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -117,6 +117,12 @@ initmsgbuf(caddr_t buf, size_t bufsize) /* mark it as ready for use. */ msgbufmapped = 1; +} + +void +initconsbuf(void) +{ + long new_bufs; /* Set up a buffer to collect /dev/console output */ consbufp = malloc(CONSBUFSIZE, M_TEMP, M_NOWAIT|M_ZERO); diff --git a/sys/sys/msgbuf.h b/sys/sys/msgbuf.h index 8ca1511b061..de4e5be2390 100644 --- a/sys/sys/msgbuf.h +++ b/sys/sys/msgbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: msgbuf.h,v 1.9 2015/01/13 10:07:58 mpf Exp $ */ +/* $OpenBSD: msgbuf.h,v 1.10 2015/01/13 18:51:27 kettenis Exp $ */ /* $NetBSD: msgbuf.h,v 1.8 1995/03/26 20:24:27 jtc Exp $ */ /* @@ -47,5 +47,6 @@ extern struct msgbuf *msgbufp; extern struct msgbuf *consbufp; void initmsgbuf(caddr_t buf, size_t bufsize); +void initconsbuf(void); void msgbuf_putchar(struct msgbuf *, const char c); #endif