diff options
author | Andrew Turner <andrew@FreeBSD.org> | 2019-11-21 11:22:08 +0000 |
---|---|---|
committer | Andrew Turner <andrew@FreeBSD.org> | 2019-11-21 11:22:08 +0000 |
commit | 849aef496d2ae19961310f4e92f3a0b928732d26 (patch) | |
tree | c9872d59d6c400ed994da160ee8d67aada890e55 /sys/arm64/arm64 | |
parent | 489912da7bb487a33a7f0642a983c233b22381ba (diff) | |
download | src-849aef496d2ae19961310f4e92f3a0b928732d26.tar.gz src-849aef496d2ae19961310f4e92f3a0b928732d26.zip |
Port the NetBSD KCSAN runtime to FreeBSD.
Update the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime to work in
the FreeBSD kernel. It is a useful tool for finding data races between
threads executing on different CPUs.
This can be enabled by enabling KCSAN in the kernel config, or by using the
GENERIC-KCSAN amd64 kernel. It works on amd64 and arm64, however the later
needs a compiler change to allow -fsanitize=thread that KCSAN uses.
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22315
Notes
Notes:
svn path=/head/; revision=354942
Diffstat (limited to 'sys/arm64/arm64')
-rw-r--r-- | sys/arm64/arm64/bus_machdep.c | 2 | ||||
-rw-r--r-- | sys/arm64/arm64/copystr.c | 2 | ||||
-rw-r--r-- | sys/arm64/arm64/machdep.c | 3 | ||||
-rw-r--r-- | sys/arm64/arm64/mp_machdep.c | 3 |
4 files changed, 9 insertions, 1 deletions
diff --git a/sys/arm64/arm64/bus_machdep.c b/sys/arm64/arm64/bus_machdep.c index f6df4a1eb52a..1fabb91c575f 100644 --- a/sys/arm64/arm64/bus_machdep.c +++ b/sys/arm64/arm64/bus_machdep.c @@ -25,6 +25,8 @@ * */ +#define KCSAN_RUNTIME + #include "opt_platform.h" #include <sys/param.h> diff --git a/sys/arm64/arm64/copystr.c b/sys/arm64/arm64/copystr.c index ebb4acddfbaf..fd4e9af14223 100644 --- a/sys/arm64/arm64/copystr.c +++ b/sys/arm64/arm64/copystr.c @@ -32,7 +32,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> int -copystr(const void * __restrict kfaddr, void * __restrict kdaddr, size_t len, +(copystr)(const void * __restrict kfaddr, void * __restrict kdaddr, size_t len, size_t * __restrict lencopied) { const char *src; diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index d41bae02c0b5..77d01d399ae7 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/cons.h> #include <sys/cpu.h> +#include <sys/csan.h> #include <sys/devmap.h> #include <sys/efi.h> #include <sys/exec.h> @@ -1209,6 +1210,8 @@ initarm(struct arm64_bootparams *abp) kdb_init(); pan_enable(); + kcsan_cpu_init(0); + env = kern_getenv("kernelname"); if (env != NULL) strlcpy(kernelname, env, sizeof(kernelname)); diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 2efdce76c891..bbda274bb226 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/bus.h> #include <sys/cpu.h> +#include <sys/csan.h> #include <sys/kernel.h> #include <sys/ktr.h> #include <sys/malloc.h> @@ -253,6 +254,8 @@ init_secondary(uint64_t cpu) mtx_unlock_spin(&ap_boot_mtx); + kcsan_cpu_init(cpu); + /* Enter the scheduler */ sched_throw(NULL); |