From 71601aaaaf592225cb0834ce2b287c2fede02f16 Mon Sep 17 00:00:00 2001 From: Denis Brockus Date: Thu, 20 Jun 2019 13:57:14 -0600 Subject: minute-ia: add 0 error code for exceptions that do not pass one The errorcode is pushed to the stack by hardware for vectors 8, 10-14 and 17. The others will be missing that parameter when exception_panic is called. So make sure to push a 0 for these other exceptions to line up parameter values. BUG=b:135671664 BRANCH=none TEST=make buildall -j TEST=verify errorcode 0 on exceptions that hw does not push a value Change-Id: I7aad96278408a5e38cf973c868e05d92b52469dd Signed-off-by: Denis Brockus Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1669884 Reviewed-by: Jack Rosenthal Commit-Queue: Jack Rosenthal --- core/minute-ia/interrupts.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/core/minute-ia/interrupts.c b/core/minute-ia/interrupts.c index 1d87dba77a..07c4c71ef0 100644 --- a/core/minute-ia/interrupts.c +++ b/core/minute-ia/interrupts.c @@ -169,23 +169,34 @@ static const irq_desc_t system_irqs[] = { * of which will push their corresponding interrupt vector number to * the stack, and then call exception_panic. The remaining arguments to * exception_panic were pushed by the hardware when the exception was - * called. + * called. The errorcode is pushed to the stack by hardware for vectors + * 8, 10-14 and 17. Make sure to push 0 for the other vectors * * This is done since interrupt vectors 0-31 bypass the APIC ISR register * and go directly to the CPU core, so get_current_interrupt_vector * cannot be used. */ -#define DEFINE_EXN_HANDLER(vector) \ +#define DEFINE_EXN_HANDLER(vector) \ _DEFINE_EXN_HANDLER(vector, exception_panic_##vector) #define _DEFINE_EXN_HANDLER(vector, name) \ - void __keep name(void); \ + void __keep name(void); \ __attribute__((noreturn)) void name(void) \ { \ - __asm__ ( \ - "push $" #vector "\n" \ - "call exception_panic\n"); \ - while (1) \ - continue; \ + __asm__ ("push $0\n" \ + "push $" #vector "\n" \ + "call exception_panic\n"); \ + __builtin_unreachable(); \ + } + +#define DEFINE_EXN_HANDLER_W_ERRORCODE(vector) \ + _DEFINE_EXN_HANDLER_W_ERRORCODE(vector, exception_panic_##vector) +#define _DEFINE_EXN_HANDLER_W_ERRORCODE(vector, name) \ + void __keep name(void); \ + __attribute__((noreturn)) void name(void) \ + { \ + __asm__ ("push $" #vector "\n" \ + "call exception_panic\n"); \ + __builtin_unreachable(); \ } DEFINE_EXN_HANDLER(0); @@ -196,15 +207,15 @@ DEFINE_EXN_HANDLER(4); DEFINE_EXN_HANDLER(5); DEFINE_EXN_HANDLER(6); DEFINE_EXN_HANDLER(7); -DEFINE_EXN_HANDLER(8); +DEFINE_EXN_HANDLER_W_ERRORCODE(8); DEFINE_EXN_HANDLER(9); -DEFINE_EXN_HANDLER(10); -DEFINE_EXN_HANDLER(11); -DEFINE_EXN_HANDLER(12); -DEFINE_EXN_HANDLER(13); -DEFINE_EXN_HANDLER(14); +DEFINE_EXN_HANDLER_W_ERRORCODE(10); +DEFINE_EXN_HANDLER_W_ERRORCODE(11); +DEFINE_EXN_HANDLER_W_ERRORCODE(12); +DEFINE_EXN_HANDLER_W_ERRORCODE(13); +DEFINE_EXN_HANDLER_W_ERRORCODE(14); DEFINE_EXN_HANDLER(16); -DEFINE_EXN_HANDLER(17); +DEFINE_EXN_HANDLER_W_ERRORCODE(17); DEFINE_EXN_HANDLER(18); DEFINE_EXN_HANDLER(19); DEFINE_EXN_HANDLER(20); -- cgit v1.2.1