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