summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Mittelberg <bmbm@google.com>2022-10-24 17:21:32 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-28 18:51:37 +0000
commit4b469fb4b1e4d9ab01b5f6a969949537fb6299da (patch)
tree9b8d207da6882101bd37c175641806ef698ab3b9
parente383fd52017e74a96660a20e21123f798687044b (diff)
downloadchrome-ec-4b469fb4b1e4d9ab01b5f6a969949537fb6299da.tar.gz
panic output: remove assert
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/+/3988174
-rw-r--r--common/panic_output.c14
-rw-r--r--include/panic.h2
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 1984081dd7..ffee055183 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -85,6 +85,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