From 0ad7fae66c7f1532c7ce25938b322d7536ef89b8 Mon Sep 17 00:00:00 2001 From: Dongbum Kim Date: Thu, 20 Feb 2025 16:27:03 +0900 Subject: [PATCH] ANDROID: printk: add vendor hook to logging during hibernation If hibernation fail, user cannot check log during hibernation. During hibernation, we cannot get any log from copying hibernation image to shutdown the system, for example, write image to storage. A vendor hook copies every log with all loglevel to reserved memory address. We cannot get all loglevels with pstore, so we add vendor hook for copying every log. When the system is rebooted, user can check log from reserved memory address where vendor hook stored in. Bug: 342523877 Change-Id: I31f61378f555ea65ccecfa5b7a96a3ed3e4061a6 Signed-off-by: Dongbum Kim --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/printk.h | 4 ++++ kernel/printk/printk.c | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index bddbde83c145..d76fdab3b839 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -473,3 +473,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sdhci_get_cd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_trigger_vendor_lmk_kill); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_map_pages_range); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_vprintk_store); diff --git a/include/trace/hooks/printk.h b/include/trace/hooks/printk.h index 2598490b1449..15bd58546bc1 100644 --- a/include/trace/hooks/printk.h +++ b/include/trace/hooks/printk.h @@ -13,6 +13,10 @@ DECLARE_HOOK(android_vh_printk_hotplug, TP_PROTO(int *flag), TP_ARGS(flag)); +DECLARE_HOOK(android_vh_vprintk_store, + TP_PROTO(u64 time, char *m, size_t len), + TP_ARGS(time, m, len)); + #endif /* _TRACE_HOOK_PRINTK_H */ /* This part must be outside protection */ #include diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 0a99fd63232d..f6d1c6a4f868 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2248,6 +2248,7 @@ int vprintk_store(int facility, int level, r.info->flags = flags & 0x1f; r.info->ts_nsec = ts_nsec; r.info->caller_id = caller_id; + trace_android_vh_vprintk_store(r.info->ts_nsec, r.text_buf, r.info->text_len); if (dev_info) memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info));