support android vendor hooks for openEuler-23.09
Jialin Zhang (2): vendor_hooks: make android vendor hooks feature generic. openeuler_defconfig: enable CONFIG_VENDOR_HOOKS for x86 and arm64
Nick Desaulniers (1): ANDROID: vendor_hooks: fix __section macro
Todd Kjos (5): ANDROID: add support for vendor hooks ANDROID: fix redefinition error for restricted vendor hooks ANDROID: use static_call() for restricted hooks ANDROID: simplify vendor hooks for non-GKI builds ANDROID: fixup restricted hooks after tracepont refactoring
arch/arm64/configs/openeuler_defconfig | 6 ++ arch/x86/configs/openeuler_defconfig | 6 ++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/hooks/Kconfig | 13 +++ drivers/hooks/Makefile | 4 + drivers/hooks/vendor_hooks.c | 16 ++++ include/trace/hooks/vendor_hooks.h | 119 +++++++++++++++++++++++++ 8 files changed, 167 insertions(+) create mode 100644 drivers/hooks/Kconfig create mode 100644 drivers/hooks/Makefile create mode 100644 drivers/hooks/vendor_hooks.c create mode 100644 include/trace/hooks/vendor_hooks.h
From: Todd Kjos tkjos@google.com
aosp inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
Reference: https://android.googlesource.com/kernel/common/+/7f62740112ef
-------------------------------------------------
Add support for vendor hooks. Adds include/trace/hooks directory for trace definition headers where hooks can be defined and vendor_hook.c for instantiating and exporting them for vendor modules.
There are two variants of vendor hooks, both based on tracepoints:
Normal: this uses the DECLARE_HOOK macro to create a tracepoint function with the name trace_<name> where <name> is the unique identifier for the trace.
Restricted: restricted hooks are needed for cases like scheduler hooks where the attached function must be called even if the cpu is offline or requires a non-atomic context. Restricted vendor hooks cannot be detached, so modules that attach to a restricted hook can never unload. Also, only 1 attachment is allowed (any other attempts to attach will fail with -EBUSY).
For either case, modules attach to the hook by using register_trace_<name>(func_ptr, NULL).
New hooks should be defined in headers in the include/trace/hooks/ directory using the DECLARE_HOOK() or DECLARE_RESTRICTED_HOOK() macros.
New files added to include/trace/hooks should be #include'd from drivers/android/vendor_hooks.c. The EXPORT_TRACEPOINT_SYMBOL_GPL() should be also added to drivers/android/vendor_hooks.c.
For example, if a new hook, 'android_vh_foo(int &ret)' is added in do_exit() in exit.c, these changes are needed:
1. create a new header file include/trace/hooks/foo.h which contains: #include <trace/hooks/vendor_hooks.h> ... DECLARE_HOOK(android_vh_foo, TP_PROTO(int *retp), TP_ARGS(retp);
2. in exit.c, add #include <trace/hooks/foo.h> ... int ret = 0; ... android_vh_foo(&ret); if (ret) return ret; ...
3. in drivers/android/vendor_hooks.c, add #include <trace/hooks/foo.h> ... EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_foo);
The hook can then be attached by adding the registration code to the module:
#include <trace/hooks/sched.h> ... static void my_foo(int *retp) { *retp = 0; } ... rc = register_trace_android_vh_sched_exit(my_foo, NULL);
Bug: 156285741 Signed-off-by: Todd Kjos tkjos@google.com Change-Id: I6a7d1c8919dae91c965e2a0450df50eac2d282db Conflicts: drivers/android/Kconfig Signed-off-by: Yu Liao liaoyu15@huawei.com --- drivers/android/Kconfig | 9 ++++ drivers/android/Makefile | 1 + drivers/android/vendor_hooks.c | 16 +++++++ include/trace/hooks/vendor_hooks.h | 72 ++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 drivers/android/vendor_hooks.c create mode 100644 include/trace/hooks/vendor_hooks.h
diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig index 07aa8ae0a058..9dbee23aac66 100644 --- a/drivers/android/Kconfig +++ b/drivers/android/Kconfig @@ -47,4 +47,13 @@ config ANDROID_BINDER_IPC_SELFTEST exhaustively with combinations of various buffer sizes and alignments.
+config ANDROID_VENDOR_HOOKS + bool "Android Vendor Hooks" + depends on TRACEPOINTS + ---help--- + Enable vendor hooks implemented as tracepoints + + Allow vendor modules to attach to tracepoint "hooks" defined via + DECLARE_HOOK or DECLARE_RESTRICTED_HOOK. + endmenu diff --git a/drivers/android/Makefile b/drivers/android/Makefile index c9d3d0c99c25..d488047415a0 100644 --- a/drivers/android/Makefile +++ b/drivers/android/Makefile @@ -4,3 +4,4 @@ ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_ANDROID_BINDERFS) += binderfs.o obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o +obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c new file mode 100644 index 000000000000..4a403a81eed3 --- /dev/null +++ b/drivers/android/vendor_hooks.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* vendor_hook.c + * + * Android Vendor Hook Support + * + * Copyright (C) 2020 Google, Inc. + */ + +#define CREATE_TRACE_POINTS +#include <trace/hooks/vendor_hooks.h> + +/* + * Export tracepoints that act as a bare tracehook (ie: have no trace event + * associated with them) to allow external modules to probe them. + */ + diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h new file mode 100644 index 000000000000..9d9ae21895dd --- /dev/null +++ b/include/trace/hooks/vendor_hooks.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#if !defined(_TRACE_VENDOR_HOOKS_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_VENDOR_HOOKS_H + +#include <linux/tracepoint.h> + +#define DECLARE_HOOK DECLARE_TRACE + +#ifdef TRACE_HEADER_MULTI_READ + +#undef DECLARE_RESTRICTED_HOOK +#define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ + DEFINE_TRACE(name) + +/* prevent additional recursion */ +#undef TRACE_HEADER_MULTI_READ +#else /* TRACE_HEADER_MULTI_READ */ + +#define DO_HOOK(tp, proto, args, cond) \ + do { \ + struct tracepoint_func *it_func_ptr; \ + void *it_func; \ + void *__data; \ + \ + if (!(cond)) \ + return; \ + \ + it_func_ptr = (tp)->funcs; \ + if (it_func_ptr) { \ + it_func = (it_func_ptr)->func; \ + __data = (it_func_ptr)->data; \ + ((void(*)(proto))(it_func))(args); \ + WARN_ON(((++it_func_ptr)->func)); \ + } \ + } while (0) + +#define __DECLARE_HOOK(name, proto, args, cond, data_proto, data_args) \ + extern struct tracepoint __tracepoint_##name; \ + static inline void trace_##name(proto) \ + { \ + if (static_key_false(&__tracepoint_##name.key)) \ + DO_HOOK(&__tracepoint_##name, \ + TP_PROTO(data_proto), \ + TP_ARGS(data_args), \ + TP_CONDITION(cond)); \ + } \ + static inline bool \ + trace_##name##_enabled(void) \ + { \ + return static_key_false(&__tracepoint_##name.key); \ + } \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), void *data) \ + { \ + /* only allow a single attachment */ \ + if (trace_##name##_enabled()) \ + return -EBUSY; \ + return tracepoint_probe_register(&__tracepoint_##name, \ + (void *)probe, data); \ + } \ + /* vendor hooks cannot be unregistered */ \ + +#define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ + __DECLARE_HOOK(name, PARAMS(proto), PARAMS(args), \ + cond, \ + PARAMS(void *__data, proto), \ + PARAMS(__data, args)) + +#endif /* TRACE_HEADER_MULTI_READ */ + +#endif /* _TRACE_VENDOR_HOOKS_H */
From: Todd Kjos tkjos@google.com
aosp inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
Reference: https://android.googlesource.com/kernel/common/+/e706f27c765b
-------------------------------------------------
Because of the multi-inclusion oddities of tracepoints, the multi-inclusion protection in vendor_hooks.h caused issues if more than 1 vendor hook header file with restricted vendor hooks defined were included with "CREATE_TRACE_POINTS" defined (redefinition of symbol errors).
The problem is fixed by removing the multiple-inclusion protection as is done for regular tracepoints.
Fixes: 7f62740112ef ("ANDROID: add support for vendor hooks") Bug: 163076069 Signed-off-by: Todd Kjos tkjos@google.com Change-Id: Ic177db1693a6a2db58f08917e9115c7e6c2971b6 Signed-off-by: Yu Liao liaoyu15@huawei.com --- include/trace/hooks/vendor_hooks.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h index 9d9ae21895dd..8a3fdb9222e5 100644 --- a/include/trace/hooks/vendor_hooks.h +++ b/include/trace/hooks/vendor_hooks.h @@ -1,7 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0 */
-#if !defined(_TRACE_VENDOR_HOOKS_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_VENDOR_HOOKS_H +/* + * Note: we intentionally omit include file ifdef protection + * This is due to the way trace events work. If a file includes two + * trace event headers under one "CREATE_TRACE_POINTS" the first include + * will override the DECLARE_RESTRICTED_HOOK and break the second include. + */
#include <linux/tracepoint.h>
@@ -13,6 +17,7 @@ #define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ DEFINE_TRACE(name)
+ /* prevent additional recursion */ #undef TRACE_HEADER_MULTI_READ #else /* TRACE_HEADER_MULTI_READ */ @@ -61,6 +66,7 @@ } \ /* vendor hooks cannot be unregistered */ \
+#undef DECLARE_RESTRICTED_HOOK #define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ __DECLARE_HOOK(name, PARAMS(proto), PARAMS(args), \ cond, \ @@ -68,5 +74,3 @@ PARAMS(__data, args))
#endif /* TRACE_HEADER_MULTI_READ */ - -#endif /* _TRACE_VENDOR_HOOKS_H */
From: Todd Kjos tkjos@google.com
aosp inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
Reference: https://android.googlesource.com/kernel/common/+/5e767aa07eea
-------------------------------------------------
commit d25e37d89dd2 ("tracepoint: Optimize using static_call()") refactored tracepoints to use static_call(). Add the same optimization for restricted vendor hooks.
Fixes: d25e37d89dd2 ("tracepoint: Optimize using static_call()") Signed-off-by: Todd Kjos tkjos@google.com Change-Id: I336db7e90b733ac4098ce342001cc31fd215d137 Signed-off-by: Yu Liao liaoyu15@huawei.com --- include/trace/hooks/vendor_hooks.h | 46 ++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h index 8a3fdb9222e5..8a7acb983c67 100644 --- a/include/trace/hooks/vendor_hooks.h +++ b/include/trace/hooks/vendor_hooks.h @@ -13,39 +13,67 @@
#ifdef TRACE_HEADER_MULTI_READ
+#define DEFINE_HOOK_FN(_name, _reg, _unreg, proto, args) \ + static const char __tpstrtab_##_name[] \ + __section(__tracepoints_strings) = #_name; \ + extern struct static_call_key STATIC_CALL_KEY(tp_func_##_name); \ + int __traceiter_##_name(void *__data, proto); \ + struct tracepoint __tracepoint_##_name __used \ + __section(__tracepoints) = { \ + .name = __tpstrtab_##_name, \ + .key = STATIC_KEY_INIT_FALSE, \ + .static_call_key = &STATIC_CALL_KEY(tp_func_##_name), \ + .static_call_tramp = STATIC_CALL_TRAMP_ADDR(tp_func_##_name), \ + .iterator = &__traceiter_##_name, \ + .regfunc = _reg, \ + .unregfunc = _unreg, \ + .funcs = NULL }; \ + __TRACEPOINT_ENTRY(_name); \ + int __traceiter_##_name(void *__data, proto) \ + { \ + struct tracepoint_func *it_func_ptr; \ + void *it_func; \ + \ + it_func_ptr = (&__tracepoint_##_name)->funcs; \ + it_func = (it_func_ptr)->func; \ + __data = (it_func_ptr)->data; \ + ((void(*)(void *, proto))(it_func))(__data, args); \ + WARN_ON(((++it_func_ptr)->func)); \ + return 0; \ + } \ + DEFINE_STATIC_CALL(tp_func_##_name, __traceiter_##_name); + #undef DECLARE_RESTRICTED_HOOK #define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ - DEFINE_TRACE(name) - + DEFINE_HOOK_FN(name, NULL, NULL, PARAMS(proto), PARAMS(args))
/* prevent additional recursion */ #undef TRACE_HEADER_MULTI_READ #else /* TRACE_HEADER_MULTI_READ */
-#define DO_HOOK(tp, proto, args, cond) \ +#define DO_HOOK(name, proto, args, cond) \ do { \ struct tracepoint_func *it_func_ptr; \ - void *it_func; \ void *__data; \ \ if (!(cond)) \ return; \ \ - it_func_ptr = (tp)->funcs; \ + it_func_ptr = (&__tracepoint_##name)->funcs; \ if (it_func_ptr) { \ - it_func = (it_func_ptr)->func; \ __data = (it_func_ptr)->data; \ - ((void(*)(proto))(it_func))(args); \ - WARN_ON(((++it_func_ptr)->func)); \ + __DO_TRACE_CALL(name)(args); \ } \ } while (0)
#define __DECLARE_HOOK(name, proto, args, cond, data_proto, data_args) \ + extern int __traceiter_##name(data_proto); \ + DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name); \ extern struct tracepoint __tracepoint_##name; \ static inline void trace_##name(proto) \ { \ if (static_key_false(&__tracepoint_##name.key)) \ - DO_HOOK(&__tracepoint_##name, \ + DO_HOOK(name, \ TP_PROTO(data_proto), \ TP_ARGS(data_args), \ TP_CONDITION(cond)); \
From: Nick Desaulniers ndesaulniers@google.com
aosp inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
Reference: https://android.googlesource.com/kernel/common/+/4cc2f83c77aa
-------------------------------------------------
After upstream 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to __section("foo")"), the preprocessor macro __section now requires the section name to be double quoted.
This patch resolves breakage that results from merging down from mainline in this out of tree header.
Fixes: 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to __section("foo")") Signed-off-by: Nick Desaulniers ndesaulniers@google.com Signed-off-by: Greg Kroah-Hartman gregkh@google.com Change-Id: Ie6a701251e6420e63187a466b43ec2c834e0ec2e Signed-off-by: Yu Liao liaoyu15@huawei.com --- include/trace/hooks/vendor_hooks.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h index 8a7acb983c67..e6cabd366eeb 100644 --- a/include/trace/hooks/vendor_hooks.h +++ b/include/trace/hooks/vendor_hooks.h @@ -15,11 +15,11 @@
#define DEFINE_HOOK_FN(_name, _reg, _unreg, proto, args) \ static const char __tpstrtab_##_name[] \ - __section(__tracepoints_strings) = #_name; \ + __section("__tracepoints_strings") = #_name; \ extern struct static_call_key STATIC_CALL_KEY(tp_func_##_name); \ int __traceiter_##_name(void *__data, proto); \ struct tracepoint __tracepoint_##_name __used \ - __section(__tracepoints) = { \ + __section("__tracepoints") = { \ .name = __tpstrtab_##_name, \ .key = STATIC_KEY_INIT_FALSE, \ .static_call_key = &STATIC_CALL_KEY(tp_func_##_name), \
From: Todd Kjos tkjos@google.com
aosp inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
Reference: https://android.googlesource.com/kernel/common/+/943c3b3124d2
-------------------------------------------------
Vendor hooks required explicitly defining macros or inline functions to handle the non-GKI build case (!CONFIG_ANDROID_VENDOR_HOOKS). Added support for generating them automatically so the macros are no longer required.
Both models are now supported so we can transition.
Bug: 177416721 Signed-off-by: Todd Kjos tkjos@google.com Change-Id: I01acc389d315a5d509b0c48116854342a42e1058 Signed-off-by: Yu Liao liaoyu15@huawei.com --- include/trace/hooks/vendor_hooks.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h index e6cabd366eeb..ef8c95aaebf0 100644 --- a/include/trace/hooks/vendor_hooks.h +++ b/include/trace/hooks/vendor_hooks.h @@ -9,6 +9,8 @@
#include <linux/tracepoint.h>
+#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) + #define DECLARE_HOOK DECLARE_TRACE
#ifdef TRACE_HEADER_MULTI_READ @@ -102,3 +104,10 @@ PARAMS(__data, args))
#endif /* TRACE_HEADER_MULTI_READ */ + +#else /* !CONFIG_TRACEPOINTS || !CONFIG_ANDROID_VENDOR_HOOKS */ +/* suppress trace hooks */ +#define DECLARE_HOOK DECLARE_EVENT_NOP +#define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ + DECLARE_EVENT_NOP(name, PARAMS(proto), PARAMS(args)) +#endif
From: Todd Kjos tkjos@google.com
aosp inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
Reference: https://android.googlesource.com/kernel/common/+/51681321c0ef
-------------------------------------------------
In upstream commit d9a1be1be331 ("tracepoints: Do not punish non static call users"), tracepoint macros were refactored to optimize for static_call() cases. Since the Android-specific restricted vendor hook mechanism leverages tracehooks, this required equivalent refactoring in include/trace/hooks/vendor_hooks.h
Fixes: d9a1be1be331 ("tracepoints: Do not punish non static call users") Signed-off-by: Todd Kjos tkjos@google.com Change-Id: I2e01b34606e6ff0e577b76b57c47f601c32f626b Signed-off-by: Greg Kroah-Hartman gregkh@google.com Signed-off-by: Yu Liao liaoyu15@huawei.com --- include/trace/hooks/vendor_hooks.h | 34 ++++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h index ef8c95aaebf0..3661e5056519 100644 --- a/include/trace/hooks/vendor_hooks.h +++ b/include/trace/hooks/vendor_hooks.h @@ -53,32 +53,39 @@ #undef TRACE_HEADER_MULTI_READ #else /* TRACE_HEADER_MULTI_READ */
-#define DO_HOOK(name, proto, args, cond) \ +#ifdef CONFIG_HAVE_STATIC_CALL +#define __DO_RESTRICTED_HOOK_CALL(name, args) \ do { \ struct tracepoint_func *it_func_ptr; \ void *__data; \ - \ - if (!(cond)) \ - return; \ - \ it_func_ptr = (&__tracepoint_##name)->funcs; \ if (it_func_ptr) { \ __data = (it_func_ptr)->data; \ - __DO_TRACE_CALL(name)(args); \ + static_call(tp_func_##name)(__data, args); \ } \ } while (0) +#else +#define __DO_RESTRICTED_HOOK_CALL(name, args) __traceiter_##name(NULL, args) +#endif + +#define DO_RESTRICTED_HOOK(name, args, cond) \ + do { \ + if (!(cond)) \ + return; \ + \ + __DO_RESTRICTED_HOOK_CALL(name, TP_ARGS(args)); \ + } while (0)
-#define __DECLARE_HOOK(name, proto, args, cond, data_proto, data_args) \ +#define __DECLARE_RESTRICTED_HOOK(name, proto, args, cond, data_proto) \ extern int __traceiter_##name(data_proto); \ DECLARE_STATIC_CALL(tp_func_##name, __traceiter_##name); \ extern struct tracepoint __tracepoint_##name; \ static inline void trace_##name(proto) \ { \ if (static_key_false(&__tracepoint_##name.key)) \ - DO_HOOK(name, \ - TP_PROTO(data_proto), \ - TP_ARGS(data_args), \ - TP_CONDITION(cond)); \ + DO_RESTRICTED_HOOK(name, \ + TP_ARGS(args), \ + TP_CONDITION(cond)); \ } \ static inline bool \ trace_##name##_enabled(void) \ @@ -98,10 +105,9 @@
#undef DECLARE_RESTRICTED_HOOK #define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \ - __DECLARE_HOOK(name, PARAMS(proto), PARAMS(args), \ + __DECLARE_RESTRICTED_HOOK(name, PARAMS(proto), PARAMS(args), \ cond, \ - PARAMS(void *__data, proto), \ - PARAMS(__data, args)) + PARAMS(void *__data, proto))
#endif /* TRACE_HEADER_MULTI_READ */
From: Jialin Zhang zhangjialin11@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
-------------------------------------------------
Make android vendor hooks feature generic.
Signed-off-by: Jialin Zhang zhangjialin11@huawei.com Reviewed-by: Wei Li liwei391@huawei.com Reviewed-by: Xie XiuQi xiexiuqi@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com Signed-off-by: Yu Liao liaoyu15@huawei.com --- drivers/Kconfig | 2 ++ drivers/Makefile | 1 + drivers/android/Kconfig | 9 --------- drivers/android/Makefile | 1 - drivers/hooks/Kconfig | 13 +++++++++++++ drivers/hooks/Makefile | 4 ++++ drivers/{android => hooks}/vendor_hooks.c | 2 +- include/trace/hooks/vendor_hooks.h | 4 ++-- 8 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 drivers/hooks/Kconfig create mode 100644 drivers/hooks/Makefile rename drivers/{android => hooks}/vendor_hooks.c (91%)
diff --git a/drivers/Kconfig b/drivers/Kconfig index cc09f02c76d0..07700cc35d16 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -207,6 +207,8 @@ source "drivers/thunderbolt/Kconfig"
source "drivers/android/Kconfig"
+source "drivers/hooks/Kconfig" + source "drivers/gpu/trace/Kconfig"
source "drivers/nvdimm/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 45e1f63f20ad..7c4a51caf4ba 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -181,6 +181,7 @@ obj-y += hwtracing/intel_th/ obj-$(CONFIG_STM) += hwtracing/stm/ obj-$(CONFIG_HISI_PTT) += hwtracing/ptt/ obj-y += android/ +obj-$(CONFIG_VENDOR_HOOKS) += hooks/ obj-$(CONFIG_NVMEM) += nvmem/ obj-$(CONFIG_FPGA) += fpga/ obj-$(CONFIG_FSI) += fsi/ diff --git a/drivers/android/Kconfig b/drivers/android/Kconfig index 9dbee23aac66..07aa8ae0a058 100644 --- a/drivers/android/Kconfig +++ b/drivers/android/Kconfig @@ -47,13 +47,4 @@ config ANDROID_BINDER_IPC_SELFTEST exhaustively with combinations of various buffer sizes and alignments.
-config ANDROID_VENDOR_HOOKS - bool "Android Vendor Hooks" - depends on TRACEPOINTS - ---help--- - Enable vendor hooks implemented as tracepoints - - Allow vendor modules to attach to tracepoint "hooks" defined via - DECLARE_HOOK or DECLARE_RESTRICTED_HOOK. - endmenu diff --git a/drivers/android/Makefile b/drivers/android/Makefile index d488047415a0..c9d3d0c99c25 100644 --- a/drivers/android/Makefile +++ b/drivers/android/Makefile @@ -4,4 +4,3 @@ ccflags-y += -I$(src) # needed for trace events obj-$(CONFIG_ANDROID_BINDERFS) += binderfs.o obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o binder_alloc.o obj-$(CONFIG_ANDROID_BINDER_IPC_SELFTEST) += binder_alloc_selftest.o -obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o diff --git a/drivers/hooks/Kconfig b/drivers/hooks/Kconfig new file mode 100644 index 000000000000..1c0e33ef9a56 --- /dev/null +++ b/drivers/hooks/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +menu "Vendor Hooks" + +config VENDOR_HOOKS + bool "Vendor Hooks" + depends on TRACEPOINTS + help + Enable vendor hooks implemented as tracepoints + + Allow vendor modules to attach to tracepoint "hooks" defined via + DECLARE_HOOK or DECLARE_RESTRICTED_HOOK. + +endmenu diff --git a/drivers/hooks/Makefile b/drivers/hooks/Makefile new file mode 100644 index 000000000000..159230826966 --- /dev/null +++ b/drivers/hooks/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only +ccflags-y += -I$(src) # needed for trace events + +obj-$(CONFIG_VENDOR_HOOKS) += vendor_hooks.o diff --git a/drivers/android/vendor_hooks.c b/drivers/hooks/vendor_hooks.c similarity index 91% rename from drivers/android/vendor_hooks.c rename to drivers/hooks/vendor_hooks.c index 4a403a81eed3..359989d1bb32 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/hooks/vendor_hooks.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* vendor_hook.c * - * Android Vendor Hook Support + * Vendor Hook Support * * Copyright (C) 2020 Google, Inc. */ diff --git a/include/trace/hooks/vendor_hooks.h b/include/trace/hooks/vendor_hooks.h index 3661e5056519..ab8864da66d8 100644 --- a/include/trace/hooks/vendor_hooks.h +++ b/include/trace/hooks/vendor_hooks.h @@ -9,7 +9,7 @@
#include <linux/tracepoint.h>
-#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) +#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_VENDOR_HOOKS)
#define DECLARE_HOOK DECLARE_TRACE
@@ -111,7 +111,7 @@
#endif /* TRACE_HEADER_MULTI_READ */
-#else /* !CONFIG_TRACEPOINTS || !CONFIG_ANDROID_VENDOR_HOOKS */ +#else /* !CONFIG_TRACEPOINTS || !CONFIG_VENDOR_HOOKS */ /* suppress trace hooks */ #define DECLARE_HOOK DECLARE_EVENT_NOP #define DECLARE_RESTRICTED_HOOK(name, proto, args, cond) \
From: Jialin Zhang zhangjialin11@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I7YFU9
-------------------------------------------------
Enable CONFIG_VENDOR_HOOKS for x86 and arm64 by default.
Signed-off-by: Jialin Zhang zhangjialin11@huawei.com Reviewed-by: Wei Li liwei391@huawei.com Reviewed-by: Xie XiuQi xiexiuqi@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com Signed-off-by: Yu Liao liaoyu15@huawei.com --- arch/arm64/configs/openeuler_defconfig | 6 ++++++ arch/x86/configs/openeuler_defconfig | 6 ++++++ 2 files changed, 12 insertions(+)
diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index 13e6529e38f3..9d071bb380f6 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6548,6 +6548,12 @@ CONFIG_USB4=m # CONFIG_ANDROID_BINDER_IPC is not set # end of Android
+# +# Vendor Hooks +# +CONFIG_VENDOR_HOOKS=y +# end of Vendor Hooks + CONFIG_LIBNVDIMM=m CONFIG_BLK_DEV_PMEM=m CONFIG_ND_CLAIM=y diff --git a/arch/x86/configs/openeuler_defconfig b/arch/x86/configs/openeuler_defconfig index bcae1af1ad6e..0713d2669844 100644 --- a/arch/x86/configs/openeuler_defconfig +++ b/arch/x86/configs/openeuler_defconfig @@ -7790,6 +7790,12 @@ CONFIG_USB4=m # CONFIG_ANDROID_BINDER_IPC is not set # end of Android
+# +# Vendor Hooks +# +CONFIG_VENDOR_HOOKS=y +# end of Vendor Hooks + CONFIG_LIBNVDIMM=m CONFIG_BLK_DEV_PMEM=m CONFIG_ND_CLAIM=y
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/1989 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/L...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/1989 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/L...