Date: Thu, 25 Feb 2021 12:46:34 GMT From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 3fd63ddfdf35 - main - Limit when we call DELAY from KCSAN on amd64 Message-ID: <202102251246.11PCkYss030709@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=3fd63ddfdf3541faea762143365dbc70c16fa49e commit 3fd63ddfdf3541faea762143365dbc70c16fa49e Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2021-02-05 11:41:17 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2021-02-25 12:38:05 +0000 Limit when we call DELAY from KCSAN on amd64 In some cases the DELAY implementation on amd64 can recurse on a spin mutex in the i8254 early delay code. Detect when this is going to happen and don't call delay in this case. It is safe to not delay here with the only issue being KCSAN may not detect data races. Reviewed by: kib Tested by: arichardson Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D28895 --- sys/amd64/include/csan.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/amd64/include/csan.h b/sys/amd64/include/csan.h index c886daa12f69..9daf8275492c 100644 --- a/sys/amd64/include/csan.h +++ b/sys/amd64/include/csan.h @@ -31,6 +31,9 @@ * $FreeBSD$ */ +#include <sys/timetc.h> + +#include <machine/clock.h> #include <machine/cpufunc.h> #include <machine/stack.h> #include <machine/vmparam.h> @@ -64,7 +67,14 @@ kcsan_md_enable_intrs(uint64_t *state) static inline void kcsan_md_delay(uint64_t us) { - DELAY(us); + /* + * Only call DELAY if not using the early delay code. The i8254 + * early delay function may cause us to recurse on a spin lock + * leading to a panic. + */ + if ((tsc_is_invariant && tsc_freq != 0) || + timecounter->tc_quality > 0) + DELAY(us); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102251246.11PCkYss030709>