From 1950b66a01a8643b959e3f0bc59ea47ad82a80ca Mon Sep 17 00:00:00 2001 From: Sangmoon Kim Date: Tue, 19 Jan 2021 20:55:28 +0900 Subject: [PATCH] ANDROID: bug: add vendor hook for bug trap Add hook to gather data of bug trap and summarize it with other information. It helps the bootloader produce the summary information when kernel panic or watchdog reset occurs. It can be obtained through Ramdump, etc., and this information can be used to quickly classify and respond to problems. Bug: 326888644 Bug: 381974812 Change-Id: I4aa398f42e13b50b719f91042d89290d03090d2a Signed-off-by: Sangmoon Kim (cherry picked from commit e74b4da79162aaf5ad40d1df6200da47953d0ff1) Signed-off-by: Cixi Geng --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/bug.h | 16 ++++++++++++++++ lib/bug.c | 4 ++++ 3 files changed, 22 insertions(+) create mode 100644 include/trace/hooks/bug.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 29ecd67341c3..daa1b96fffdf 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -47,6 +47,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -166,3 +167,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_hibernation_swap); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_cpu_resume); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_hib_resume_bdev); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_futex_plist_add); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_report_bug); diff --git a/include/trace/hooks/bug.h b/include/trace/hooks/bug.h new file mode 100644 index 000000000000..bbae73fd14c4 --- /dev/null +++ b/include/trace/hooks/bug.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM bug +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_BUG_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_BUG_H +#include + +DECLARE_RESTRICTED_HOOK(android_rvh_report_bug, + TP_PROTO(const char *file, unsigned int line, unsigned long bugaddr), + TP_ARGS(file, line, bugaddr), 1); + +#endif /* _TRACE_HOOK_BUG_H */ +/* This part must be outside protection */ +#include diff --git a/lib/bug.c b/lib/bug.c index e0ff21989990..5106dbac6b0e 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -49,6 +49,8 @@ #include #include +#include + extern struct bug_entry __start___bug_table[], __stop___bug_table[]; static inline unsigned long bug_addr(const struct bug_entry *bug) @@ -207,6 +209,8 @@ static enum bug_trap_type __report_bug(unsigned long bugaddr, struct pt_regs *re pr_crit("Kernel BUG at %pB [verbose debug info unavailable]\n", (void *)bugaddr); + trace_android_rvh_report_bug(file, line, bugaddr); + return BUG_TRAP_TYPE_BUG; }