From 91268fb85e1a09ffc3d64ea139bc7d09305c0396 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Thu, 19 Feb 2015 09:07:24 -0800 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/251110 Reviewed-by: Shawn N Reviewed-by: Randall Spangler --- common/system.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'common/system.c') 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. -- cgit v1.2.1