ANDROID: vendor_hooks: add vendor hook for bpf jit

add vendor hook for bpf jit init, so that we can do architecture
dependent page table setting

Bug: 343121306
Change-Id: I3b4a8c63dad25a1adb3c92fa80c396f015731423
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.com>
This commit is contained in:
Dezhi Huang 2024-05-28 15:42:32 +08:00 committed by Neill Kapron
parent 1cfb164127
commit 73e6ecb484
3 changed files with 26 additions and 0 deletions

View File

@ -23,6 +23,8 @@
#include <asm/set_memory.h> #include <asm/set_memory.h>
#include "bpf_jit.h" #include "bpf_jit.h"
#undef CREATE_TRACE_POINTS
#include <trace/hooks/bpf_jit_comp.h>
#define TMP_REG_1 (MAX_BPF_JIT_REG + 0) #define TMP_REG_1 (MAX_BPF_JIT_REG + 0)
#define TMP_REG_2 (MAX_BPF_JIT_REG + 1) #define TMP_REG_2 (MAX_BPF_JIT_REG + 1)
@ -1649,6 +1651,8 @@ skip_init_ctx:
goto out_off; goto out_off;
} }
bpf_jit_binary_lock_ro(header); bpf_jit_binary_lock_ro(header);
trace_android_rvh_bpf_int_jit_compile_ro(header,
header->size);
} else { } else {
jit_data->ctx = ctx; jit_data->ctx = ctx;
jit_data->image = image_ptr; jit_data->image = image_ptr;

View File

@ -59,6 +59,7 @@
#include <trace/hooks/topology.h> #include <trace/hooks/topology.h>
#include <trace/hooks/thermal.h> #include <trace/hooks/thermal.h>
#include <trace/hooks/bug.h> #include <trace/hooks/bug.h>
#include <trace/hooks/bpf_jit_comp.h>
#include <trace/hooks/softlockup.h> #include <trace/hooks/softlockup.h>
#include <trace/hooks/power.h> #include <trace/hooks/power.h>
#include <trace/hooks/cpuinfo.h> #include <trace/hooks/cpuinfo.h>
@ -151,6 +152,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_send_command);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_compl_command); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_compl_command);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_bpf_int_jit_compile_ro);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_anon_vma_name_recog); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_anon_vma_name_recog);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_restore_mm_flags); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_restore_mm_flags);

View File

@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM bpf_jit_comp
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_BPF_JIT_COMP_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_BPF_JIT_COMP_H
#include <trace/hooks/vendor_hooks.h>
/*
* Following tracepoints are not exported in tracefs and provide a
* mechanism for vendor modules to hook and extend functionality
*/
struct bpf_binary_header;
DECLARE_RESTRICTED_HOOK(android_rvh_bpf_int_jit_compile_ro,
TP_PROTO(const struct bpf_binary_header *header, u32 size),
TP_ARGS(header, size), 1);
#endif /* _TRACE_HOOK_BPF_JIT_COMP_H */
/* This part must be outside protection */
#include <trace/define_trace.h>