Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #undef TRACE_SYSTEM_VAR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifdef CONFIG_BPF_EVENTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #undef __entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define __entry entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #undef __get_dynamic_array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define __get_dynamic_array(field)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 		((void *)__entry + (__entry->__data_loc_##field & 0xffff))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #undef __get_dynamic_array_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define __get_dynamic_array_len(field)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 		((__entry->__data_loc_##field >> 16) & 0xffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #undef __get_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define __get_str(field) ((char *)__get_dynamic_array(field))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #undef __get_bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define __get_bitmask(field) (char *)__get_dynamic_array(field)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #undef __perf_count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define __perf_count(c)	(c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #undef __perf_task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define __perf_task(t)	(t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /* cast any integer, pointer, or small struct to u64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define UINTTYPE(size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	__typeof__(__builtin_choose_expr(size == 1,  (u8)1, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		   __builtin_choose_expr(size == 2, (u16)2, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		   __builtin_choose_expr(size == 4, (u32)3, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		   __builtin_choose_expr(size == 8, (u64)4, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 					 (void)5)))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define __CAST_TO_U64(x) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	typeof(x) __src = (x); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	UINTTYPE(sizeof(x)) __dst; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	memcpy(&__dst, &__src, sizeof(__dst)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	(u64)__dst; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define __CAST1(a,...) __CAST_TO_U64(a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define __CAST2(a,...) __CAST_TO_U64(a), __CAST1(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define __CAST3(a,...) __CAST_TO_U64(a), __CAST2(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define __CAST4(a,...) __CAST_TO_U64(a), __CAST3(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define __CAST5(a,...) __CAST_TO_U64(a), __CAST4(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define __CAST6(a,...) __CAST_TO_U64(a), __CAST5(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define __CAST7(a,...) __CAST_TO_U64(a), __CAST6(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define __CAST8(a,...) __CAST_TO_U64(a), __CAST7(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define __CAST9(a,...) __CAST_TO_U64(a), __CAST8(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define __CAST10(a,...) __CAST_TO_U64(a), __CAST9(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define __CAST11(a,...) __CAST_TO_U64(a), __CAST10(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define __CAST12(a,...) __CAST_TO_U64(a), __CAST11(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /* tracepoints with more than 12 arguments will hit build error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #undef DECLARE_EVENT_CLASS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static notrace void							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) __bpf_trace_##call(void *__data, proto)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct bpf_prog *prog = __data;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * This part is compiled out, it is only here as a build time check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * to make sure that if the tracepoint handling changes, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * bpf probe will fail to compile unless it too is updated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define __DEFINE_EVENT(template, call, proto, args, size)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static inline void bpf_test_probe_##call(void)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	check_trace_callback_type_##call(__bpf_trace_##template);	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) typedef void (*btf_trace_##call)(void *__data, proto);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static union {								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct bpf_raw_event_map event;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	btf_trace_##call handler;					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) } __bpf_trace_tp_map_##call __used					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) __section("__bpf_raw_tp_map") = {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	.event = {							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		.tp		= &__tracepoint_##call,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		.bpf_func	= __bpf_trace_##template,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		.num_args	= COUNT_ARGS(args),			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		.writable_size	= size,					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	},								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define FIRST(x, ...) x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) #undef DEFINE_EVENT_WRITABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define DEFINE_EVENT_WRITABLE(template, call, proto, args, size)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static inline void bpf_test_buffer_##call(void)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* BUILD_BUG_ON() is ignored if the code is completely eliminated, but \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 * BUILD_BUG_ON_ZERO() uses a different mechanism that is not	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 * dead-code-eliminated.					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	 */								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	FIRST(proto);							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	(void)BUILD_BUG_ON_ZERO(size != sizeof(*FIRST(args)));		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #undef DEFINE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define DEFINE_EVENT(template, call, proto, args)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	__DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #undef DEFINE_EVENT_PRINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #undef DEFINE_EVENT_WRITABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #undef __DEFINE_EVENT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #undef FIRST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #endif /* CONFIG_BPF_EVENTS */