Module Name: src Committed By: mrg Date: Fri Aug 15 07:39:25 UTC 2014
Modified Files: src/sys/kern: subr_prf.c Log Message: avoid calling into time code when cold, and avoid calling nanotime() if we're not going to use the result anyway. XXX: not necessarily the best fix, but better than crashing *early* boot due to too-early nanotime() calls. XXX: pullup. To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/sys/kern/subr_prf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_prf.c diff -u src/sys/kern/subr_prf.c:1.154 src/sys/kern/subr_prf.c:1.155 --- src/sys/kern/subr_prf.c:1.154 Sun Aug 10 16:44:36 2014 +++ src/sys/kern/subr_prf.c Fri Aug 15 07:39:25 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_prf.c,v 1.154 2014/08/10 16:44:36 tls Exp $ */ +/* $NetBSD: subr_prf.c,v 1.155 2014/08/15 07:39:25 mrg Exp $ */ /*- * Copyright (c) 1986, 1988, 1991, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.154 2014/08/10 16:44:36 tls Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.155 2014/08/15 07:39:25 mrg Exp $"); #include "opt_ddb.h" #include "opt_ipkdb.h" @@ -1200,7 +1200,6 @@ kprintf(const char *fmt0, int oflags, vo const char *xdigs; /* digits for [xX] conversion */ char bf[KPRINTF_BUFSIZE]; /* space for %c, %[diouxX] */ char *tailp; /* tail pointer for snprintf */ - struct timespec ts; if (oflags == TOBUFONLY && (vp != NULL)) tailp = *(char **)vp; @@ -1549,9 +1548,12 @@ done: *(char **)vp = sbuf; (*v_flush)(); - (void)nanotime(&ts); #ifdef RND_PRINTF - SHA512_Update(&kprnd_sha, (char *)&ts, sizeof(ts)); + if (!cold) { + struct timespec ts; + (void)nanotime(&ts); + SHA512_Update(&kprnd_sha, (char *)&ts, sizeof(ts)); + } #endif return ret; }