Module Name: src Committed By: maxv Date: Tue Nov 5 20:19:18 UTC 2019
Modified Files: src/share/mk: bsd.sys.mk src/sys/arch/amd64/amd64: machdep.c mptramp.S src/sys/arch/amd64/conf: GENERIC Makefile.amd64 src/sys/arch/x86/x86: cpu.c src/sys/conf: files src/sys/kern: files.kern src/sys/lib/libkern: libkern.h src/sys/sys: atomic.h bus_proto.h cdefs.h systm.h Added Files: src/sys/arch/amd64/include: csan.h src/sys/kern: subr_csan.c src/sys/sys: csan.h Log Message: Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us to detect race conditions at runtime. It is a variation of TSan that is easy to implement and more suited to kernel internals, albeit theoretically less precise than TSan's happens-before. We do basically two things: - On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell describing the access, and delay the calling CPU (10ms). - On all memory accesses, we verify if the memory we're reading/writing is referenced in a cell already. The combination of the two means that, if for example cpu0 does a read that is selected and cpu1 does a write at the same address, kCSan will fire, because cpu1's write collides with cpu0's read cell. The coverage of the instrumentation is the same as that of kASan. Also, the code is organized in a way similar to kASan, so it is easy to add support for more architectures than amd64. kCSan is compatible with KCOV. Reviewed by Kamil. To generate a diff of this commit: cvs rdiff -u -r1.294 -r1.295 src/share/mk/bsd.sys.mk cvs rdiff -u -r1.337 -r1.338 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.26 -r1.27 src/sys/arch/amd64/amd64/mptramp.S cvs rdiff -u -r1.544 -r1.545 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.78 -r1.79 src/sys/arch/amd64/conf/Makefile.amd64 cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/csan.h cvs rdiff -u -r1.173 -r1.174 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.1240 -r1.1241 src/sys/conf/files cvs rdiff -u -r1.35 -r1.36 src/sys/kern/files.kern cvs rdiff -u -r0 -r1.1 src/sys/kern/subr_csan.c cvs rdiff -u -r1.132 -r1.133 src/sys/lib/libkern/libkern.h cvs rdiff -u -r1.15 -r1.16 src/sys/sys/atomic.h cvs rdiff -u -r1.9 -r1.10 src/sys/sys/bus_proto.h cvs rdiff -u -r1.147 -r1.148 src/sys/sys/cdefs.h cvs rdiff -u -r0 -r1.1 src/sys/sys/csan.h cvs rdiff -u -r1.287 -r1.288 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.