diff options
author | Simon Glass <sjg@chromium.org> | 2012-06-03 10:09:55 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-06-15 18:25:34 -0700 |
commit | 8c55761613bd5f0b2bcac6c769256842218d96c1 (patch) | |
tree | 95ee4016c3b74bbd8a0b47f8bbf4ce3657c998ae | |
parent | 8db2c7f910661661b3dfb67fb2eb99a16ee14de5 (diff) | |
download | chrome-ec-8c55761613bd5f0b2bcac6c769256842218d96c1.tar.gz |
Add an option to report panics in a new stack
For particularly nasty errors the stack or stack pointer may be corrupt,
or in a place that we do not want overwritten. Provide and option to
place the stack in a fresh place, assuming you can reach exception_panic().
Note that exception_panic() does not write anything to stack itself.
BUG=chrome-os-partner:10146
TEST=manual:
build for all boards
On snow, cause a panic and see that it is reported correctly.
Change-Id: I21d8b9bb12455758309d54ef20de66640d8a2df6
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24504
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | core/cortex-m/panic.c | 9 |
2 files changed, 15 insertions, 1 deletions
@@ -25,7 +25,6 @@ by Google. See below diagram for architecture. +--------------------+ - Build Options ============= @@ -34,3 +33,9 @@ Build Options Try to detect a watchdog that is about to fire, and print a trace. This is needed on STM32, where the independent watchdog has no early warning feature and the windowed watchdog has a very short period. + +- CONFIG_PANIC_NEW_STACK + + When reporting a panic, change to a completely new stack. This might + help get a useful trace out a situation where the stack or stack + pointer has been corrupted. diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c index cbdef6a96f..8e022857ef 100644 --- a/core/cortex-m/panic.c +++ b/core/cortex-m/panic.c @@ -16,9 +16,15 @@ #include "watchdog.h" +/* This is the size of our private panic stack, if we have one */ +#define STACK_SIZE_WORDS 64 + /* We save registers here for display by report_panic() */ static struct save_area { +#ifdef CONFIG_PANIC_NEW_STACK + uint32_t stack[STACK_SIZE_WORDS]; +#endif uint32_t saved_regs[11]; /* psp, ipsr, lr, r4-r11 */ } save_area __attribute__((aligned(8))); @@ -207,6 +213,9 @@ void exception_panic(void) "mrs r2, ipsr\n" "mov r3, lr\n" "stmia r0, {r1-r11}\n" +#ifdef CONFIG_PANIC_NEW_STACK + "mov sp, r0\n" +#endif "mov r1, r0\n" "mov r0, #0\n" "b report_panic" : : |