From 13f2b693c7cfc0f23946b0691d6ddf6a728fa018 Mon Sep 17 00:00:00 2001 From: Dezhi Huang Date: Sat, 13 Apr 2024 19:10:15 +0800 Subject: [PATCH] ANDROID: vendor_hooks: add hook to record reboot reason Add hook to record the reason for calling hw_protection_shutdown Bug: 380204228 Bug: 334006616 Change-Id: I9dce8056693c96f1d5f1fab9af02a2e68ed6ab91 Signed-off-by: Dezhi Huang (cherry picked from commit 70e95a10a553c0c530694b8939d25fbb984647d0) --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/reboot.h | 18 ++++++++++++++++++ kernel/reboot.c | 4 ++++ 3 files changed, 24 insertions(+) create mode 100644 include/trace/hooks/reboot.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 4911325dec12..58fdb68e6b0b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -194,6 +195,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ra_tuning_max_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_mmap_readaround); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_alloc_node); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_free); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_hw_protection_shutdown); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_selinux_avc_insert); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_selinux_avc_node_delete); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_selinux_avc_node_replace); diff --git a/include/trace/hooks/reboot.h b/include/trace/hooks/reboot.h new file mode 100644 index 000000000000..e9c7d688cbc8 --- /dev/null +++ b/include/trace/hooks/reboot.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM reboot + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_REBOOT_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_REBOOT_H + +#include + +DECLARE_RESTRICTED_HOOK(android_rvh_hw_protection_shutdown, + TP_PROTO(const char *reason), + TP_ARGS(reason), 1); + +#endif /* _TRACE_HOOK_REBOOT_H */ +/* This part must be outside protection */ +#include diff --git a/kernel/reboot.c b/kernel/reboot.c index 182a2106c78d..344ceaf5ed13 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -19,6 +19,8 @@ #include #include +#include + /* * this indicates whether you can reboot with ctrl-alt-del: the default is yes */ @@ -979,6 +981,8 @@ void hw_protection_shutdown(const char *reason, int ms_until_forced) if (!atomic_dec_and_test(&allow_proceed)) return; + trace_android_rvh_hw_protection_shutdown(reason); + /* * Queue a backup emergency shutdown in the event of * orderly_poweroff failure