|
@@ -19,6 +19,7 @@
|
|
#include <linux/debugfs.h>
|
|
#include <linux/debugfs.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/kcov.h>
|
|
#include <linux/kcov.h>
|
|
|
|
+#include <asm/setup.h>
|
|
|
|
|
|
/*
|
|
/*
|
|
* kcov descriptor (one per opened debugfs file).
|
|
* kcov descriptor (one per opened debugfs file).
|
|
@@ -73,6 +74,11 @@ void notrace __sanitizer_cov_trace_pc(void)
|
|
if (mode == KCOV_MODE_TRACE) {
|
|
if (mode == KCOV_MODE_TRACE) {
|
|
unsigned long *area;
|
|
unsigned long *area;
|
|
unsigned long pos;
|
|
unsigned long pos;
|
|
|
|
+ unsigned long ip = _RET_IP_;
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_RANDOMIZE_BASE
|
|
|
|
+ ip -= kaslr_offset();
|
|
|
|
+#endif
|
|
|
|
|
|
/*
|
|
/*
|
|
* There is some code that runs in interrupts but for which
|
|
* There is some code that runs in interrupts but for which
|
|
@@ -86,7 +92,7 @@ void notrace __sanitizer_cov_trace_pc(void)
|
|
/* The first word is number of subsequent PCs. */
|
|
/* The first word is number of subsequent PCs. */
|
|
pos = READ_ONCE(area[0]) + 1;
|
|
pos = READ_ONCE(area[0]) + 1;
|
|
if (likely(pos < t->kcov_size)) {
|
|
if (likely(pos < t->kcov_size)) {
|
|
- area[pos] = _RET_IP_;
|
|
|
|
|
|
+ area[pos] = ip;
|
|
WRITE_ONCE(area[0], pos);
|
|
WRITE_ONCE(area[0], pos);
|
|
}
|
|
}
|
|
}
|
|
}
|