diff options
author | Boris Mittelberg <bmbm@google.com> | 2022-10-24 17:21:32 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-03-22 23:55:30 +0000 |
commit | bdad106ad1037600440e59c2462a457f3615e9d4 (patch) | |
tree | fe0693be26249eba50fb9653cbd232ae4871253c | |
parent | 2e7ebc84a64bd9ded1cccb3ebe7bf2c90641a82a (diff) | |
download | chrome-ec-firmware-grunt-11031.B.tar.gz |
panic output: remove assertfirmware-grunt-11031.B
Remove assert to avoid nested panic while getting panic info.
Truncate panic data to maximal supported size.
BRANCH=none
BUG=b:254485444
TEST=./twister -p native_posix -p unit_testing --coverage
Signed-off-by: Boris Mittelberg <bmbm@google.com>
Change-Id: Ibcf3c0244b159578b6c51c80eec23453522059df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3975601
Reviewed-by: Ricardo Quesada <ricardoq@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
(cherry picked from commit 0a031be7f2ca6b9f11f0085cb22960d7780ee4a4)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4329105
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: caveh jalali <caveh@chromium.org>
-rw-r--r-- | common/panic_output.c | 14 | ||||
-rw-r--r-- | include/panic.h | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/common/panic_output.c b/common/panic_output.c index e6b48a375d..06b2b7e51e 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -229,10 +229,18 @@ DECLARE_CONSOLE_COMMAND(panicinfo, command_panicinfo, int host_command_panic_info(struct host_cmd_handler_args *args) { + uint32_t pdata_size = pdata_ptr->struct_size; + if (pdata_ptr->magic == PANIC_DATA_MAGIC) { - ASSERT(pdata_ptr->struct_size <= args->response_max); - memcpy(args->response, pdata_ptr, pdata_ptr->struct_size); - args->response_size = pdata_ptr->struct_size; + if (pdata_size > args->response_max) { + panic_printf("Panic data size %d is too " + "large, truncating to %d\n", + pdata_size, args->response_max); + pdata_size = args->response_max; + pdata_ptr->flags |= PANIC_DATA_FLAG_TRUNCATED; + } + memcpy(args->response, pdata_ptr, pdata_size); + args->response_size = pdata_size; /* Data has now been returned */ pdata_ptr->flags |= PANIC_DATA_FLAG_OLD_HOSTCMD; diff --git a/include/panic.h b/include/panic.h index 8a689c4b23..f3910b70ca 100644 --- a/include/panic.h +++ b/include/panic.h @@ -81,6 +81,8 @@ enum panic_arch { #define PANIC_DATA_FLAG_OLD_HOSTCMD (1 << 2) /* Already reported via host event */ #define PANIC_DATA_FLAG_OLD_HOSTEVENT (1 << 3) +/* The data was truncated to fit panic info host cmd */ +#define PANIC_DATA_FLAG_TRUNCATED (1 << 4) /** * Write a string to the panic reporting device |