1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/sched.h>
6 #include <uapi/linux/kcov.h>
13 /* Coverage collection is not enabled yet. */
14 KCOV_MODE_DISABLED = 0,
15 /* KCOV was initialized, but tracing mode hasn't been chosen yet. */
18 * Tracing coverage collection mode.
19 * Covered PCs are collected in a per-task buffer.
21 KCOV_MODE_TRACE_PC = 2,
22 /* Collecting comparison operands mode. */
23 KCOV_MODE_TRACE_CMP = 3,
26 #define KCOV_IN_CTXSW (1 << 30)
28 void kcov_task_init(struct task_struct *t);
29 void kcov_task_exit(struct task_struct *t);
31 #define kcov_prepare_switch(t) \
33 (t)->kcov_mode |= KCOV_IN_CTXSW; \
36 #define kcov_finish_switch(t) \
38 (t)->kcov_mode &= ~KCOV_IN_CTXSW; \
41 /* See Documentation/dev-tools/kcov.rst for usage details. */
42 void kcov_remote_start(u64 handle);
43 void kcov_remote_stop(void);
44 u64 kcov_common_handle(void);
46 static inline void kcov_remote_start_common(u64 id)
48 kcov_remote_start(kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, id));
51 static inline void kcov_remote_start_usb(u64 id)
53 kcov_remote_start(kcov_remote_handle(KCOV_SUBSYSTEM_USB, id));
58 static inline void kcov_task_init(struct task_struct *t) {}
59 static inline void kcov_task_exit(struct task_struct *t) {}
60 static inline void kcov_prepare_switch(struct task_struct *t) {}
61 static inline void kcov_finish_switch(struct task_struct *t) {}
62 static inline void kcov_remote_start(u64 handle) {}
63 static inline void kcov_remote_stop(void) {}
64 static inline u64 kcov_common_handle(void)
68 static inline void kcov_remote_start_common(u64 id) {}
69 static inline void kcov_remote_start_usb(u64 id) {}
71 #endif /* CONFIG_KCOV */
72 #endif /* _LINUX_KCOV_H */