xref: /OK3568_Linux_fs/kernel/include/trace/hooks/binder.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #undef TRACE_SYSTEM
3*4882a593Smuzhiyun #define TRACE_SYSTEM binder
4*4882a593Smuzhiyun #undef TRACE_INCLUDE_PATH
5*4882a593Smuzhiyun #define TRACE_INCLUDE_PATH trace/hooks
6*4882a593Smuzhiyun #if !defined(_TRACE_HOOK_BINDER_H) || defined(TRACE_HEADER_MULTI_READ)
7*4882a593Smuzhiyun #define _TRACE_HOOK_BINDER_H
8*4882a593Smuzhiyun #include <linux/tracepoint.h>
9*4882a593Smuzhiyun #include <trace/hooks/vendor_hooks.h>
10*4882a593Smuzhiyun /*
11*4882a593Smuzhiyun  * Following tracepoints are not exported in tracefs and provide a
12*4882a593Smuzhiyun  * mechanism for vendor modules to hook and extend functionality
13*4882a593Smuzhiyun  */
14*4882a593Smuzhiyun #if defined(__GENKSYMS__) || !IS_ENABLED(CONFIG_ANDROID_BINDER_IPC)
15*4882a593Smuzhiyun struct binder_alloc;
16*4882a593Smuzhiyun struct binder_proc;
17*4882a593Smuzhiyun struct binder_thread;
18*4882a593Smuzhiyun struct binder_transaction;
19*4882a593Smuzhiyun struct binder_transaction_data;
20*4882a593Smuzhiyun #else
21*4882a593Smuzhiyun /* struct binder_alloc */
22*4882a593Smuzhiyun #include <../drivers/android/binder_alloc.h>
23*4882a593Smuzhiyun /* struct binder_proc, struct binder_thread, struct binder_transaction */
24*4882a593Smuzhiyun #include <../drivers/android/binder_internal.h>
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #ifdef __GENKSYMS__
28*4882a593Smuzhiyun struct task_struct;
29*4882a593Smuzhiyun struct seq_file;
30*4882a593Smuzhiyun #else
31*4882a593Smuzhiyun /* struct task_struct */
32*4882a593Smuzhiyun #include <linux/sched.h>
33*4882a593Smuzhiyun /* struct seq_file */
34*4882a593Smuzhiyun #include <linux/seq_file.h>
35*4882a593Smuzhiyun /* struct binder_transaction_data */
36*4882a593Smuzhiyun #include <uapi/linux/android/binder.h>
37*4882a593Smuzhiyun #endif /* __GENKSYMS__ */
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_transaction_init,
40*4882a593Smuzhiyun 	TP_PROTO(struct binder_transaction *t),
41*4882a593Smuzhiyun 	TP_ARGS(t));
42*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_priority_skip,
43*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *task, bool *skip),
44*4882a593Smuzhiyun 	TP_ARGS(task, skip));
45*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_set_priority,
46*4882a593Smuzhiyun 	TP_PROTO(struct binder_transaction *t, struct task_struct *task),
47*4882a593Smuzhiyun 	TP_ARGS(t, task));
48*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_restore_priority,
49*4882a593Smuzhiyun 	TP_PROTO(struct binder_transaction *t, struct task_struct *task),
50*4882a593Smuzhiyun 	TP_ARGS(t, task));
51*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_wakeup_ilocked,
52*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *task, bool sync, struct binder_proc *proc),
53*4882a593Smuzhiyun 	TP_ARGS(task, sync, proc));
54*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_wait_for_work,
55*4882a593Smuzhiyun 	TP_PROTO(bool do_proc_work, struct binder_thread *tsk, struct binder_proc *proc),
56*4882a593Smuzhiyun 	TP_ARGS(do_proc_work, tsk, proc));
57*4882a593Smuzhiyun DECLARE_HOOK(android_vh_sync_txn_recvd,
58*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *tsk, struct task_struct *from),
59*4882a593Smuzhiyun 	TP_ARGS(tsk, from));
60*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_alloc_new_buf_locked,
61*4882a593Smuzhiyun 	TP_PROTO(size_t size, struct binder_alloc *alloc, int is_async),
62*4882a593Smuzhiyun 	TP_ARGS(size, alloc, is_async));
63*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_reply,
64*4882a593Smuzhiyun 	TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc,
65*4882a593Smuzhiyun 		struct binder_thread *thread, struct binder_transaction_data *tr),
66*4882a593Smuzhiyun 	TP_ARGS(target_proc, proc, thread, tr));
67*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_trans,
68*4882a593Smuzhiyun 	TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc,
69*4882a593Smuzhiyun 		struct binder_thread *thread, struct binder_transaction_data *tr),
70*4882a593Smuzhiyun 	TP_ARGS(target_proc, proc, thread, tr));
71*4882a593Smuzhiyun DECLARE_RESTRICTED_HOOK(android_rvh_binder_transaction,
72*4882a593Smuzhiyun 	TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc,
73*4882a593Smuzhiyun 		struct binder_thread *thread, struct binder_transaction_data *tr),
74*4882a593Smuzhiyun 	TP_ARGS(target_proc, proc, thread, tr), 1);
75*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_preset,
76*4882a593Smuzhiyun 	TP_PROTO(struct hlist_head *hhead, struct mutex *lock),
77*4882a593Smuzhiyun 	TP_ARGS(hhead, lock));
78*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_proc_transaction,
79*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *caller_task, struct task_struct *binder_proc_task,
80*4882a593Smuzhiyun 		struct task_struct *binder_th_task, int node_debug_id,
81*4882a593Smuzhiyun 		unsigned int code, bool pending_async),
82*4882a593Smuzhiyun 	TP_ARGS(caller_task, binder_proc_task, binder_th_task, node_debug_id, code, pending_async));
83*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_proc_transaction_end,
84*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *caller_task, struct task_struct *binder_proc_task,
85*4882a593Smuzhiyun 		struct task_struct *binder_th_task, unsigned int code,
86*4882a593Smuzhiyun 		bool pending_async, bool sync),
87*4882a593Smuzhiyun 	TP_ARGS(caller_task, binder_proc_task, binder_th_task, code, pending_async, sync));
88*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_new_ref,
89*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *proc, uint32_t ref_desc, int node_debug_id),
90*4882a593Smuzhiyun 	TP_ARGS(proc, ref_desc, node_debug_id));
91*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_del_ref,
92*4882a593Smuzhiyun 	TP_PROTO(struct task_struct *proc, uint32_t ref_desc),
93*4882a593Smuzhiyun 	TP_ARGS(proc, ref_desc));
94*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_print_transaction_info,
95*4882a593Smuzhiyun 	TP_PROTO(struct seq_file *m, struct binder_proc *proc,
96*4882a593Smuzhiyun 		 const char *prefix, struct binder_transaction *t),
97*4882a593Smuzhiyun 	TP_ARGS(m, proc, prefix, t));
98*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_looper_state_registered,
99*4882a593Smuzhiyun 	TP_PROTO(struct binder_thread *thread, struct binder_proc *proc),
100*4882a593Smuzhiyun 	TP_ARGS(thread, proc));
101*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_thread_read,
102*4882a593Smuzhiyun 	TP_PROTO(struct list_head **list, struct binder_proc *proc,
103*4882a593Smuzhiyun 		struct binder_thread *thread),
104*4882a593Smuzhiyun 	TP_ARGS(list, proc, thread));
105*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_free_proc,
106*4882a593Smuzhiyun 	TP_PROTO(struct binder_proc *proc),
107*4882a593Smuzhiyun 	TP_ARGS(proc));
108*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_thread_release,
109*4882a593Smuzhiyun 	TP_PROTO(struct binder_proc *proc, struct binder_thread *thread),
110*4882a593Smuzhiyun 	TP_ARGS(proc, thread));
111*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_read_done,
112*4882a593Smuzhiyun 	TP_PROTO(struct binder_proc *proc, struct binder_thread *thread),
113*4882a593Smuzhiyun 	TP_ARGS(proc, thread));
114*4882a593Smuzhiyun DECLARE_HOOK(android_vh_binder_has_work_ilocked,
115*4882a593Smuzhiyun 	TP_PROTO(struct binder_thread *thread, bool do_proc_work, int *ret),
116*4882a593Smuzhiyun 	TP_ARGS(thread, do_proc_work, ret));
117*4882a593Smuzhiyun /* macro versions of hooks are no longer required */
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun #endif /* _TRACE_HOOK_BINDER_H */
120*4882a593Smuzhiyun /* This part must be outside protection */
121*4882a593Smuzhiyun #include <trace/define_trace.h>
122