Skip to contentSkip to conversation

kcov: Don't trace the code coverage code

PATCH In review James Morse 2 participants 2 messages Apr 13, 2016 KCOV

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcov: Don't trace the code coverage code

Kcov causes the compiler to add a call to __sanitizer_cov_trace_pc() in every basic block. Ftrace patches in a call to _mcount() to each function it has annotated.

Letting these mechanisms annotate each other is a bad thing. Break the loop by adding 'notrace' to __sanitizer_cov_trace_pc() so that ftrace won't try to patch this code.

---
This patch lets arm64 with KCOV and STACK_TRACER boot.

 kernel/kcov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcov.c +1 -1
index 3efbee0834a8..78bed7125515 100644
@@ -43,7 +43,7 @@ struct kcov {
  * Entry point from instrumented code.
  * This is called once per basic-block/edge.
  */
-void __sanitizer_cov_trace_pc(void)
+void notrace __sanitizer_cov_trace_pc(void)
 {
 	struct task_struct *t;
 	enum kcov_mode mode;
Signature · 1 line
2.8.0.rc3
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 29 lines · James Morse

Kcov causes the compiler to add a call to __sanitizer_cov_trace_pc() in every basic block. Ftrace patches in a call to _mcount() to each function it has annotated.

Letting these mechanisms annotate each other is a bad thing. Break the loop by adding 'notrace' to __sanitizer_cov_trace_pc() so that ftrace won't try to patch this code.

---
This patch lets arm64 with KCOV and STACK_TRACER boot.

 kernel/kcov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kcov.c +1 -2
index 3efbee0834a8..78bed7125515 100644
@@ -43,7 +43,7 @@ struct kcov {
  * Entry point from instrumented code.
  * This is called once per basic-block/edge.
  */
-void __sanitizer_cov_trace_pc(void)
+void notrace __sanitizer_cov_trace_pc(void)
 {
        struct task_struct *t;
        enum kcov_mode mode;
--
Quoted 1 line

2.8.0.rc3

Thanks!