summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2018-08-21 18:06:13 +0000
committeranton <anton@cvs.openbsd.org>2018-08-21 18:06:13 +0000
commit99c399cad12f62c274b3f060a6788f7df981dc20 (patch)
treed102b7ed811c03f0adde28e95e85903ffce3641d
parent5ab1acecaf16af3119453abea9ddd7ce87a287ce (diff)
Rework kcov kernel config. Instead of treating kcov as both an option and a
pseudo-device, get rid of the option. Enabling kcov now requires the following line to be added to the kernel config: pseudo-device kcov 1 This is how pseudo devices are enabled in general. A side-effect of this change is that dev/kcov.c will no longer be compiled by default. Prodded by deraadt@; ok mpi@ visa@
-rw-r--r--sys/arch/amd64/conf/GENERIC5
-rw-r--r--sys/arch/amd64/conf/Makefile.amd6413
-rw-r--r--sys/arch/amd64/conf/files.amd648
-rw-r--r--sys/arch/i386/conf/GENERIC5
-rw-r--r--sys/arch/i386/conf/Makefile.i38611
-rw-r--r--sys/arch/i386/conf/files.i3868
-rw-r--r--sys/conf/files5
-rw-r--r--sys/dev/kcov.c6
-rw-r--r--sys/kern/kern_exit.c10
9 files changed, 29 insertions, 42 deletions
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index d3b593f71f4..dc1f1d4f6e9 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.458 2018/08/19 11:42:33 anton Exp $
+# $OpenBSD: GENERIC,v 1.459 2018/08/21 18:06:12 anton Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -658,9 +658,6 @@ pseudo-device hotplug 1 # devices hot plugging
# mouse & keyboard multiplexor pseudo-devices
pseudo-device wsmux 2
-# kernel code coverage
-pseudo-device kcov 1
-
# Virtio devices
virtio* at pci? # Virtio PCI device
vioblk* at virtio? # Virtio block device
diff --git a/sys/arch/amd64/conf/Makefile.amd64 b/sys/arch/amd64/conf/Makefile.amd64
index e1ce1d7b410..bd1d63d12c5 100644
--- a/sys/arch/amd64/conf/Makefile.amd64
+++ b/sys/arch/amd64/conf/Makefile.amd64
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.amd64,v 1.100 2018/08/19 18:09:49 deraadt Exp $
+# $OpenBSD: Makefile.amd64,v 1.101 2018/08/21 18:06:12 anton Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
@@ -43,10 +43,6 @@ SORTR= cat
.else
CMACHFLAGS+= -mretpoline
.endif
-.if ${IDENT:M-DKCOV} && ${COMPILER_VERSION:Mclang}
-CMACHFLAGS+= -fno-ret-protector
-PROF= -fsanitize-coverage=trace-pc
-.endif
.if ${COMPILER_VERSION:Mclang}
NO_INTEGR_AS= -no-integrated-as
.endif
@@ -97,6 +93,11 @@ SYSTEM_LD_TAIL+=; umask 007; \
LINKFLAGS+= -S
.endif
+.if ${SYSTEM_OBJ:Mkcov.o} && ${COMPILER_VERSION:Mclang}
+CMACHFLAGS+= -fno-ret-protector
+PROF= -fsanitize-coverage=trace-pc
+.endif
+
%LOAD
# cc's -MD puts the source and output paths in the dependency file;
@@ -139,7 +140,7 @@ vers.o: ${SYSTEM_DEP:Ngap.o}
sh $S/conf/newvers.sh
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
-.if ${IDENT:M-DKCOV} && ${COMPILER_VERSION:Mclang}
+.if ${SYSTEM_OBJ:Mkcov.o} && ${COMPILER_VERSION:Mclang}
kcov.o: $S/dev/kcov.c
${NORMAL_C} -fno-sanitize-coverage=trace-pc
.endif
diff --git a/sys/arch/amd64/conf/files.amd64 b/sys/arch/amd64/conf/files.amd64
index b876aa897f4..fe34441c442 100644
--- a/sys/arch/amd64/conf/files.amd64
+++ b/sys/arch/amd64/conf/files.amd64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.amd64,v 1.99 2018/08/19 18:01:05 deraadt Exp $
+# $OpenBSD: files.amd64,v 1.100 2018/08/21 18:06:12 anton Exp $
maxpartitions 16
maxusers 2 16 128
@@ -245,12 +245,6 @@ file arch/amd64/amd64/vmm.c vmm needs-flag
file arch/amd64/amd64/vmm_support.S vmm
#
-# KCOV
-#
-pseudo-device kcov
-file dev/kcov.c kcov needs-flag
-
-#
# Machine-independent SD/MMC drivers
#
include "dev/sdmmc/files.sdmmc"
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 494d6e00d21..f1cb367391a 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.834 2018/08/19 11:42:33 anton Exp $
+# $OpenBSD: GENERIC,v 1.835 2018/08/21 18:06:12 anton Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -764,9 +764,6 @@ pseudo-device hotplug 1 # devices hot plugging
# mouse & keyboard multiplexor pseudo-devices
pseudo-device wsmux 2
-# kernel code coverage
-pseudo-device kcov 1
-
# Virtio devices
virtio* at pci? # Virtio PCI device
vioblk* at virtio? # Virtio block device
diff --git a/sys/arch/i386/conf/Makefile.i386 b/sys/arch/i386/conf/Makefile.i386
index 7ca4991f1f6..18b7a98e80d 100644
--- a/sys/arch/i386/conf/Makefile.i386
+++ b/sys/arch/i386/conf/Makefile.i386
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.i386,v 1.125 2018/08/19 11:42:33 anton Exp $
+# $OpenBSD: Makefile.i386,v 1.126 2018/08/21 18:06:12 anton Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
@@ -39,9 +39,6 @@ SORTR= cat
.else
CMACHFLAGS+= -mretpoline
.endif
-.if ${IDENT:M-DKCOV} && ${COMPILER_VERSION:Mclang}
-PROF= -fsanitize-coverage=trace-pc
-.endif
.if ${COMPILER_VERSION:Mclang}
NO_INTEGR_AS= -no-integrated-as
.endif
@@ -99,6 +96,10 @@ SYSTEM_LD_TAIL+=; umask 007; \
LINKFLAGS+= -S
.endif
+.if ${SYSTEM_OBJ:Mkcov.o} && ${COMPILER_VERSION:Mclang}
+PROF= -fsanitize-coverage=trace-pc
+.endif
+
%LOAD
# cc's -MD puts the source and output paths in the dependency file;
@@ -141,7 +142,7 @@ vers.o: ${SYSTEM_DEP:Ngap.o}
sh $S/conf/newvers.sh
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
-.if ${IDENT:M-DKCOV} && ${COMPILER_VERSION:Mclang}
+.if ${SYSTEM_OBJ:Mkcov.o} && ${COMPILER_VERSION:Mclang}
kcov.o: $S/dev/kcov.c
${NORMAL_C} -fno-sanitize-coverage=trace-pc
.endif
diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386
index f70d8d3a6d2..ccc0b1206bc 100644
--- a/sys/arch/i386/conf/files.i386
+++ b/sys/arch/i386/conf/files.i386
@@ -1,4 +1,4 @@
-# $OpenBSD: files.i386,v 1.241 2018/08/19 18:01:05 deraadt Exp $
+# $OpenBSD: files.i386,v 1.242 2018/08/21 18:06:12 anton Exp $
#
# new style config file for i386 architecture
#
@@ -399,12 +399,6 @@ file arch/i386/i386/vmm.c vmm needs-flag
file arch/i386/i386/vmm_support.S vmm
#
-# KCOV
-#
-pseudo-device kcov
-file dev/kcov.c kcov needs-flag
-
-#
# IPMI
#
attach ipmi at mainbus
diff --git a/sys/conf/files b/sys/conf/files
index e0b49cc8445..a196003bf54 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.664 2018/07/13 09:25:22 beck Exp $
+# $OpenBSD: files,v 1.665 2018/08/21 18:06:12 anton Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -609,6 +609,9 @@ file dev/hotplug.c hotplug needs-flag
pseudo-device pppoe: ifnet, ether, sppp
file net/if_pppoe.c pppoe needs-flag
+pseudo-device kcov
+file dev/kcov.c kcov needs-flag
+
# XXX machine-independent SCSI files should live somewhere here, maybe
# kernel sources
diff --git a/sys/dev/kcov.c b/sys/dev/kcov.c
index cc8686a7927..1406969438d 100644
--- a/sys/dev/kcov.c
+++ b/sys/dev/kcov.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kcov.c,v 1.1 2018/08/19 11:42:33 anton Exp $ */
+/* $OpenBSD: kcov.c,v 1.2 2018/08/21 18:06:12 anton Exp $ */
/*
* Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
@@ -108,7 +108,6 @@ kcovattach(int count)
int
kcovopen(dev_t dev, int flag, int mode, struct proc *p)
{
-#ifdef KCOV
struct kd *kd;
if (kd_lookup(minor(dev)) != NULL)
@@ -120,9 +119,6 @@ kcovopen(dev_t dev, int flag, int mode, struct proc *p)
kd->kd_unit = minor(dev);
TAILQ_INSERT_TAIL(&kd_list, kd, kd_entry);
return (0);
-#else
- return (ENXIO);
-#endif
}
int
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 4bacf19e3de..0fff6edee2d 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exit.c,v 1.167 2018/08/19 11:42:33 anton Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.168 2018/08/21 18:06:12 anton Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@@ -56,7 +56,6 @@
#include <sys/filedesc.h>
#include <sys/signalvar.h>
#include <sys/sched.h>
-#include <sys/kcov.h>
#include <sys/ktrace.h>
#include <sys/pool.h>
#include <sys/mutex.h>
@@ -71,6 +70,11 @@
#include <uvm/uvm_extern.h>
+#include "kcov.h"
+#if NKCOV > 0
+#include <sys/kcov.h>
+#endif
+
void proc_finish_wait(struct proc *, struct proc *);
void process_zap(struct process *);
void proc_free(struct proc *);
@@ -190,7 +194,7 @@ exit1(struct proc *p, int rv, int flags)
acct_process(p);
#endif
-#ifdef KCOV
+#if NKCOV > 0
kcov_exit(p);
#endif