diff options
author | Mike McTernan <mikemcternan@google.com> | 2023-10-20 17:17:29 +0100 |
---|---|---|
committer | Mike McTernan <mikemcternan@google.com> | 2023-10-20 17:01:20 +0000 |
commit | 8f37ed47ca4e155936ff0fb56d075470afeb4012 (patch) | |
tree | 726b4d436a308752131d673f3ff8d388085c83e1 | |
parent | 0f73203f48f49930375c34d8b92ca6828fb03c68 (diff) | |
download | trusty-8f37ed47ca4e155936ff0fb56d075470afeb4012.tar.gz |
trusty-log: dump Trusty log on kernel panic only if Trusty panicked.
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>
-rw-r--r-- | drivers/trusty/trusty-log.c | 20 |
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; } |