summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike McTernan <mikemcternan@google.com>2023-10-20 17:17:29 +0100
committerEric Lai <ericllai@google.com>2024-01-15 04:51:03 +0000
commitb401fe44da3cb94a12d0866c95f7195980fba3d2 (patch)
tree726b4d436a308752131d673f3ff8d388085c83e1
parent0f73203f48f49930375c34d8b92ca6828fb03c68 (diff)
downloadtrusty-b401fe44da3cb94a12d0866c95f7195980fba3d2.tar.gz
trusty-log: dump Trusty log on kernel panic only if Trusty panicked.android-14.0.0_r0.81android-14.0.0_r0.80android-gs-akita-5.15-android14-d2
Reduce the amount of data being dumped into logs via the panic notifier if the Trusty kernel has not itself panicked. Bug: 306313274 Test: sys-rq crash with force option Test: sys-rq crash without force option Test: Trusty panic without force option Change-Id: I0d2622b905236f50388c2f5b00c17cbdbd0c2edb Signed-off-by: Michael McTernan <mikemcternan@google.com> (cherry picked from commit aefe9b29a6ba0d8af25b34544aeccd7130f6122f)
-rw-r--r--drivers/trusty/trusty-log.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/trusty/trusty-log.c b/drivers/trusty/trusty-log.c
index 425441f..e57f085 100644
--- a/drivers/trusty/trusty-log.c
+++ b/drivers/trusty/trusty-log.c
@@ -135,6 +135,15 @@ module_param_named(log_ratelimit_burst, trusty_log_rate_limit.burst, int, 0644);
module_param_named(log_ratelimit_interval, trusty_log_rate_limit.interval, int,
0644);
+/*
+ * The kernel panic notifier will unconditionaly dump the trusty logs when
+ * called, if this is set. Otherwise the kernel panic notifier will only dump
+ * Trusty logs if Trusty has itself panicked.
+ */
+static bool trusty_log_force_on_panic = false;
+
+module_param_named(log_force_on_panic, trusty_log_force_on_panic, bool, 0644);
+
/**
* struct trusty_log_sfile - trusty log misc device state
*
@@ -567,9 +576,14 @@ static int trusty_log_panic_notify(struct notifier_block *nb,
* though this is racy.
*/
s = container_of(nb, struct trusty_log_state, panic_notifier);
- dev_info(s->dev, "panic notifier - trusty version %s",
- trusty_version_str_get(s->trusty_dev));
- trusty_dump_logs(s);
+
+ if (trusty_log_force_on_panic ||
+ trusty_get_panic_status(s->trusty_dev)) {
+ dev_info(s->dev, "panic notifier - trusty version %s",
+ trusty_version_str_get(s->trusty_dev));
+ trusty_dump_logs(s);
+ }
+
return NOTIFY_OK;
}