xref: /OK3568_Linux_fs/kernel/include/trace/events/error_report.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Declarations for error reporting tracepoints.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2021, Google LLC.
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun #undef TRACE_SYSTEM
8*4882a593Smuzhiyun #define TRACE_SYSTEM error_report
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #if !defined(_TRACE_ERROR_REPORT_H) || defined(TRACE_HEADER_MULTI_READ)
11*4882a593Smuzhiyun #define _TRACE_ERROR_REPORT_H
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <linux/tracepoint.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifndef __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
16*4882a593Smuzhiyun #define __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun enum error_detector {
19*4882a593Smuzhiyun 	ERROR_DETECTOR_KFENCE,
20*4882a593Smuzhiyun 	ERROR_DETECTOR_KASAN
21*4882a593Smuzhiyun };
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #endif /* __ERROR_REPORT_DECLARE_TRACE_ENUMS_ONCE_ONLY */
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #define error_detector_list	\
26*4882a593Smuzhiyun 	EM(ERROR_DETECTOR_KFENCE, "kfence")	\
27*4882a593Smuzhiyun 	EMe(ERROR_DETECTOR_KASAN, "kasan")
28*4882a593Smuzhiyun /* Always end the list with an EMe. */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #undef EM
31*4882a593Smuzhiyun #undef EMe
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #define EM(a, b)	TRACE_DEFINE_ENUM(a);
34*4882a593Smuzhiyun #define EMe(a, b)	TRACE_DEFINE_ENUM(a);
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun error_detector_list
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #undef EM
39*4882a593Smuzhiyun #undef EMe
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun #define EM(a, b) { a, b },
42*4882a593Smuzhiyun #define EMe(a, b) { a, b }
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun #define show_error_detector_list(val) \
45*4882a593Smuzhiyun 	__print_symbolic(val, error_detector_list)
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun DECLARE_EVENT_CLASS(error_report_template,
48*4882a593Smuzhiyun 		    TP_PROTO(enum error_detector error_detector, unsigned long id),
49*4882a593Smuzhiyun 		    TP_ARGS(error_detector, id),
50*4882a593Smuzhiyun 		    TP_STRUCT__entry(__field(enum error_detector, error_detector)
51*4882a593Smuzhiyun 					     __field(unsigned long, id)),
52*4882a593Smuzhiyun 		    TP_fast_assign(__entry->error_detector = error_detector;
53*4882a593Smuzhiyun 				   __entry->id = id;),
54*4882a593Smuzhiyun 		    TP_printk("[%s] %lx",
55*4882a593Smuzhiyun 			      show_error_detector_list(__entry->error_detector),
56*4882a593Smuzhiyun 			      __entry->id));
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun /**
59*4882a593Smuzhiyun  * error_report_end - called after printing the error report
60*4882a593Smuzhiyun  * @error_detector:	short string describing the error detection tool
61*4882a593Smuzhiyun  * @id:			pseudo-unique descriptor identifying the report
62*4882a593Smuzhiyun  *			(e.g. the memory access address)
63*4882a593Smuzhiyun  *
64*4882a593Smuzhiyun  * This event occurs right after a debugging tool finishes printing the error
65*4882a593Smuzhiyun  * report.
66*4882a593Smuzhiyun  */
67*4882a593Smuzhiyun DEFINE_EVENT(error_report_template, error_report_end,
68*4882a593Smuzhiyun 	     TP_PROTO(enum error_detector error_detector, unsigned long id),
69*4882a593Smuzhiyun 	     TP_ARGS(error_detector, id));
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun #endif /* _TRACE_ERROR_REPORT_H */
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun /* This part must be outside protection */
74*4882a593Smuzhiyun #include <trace/define_trace.h>
75