summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
authorJohn Levon <john.levon@joyent.com>2019-08-20 20:44:44 +0000
committerJohn Levon <john.levon@joyent.com>2019-08-21 07:35:56 +0000
commitf0a2865453f053f6ff0041c6326877f1149d89ec (patch)
tree6ceb3fff46dd567be415a839ae9b74ee2c27b5f3 /usr/src/uts
parent0678e39e27ea5dfce7fc85dcc38c837f3c8f6f6d (diff)
downloadillumos-joyent-f0a2865453f053f6ff0041c6326877f1149d89ec.tar.gz
OS-7922 buildstamp module should live in illumos-joyent
Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/os/buildversion.c112
-rw-r--r--usr/src/uts/intel/Makefile.intel2
-rw-r--r--usr/src/uts/intel/buildversion/Makefile50
-rw-r--r--usr/src/uts/intel/os/name_to_major2
-rw-r--r--usr/src/uts/sparc/Makefile.sparc2
-rw-r--r--usr/src/uts/sparc/buildversion/Makefile50
6 files changed, 217 insertions, 1 deletions
diff --git a/usr/src/uts/common/os/buildversion.c b/usr/src/uts/common/os/buildversion.c
new file mode 100644
index 0000000000..d67cc87fc1
--- /dev/null
+++ b/usr/src/uts/common/os/buildversion.c
@@ -0,0 +1,112 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
+
+/*
+ * This kernel module carries the contents of the file $SRC/buildversion
+ * in such a way that it will be included in kernel crash dumps. It will be
+ * forceloaded at boot, will refuse to detach, and has no other moving parts.
+ *
+ * The git information can be read back with "mdb", either on the live system
+ * or from a crash dump; e.g.,
+ *
+ * # mdb -ke buildversion_start/s
+ *
+ * or with
+ *
+ * # mdb -ke ::status
+ */
+
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#include <sys/modctl.h>
+
+int buildversion_no_detach = 1;
+
+static int
+buildversion_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
+{
+ switch (cmd) {
+ case DDI_ATTACH:
+ case DDI_RESUME:
+ return (DDI_SUCCESS);
+
+ default:
+ return (DDI_FAILURE);
+ }
+}
+
+static int
+buildversion_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
+{
+
+ switch (cmd) {
+ case DDI_DETACH:
+ if (buildversion_no_detach) {
+ return (DDI_FAILURE);
+ }
+ /* FALLTHRU */
+ case DDI_SUSPEND:
+ return (DDI_SUCCESS);
+
+ default:
+ return (DDI_FAILURE);
+ }
+}
+
+static struct dev_ops buildversion_dev_ops = {
+ .devo_rev = DEVO_REV,
+ .devo_refcnt = 0,
+ .devo_getinfo = nodev,
+ .devo_identify = nulldev,
+ .devo_probe = nulldev,
+
+ .devo_attach = buildversion_attach,
+ .devo_detach = buildversion_detach,
+
+ .devo_reset = nodev,
+ .devo_cb_ops = NULL,
+ .devo_bus_ops = NULL,
+ .devo_power = nodev,
+ .devo_quiesce = ddi_quiesce_not_needed,
+};
+
+static struct modldrv buildversion_md = {
+ .drv_modops = &mod_driverops,
+ .drv_linkinfo = "illumos buildversion",
+ .drv_dev_ops = &buildversion_dev_ops,
+};
+
+static struct modlinkage buildversion_ml = {
+ .ml_rev = MODREV_1,
+ .ml_linkage = { &buildversion_md, NULL }
+};
+
+int
+_init(void)
+{
+ return (mod_install(&buildversion_ml));
+}
+
+int
+_info(struct modinfo *mi)
+{
+ return (mod_info(&buildversion_ml, mi));
+}
+
+int
+_fini(void)
+{
+ return (mod_remove(&buildversion_ml));
+}
diff --git a/usr/src/uts/intel/Makefile.intel b/usr/src/uts/intel/Makefile.intel
index 32f5ff1bad..4d43a7d77a 100644
--- a/usr/src/uts/intel/Makefile.intel
+++ b/usr/src/uts/intel/Makefile.intel
@@ -697,6 +697,8 @@ MISC_KMODS += uathfw
MISC_KMODS += klmmod klmops
+MISC_KMODS += buildversion
+
#
# Software Cryptographic Providers (/kernel/crypto):
#
diff --git a/usr/src/uts/intel/buildversion/Makefile b/usr/src/uts/intel/buildversion/Makefile
new file mode 100644
index 0000000000..c4cf46c1a2
--- /dev/null
+++ b/usr/src/uts/intel/buildversion/Makefile
@@ -0,0 +1,50 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# Copyright 2019 Joyent, Inc.
+#
+
+UTSBASE = ../..
+
+MODULE = buildversion
+OBJECTS = $(OBJS_DIR)/$(MODULE).o $(OBJS_DIR)/bvstr.o
+BVSTR = $(OBJS_DIR)/buildversion
+ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
+
+include $(UTSBASE)/intel/Makefile.intel
+
+ALL_TARGET = $(BINARY)
+INSTALL_TARGET = $(ALL_TARGET) $(ROOTMODULE)
+
+CLEANFILES += $(BVSTR)
+
+.KEEP_STATE:
+
+def: $(DEF_DEPS)
+
+all: $(ALL_DEPS)
+
+clean: $(CLEAN_DEPS)
+
+clobber: $(CLOBBER_DEPS)
+
+install: $(INSTALL_DEPS)
+
+#
+# If nightly didn't generate this at all, we do so here
+$(SRC)/buildversion:
+ echo "version unset" >$(SRC)/buildversion
+
+$(OBJS_DIR)/bvstr.o: $(SRC)/buildversion
+ cp $(SRC)/buildversion $(BVSTR)
+ printf '\0' >>$(BVSTR)
+ elfwrap -64 -z target=x86 -o $@ $(BVSTR)
+
+include $(UTSBASE)/intel/Makefile.targ
diff --git a/usr/src/uts/intel/os/name_to_major b/usr/src/uts/intel/os/name_to_major
index e7fe60a8ab..6041728774 100644
--- a/usr/src/uts/intel/os/name_to_major
+++ b/usr/src/uts/intel/os/name_to_major
@@ -298,7 +298,7 @@ smrt 300
iwn 301
xhci 302
qede 303
-buildstamp 304
+buildversion 304
vmm 305
viona 306
ppt 307
diff --git a/usr/src/uts/sparc/Makefile.sparc b/usr/src/uts/sparc/Makefile.sparc
index e592b8a8ff..26494d418e 100644
--- a/usr/src/uts/sparc/Makefile.sparc
+++ b/usr/src/uts/sparc/Makefile.sparc
@@ -432,6 +432,8 @@ MISC_KMODS += mii
MISC_KMODS += klmmod klmops
+MISC_KMODS += buildversion
+
#
# Software Cryptographic Providers (/kernel/crypto):
#
diff --git a/usr/src/uts/sparc/buildversion/Makefile b/usr/src/uts/sparc/buildversion/Makefile
new file mode 100644
index 0000000000..794cf866b8
--- /dev/null
+++ b/usr/src/uts/sparc/buildversion/Makefile
@@ -0,0 +1,50 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# Copyright 2019 Joyent, Inc.
+#
+
+UTSBASE = ../..
+
+MODULE = buildversion
+OBJECTS = $(OBJS_DIR)/$(MODULE).o $(OBJS_DIR)/bvstr.o
+BVSTR = $(OBJS_DIR)/buildversion
+ROOTMODULE = $(ROOT_MISC_DIR)/$(MODULE)
+
+include $(UTSBASE)/sparc/Makefile.sparc
+
+ALL_TARGET = $(BINARY)
+INSTALL_TARGET = $(ALL_TARGET) $(ROOTMODULE)
+
+CLEANFILES += $(BVSTR)
+
+.KEEP_STATE:
+
+def: $(DEF_DEPS)
+
+all: $(ALL_DEPS)
+
+clean: $(CLEAN_DEPS)
+
+clobber: $(CLOBBER_DEPS)
+
+install: $(INSTALL_DEPS)
+
+#
+# If nightly didn't generate this at all, we do so here
+$(SRC)/buildversion:
+ echo "version unset" >$(SRC)/buildversion
+
+$(OBJS_DIR)/bvstr.o: $(SRC)/buildversion
+ cp $(SRC)/buildversion $(BVSTR)
+ printf '\0' >>$(BVSTR)
+ elfwrap -64 -z target=sparc -o $@ $(BVSTR)
+
+include $(UTSBASE)/sparc/Makefile.targ