summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-02-19 09:07:24 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-20 00:07:01 +0000
commit91268fb85e1a09ffc3d64ea139bc7d09305c0396 (patch)
treeef734d5519275837a9e1f34b973d1b9d02411a13
parent3ae7240410e1bbdca9c0da49d23a8d8349eb2ef4 (diff)
downloadchrome-ec-91268fb85e1a09ffc3d64ea139bc7d09305c0396.tar.gz
panic: fix logging of watchdog in panic data
Fix bug with the new CONFIG_SOFTWARE_PANIC where a watchdog panic will write panic data after jump_data pointer is calculated. Since jump data uses the same RAM location as panic data (the end of RAM), we rely on panic data being written BEFORE jump data pointer is calculated so that we don't use the same RAM space. BUG=chrome-os-partner:36871 BRANCH=samus TEST=without this CL, can reproduce problem where jump data is corrupted using samus with following steps: 1) hibernate 1 (this will clear panicinfo) 2) waitms 3000 (this will cause a watchdog reset) 3) let system boot to S0 4) sysjump rw On sysjump to RW, the jump data will be corrupt because while we were in RO panic data was added where there wasn't any before. This means the jump_data pointer in RW will differ from the jump_data pointer that was used in RO and we will fail to find the magic jump data. Most visible consequence of this is that the USB ports will be disabled after these steps because we use jump data to store last state of USB port enables. With this CL, following the steps above, the USB ports are restored to the pre-sysjump state, which is enabled. Change-Id: Ia129419db7400eddb54bcf57b4d4aed63d5c52ef Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/251110 Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/panic_output.c10
-rw-r--r--common/system.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/common/panic_output.c b/common/panic_output.c
index af98c5953d..a2c5e56b32 100644
--- a/common/panic_output.c
+++ b/common/panic_output.c
@@ -115,16 +115,6 @@ struct panic_data *panic_get_data(void)
return pdata_ptr->magic == PANIC_DATA_MAGIC ? pdata_ptr : NULL;
}
-#ifdef CONFIG_SOFTWARE_PANIC
-static void panic_init(void)
-{
- /* Log panic cause if watchdog caused reset */
- if (system_get_reset_flags() & RESET_FLAG_WATCHDOG)
- panic_log_watchdog();
-}
-DECLARE_HOOK(HOOK_INIT, panic_init, HOOK_PRIO_DEFAULT);
-#endif
-
#ifdef CONFIG_CMD_STACKOVERFLOW
static void stack_overflow_recurse(int n)
{
diff --git a/common/system.c b/common/system.c
index 39ccc29165..b257bc8594 100644
--- a/common/system.c
+++ b/common/system.c
@@ -575,6 +575,16 @@ void system_common_pre_init(void)
{
uintptr_t addr;
+#ifdef CONFIG_SOFTWARE_PANIC
+ /*
+ * Log panic cause if watchdog caused reset. This
+ * must happen before calculating jump_data address
+ * because it might change panic pointer.
+ */
+ if (system_get_reset_flags() & RESET_FLAG_WATCHDOG)
+ panic_log_watchdog();
+#endif
+
/*
* Put the jump data before the panic data, or at the end of RAM if
* panic data is not present.