aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2021-02-05 11:41:17 +0000
committerAndrew Turner <andrew@FreeBSD.org>2021-02-25 12:38:05 +0000
commit3fd63ddfdf3541faea762143365dbc70c16fa49e (patch)
tree163b2badacb75c736aac53b06c5ac5f30628c8ce
parent59f6ddb2bc9c560c84b6ac30a2e1f140325f0a86 (diff)
downloadsrc-3fd63ddfdf3541faea762143365dbc70c16fa49e.tar.gz
src-3fd63ddfdf3541faea762143365dbc70c16fa49e.zip
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
-rw-r--r--sys/amd64/include/csan.h12
1 files changed, 11 insertions, 1 deletions
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