From owner-svn-src-head@freebsd.org Thu Aug 9 17:47:49 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F22D6106E2AE; Thu, 9 Aug 2018 17:47:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A1F5C80449; Thu, 9 Aug 2018 17:47:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60AE61CA3B; Thu, 9 Aug 2018 17:47:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w79HlmUd071160; Thu, 9 Aug 2018 17:47:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w79Hlldv071157; Thu, 9 Aug 2018 17:47:47 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201808091747.w79Hlldv071157@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 9 Aug 2018 17:47:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337545 - in head/sys: conf kern sys X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head/sys: conf kern sys X-SVN-Commit-Revision: 337545 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2018 17:47:49 -0000 Author: kevans Date: Thu Aug 9 17:47:47 2018 New Revision: 337545 URL: https://svnweb.freebsd.org/changeset/base/337545 Log: BOOT_TAG: Make a config(5) option, expose as sysctl and loader tunable BOOT_TAG lived shortly in sys/msgbuf.h, but this wasn't necessarily great for changing it or removing it. Move it into subr_prf.c and add options for it to opt_printf.h. One can specify both the BOOT_TAG and BOOT_TAG_SZ (really, size of the buffer that holds the BOOT_TAG). We expose it as kern.boot_tag and also add a loader tunable by the same name that we'll fetch upon initialization of the msgbuf. This allows for flexibility and also ensures that there's a consistent way to figure out the boot tag of the running kernel, rather than relying on headers to be in-sync. Prodded super-super-lightly by: imp Modified: head/sys/conf/NOTES head/sys/conf/options head/sys/kern/subr_prf.c head/sys/sys/msgbuf.h Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Thu Aug 9 17:42:27 2018 (r337544) +++ head/sys/conf/NOTES Thu Aug 9 17:47:47 2018 (r337545) @@ -145,6 +145,16 @@ options INCLUDE_CONFIG_FILE # Include this file i options BOOTVERBOSE=1 options BOOTHOWTO=RB_MULTIPLE +# +# Compile-time defaults for dmesg boot tagging +# +# Default boot tag; may use 'kern.boot_tag' loader tunable to override. The +# current boot's tag is also exposed via the 'kern.boot_tag' sysctl. +options BOOT_TAG=\"---<>---\" +# Maximum boot tag size the kernel's static buffer should accomodate. Maximum +# size for both BOOT_TAG and the assocated tunable. +options BOOT_TAG_SZ=32 + options GEOM_BDE # Disk encryption. options GEOM_BSD # BSD disklabels (obsolete, gone in 12) options GEOM_CACHE # Disk cache. Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Aug 9 17:42:27 2018 (r337544) +++ head/sys/conf/options Thu Aug 9 17:47:47 2018 (r337545) @@ -811,6 +811,8 @@ TERMINAL_NORM_ATTR opt_teken.h # options for printf PRINTF_BUFR_SIZE opt_printf.h +BOOT_TAG opt_printf.h +BOOT_TAG_SZ opt_printf.h # kbd options KBD_DISABLE_KEYMAP_LOAD opt_kbd.h Modified: head/sys/kern/subr_prf.c ============================================================================== --- head/sys/kern/subr_prf.c Thu Aug 9 17:42:27 2018 (r337544) +++ head/sys/kern/subr_prf.c Thu Aug 9 17:47:47 2018 (r337545) @@ -124,6 +124,18 @@ static bool msgbufmapped; /* Set when safe to use msg int msgbuftrigger; struct msgbuf *msgbufp; +#ifndef BOOT_TAG_SZ +#define BOOT_TAG_SZ 32 +#endif +#ifndef BOOT_TAG +/* Tag used to mark the start of a boot in dmesg */ +#define BOOT_TAG "---<>---" +#endif + +static char current_boot_tag[BOOT_TAG_SZ + 1] = BOOT_TAG; +SYSCTL_STRING(_kern, OID_AUTO, boot_tag, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + current_boot_tag, 0, "Tag added to dmesg at start of boot"); + static int log_console_output = 1; SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RWTUN, &log_console_output, 0, "Duplicate console output to the syslog"); @@ -1025,9 +1037,13 @@ msgbufinit(void *ptr, int size) size -= sizeof(*msgbufp); cp = (char *)ptr; + /* Attempt to fetch kern.boot_tag tunable on first mapping */ + if (!msgbufmapped) + TUNABLE_STR_FETCH("kern.boot_tag", current_boot_tag, + BOOT_TAG_SZ + 1); msgbufp = (struct msgbuf *)(cp + size); msgbuf_reinit(msgbufp, cp, size); - msgbuf_addstr(msgbufp, -1, BOOT_TAG, 0); + msgbuf_addstr(msgbufp, -1, current_boot_tag, 0); if (msgbufmapped && oldp != msgbufp) msgbuf_copy(oldp, msgbufp); msgbufmapped = true; Modified: head/sys/sys/msgbuf.h ============================================================================== --- head/sys/sys/msgbuf.h Thu Aug 9 17:42:27 2018 (r337544) +++ head/sys/sys/msgbuf.h Thu Aug 9 17:47:47 2018 (r337545) @@ -60,9 +60,6 @@ struct msgbuf { /* Subtract sequence numbers. Note that only positive values result. */ #define MSGBUF_SEQSUB(mbp, seq1, seq2) (MSGBUF_SEQNORM((mbp), (seq1) - (seq2))) -/* Tag used to mark the start of a boot in dmesg */ -#define BOOT_TAG "---<>---" - #ifdef _KERNEL extern int msgbufsize; extern int msgbuftrigger;