diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2015-01-13 18:51:28 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2015-01-13 18:51:28 +0000 |
commit | ae54e29bed675c5935676fe336733ed59bc7bdd7 (patch) | |
tree | b3d2cc7bf1438435a1f8bffea59f4dcfc65f1c23 /sys | |
parent | de1492a17c258830a6a6e290f6b8232450d4311b (diff) |
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@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/init_main.c | 5 | ||||
-rw-r--r-- | sys/kern/subr_log.c | 8 | ||||
-rw-r--r-- | sys/sys/msgbuf.h | 3 |
3 files changed, 13 insertions, 3 deletions
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 <sys/msg.h> #endif #include <sys/domain.h> +#include <sys/msgbuf.h> #include <sys/mbuf.h> #include <sys/pipe.h> #include <sys/task.h> @@ -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 |