2013-12-07 13:25:01 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the libpayload project.
|
|
|
|
*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2013-12-11 09:23:15 +01:00
|
|
|
#include <arch/exception.h>
|
2013-12-07 13:25:01 +01:00
|
|
|
#include <exception.h>
|
|
|
|
#include <libpayload.h>
|
|
|
|
#include <stdint.h>
|
2018-08-20 19:14:44 +02:00
|
|
|
#include <arch/apic.h>
|
2013-12-07 13:25:01 +01:00
|
|
|
|
2018-08-22 18:03:05 +02:00
|
|
|
#define IF_FLAG (1 << 9)
|
|
|
|
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
u32 exception_stack[0x400] __attribute__((aligned(8)));
|
|
|
|
|
2018-08-22 18:03:05 +02:00
|
|
|
static interrupt_handler handlers[256];
|
|
|
|
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
static const char *names[EXC_COUNT] = {
|
|
|
|
[EXC_DE] = "Divide by Zero",
|
|
|
|
[EXC_DB] = "Debug",
|
|
|
|
[EXC_NMI] = "Non-Maskable-Interrupt",
|
|
|
|
[EXC_BP] = "Breakpoint",
|
|
|
|
[EXC_OF] = "Overflow",
|
|
|
|
[EXC_BR] = "Bound Range",
|
|
|
|
[EXC_UD] = "Invalid Opcode",
|
|
|
|
[EXC_NM] = "Device Not Available",
|
|
|
|
[EXC_DF] = "Double Fault",
|
|
|
|
[EXC_TS] = "Invalid TSS",
|
|
|
|
[EXC_NP] = "Segment Not Present",
|
|
|
|
[EXC_SS] = "Stack Fault",
|
|
|
|
[EXC_GP] = "General Protection Fault",
|
|
|
|
[EXC_PF] = "Page Fault",
|
|
|
|
[EXC_MF] = "x87 Floating Point",
|
|
|
|
[EXC_AC] = "Alignment Check",
|
|
|
|
[EXC_MC] = "Machine Check",
|
|
|
|
[EXC_XF] = "SIMD Floating Point",
|
|
|
|
[EXC_SX] = "Security",
|
2013-12-07 13:25:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void print_segment_error_code(u32 code)
|
|
|
|
{
|
2018-08-02 23:12:34 +02:00
|
|
|
printf("%#x - descriptor %#x in the ", code, (code >> 3) & 0x1FFF);
|
2013-12-07 13:25:01 +01:00
|
|
|
if (code & (0x1 << 1)) {
|
|
|
|
printf("IDT");
|
|
|
|
} else {
|
|
|
|
if (code & 0x04)
|
|
|
|
printf("LDT");
|
|
|
|
else
|
|
|
|
printf("GDT");
|
|
|
|
}
|
|
|
|
if (code & (0x1 << 0))
|
|
|
|
printf(", external to the CPU");
|
|
|
|
else
|
|
|
|
printf(", internal to the CPU");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_page_fault_error_code(u32 code)
|
|
|
|
{
|
|
|
|
printf("%#x -", code);
|
|
|
|
if (code & (0x1 << 0))
|
|
|
|
printf(" page protection");
|
|
|
|
else
|
|
|
|
printf(" page not present");
|
|
|
|
if (code & (0x1 << 1))
|
|
|
|
printf(", write");
|
|
|
|
else
|
|
|
|
printf(", read");
|
|
|
|
if (code & (0x1 << 2))
|
|
|
|
printf(", user");
|
|
|
|
else
|
|
|
|
printf(", supervisor");
|
|
|
|
if (code & (0x1 << 3))
|
|
|
|
printf(", reserved bits set");
|
|
|
|
if (code & (0x1 << 4))
|
|
|
|
printf(", instruction fetch");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_raw_error_code(u32 code)
|
|
|
|
{
|
|
|
|
printf("%#x", code);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_stack(uintptr_t addr, size_t bytes)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
const int line = 8;
|
|
|
|
uint32_t *ptr = (uint32_t *)(addr & ~(line * sizeof(*ptr) - 1));
|
|
|
|
|
|
|
|
printf("Dumping stack:\n");
|
|
|
|
for (i = bytes / sizeof(*ptr); i >= 0; i -= line) {
|
|
|
|
printf("%p: ", ptr + i);
|
|
|
|
for (j = i; j < i + line; j++)
|
|
|
|
printf("%08x ", *(ptr + j));
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
static void dump_exception_state(void)
|
2013-12-07 13:25:01 +01:00
|
|
|
{
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
printf("%s Exception\n", names[exception_state->vector]);
|
|
|
|
|
|
|
|
printf("Error code: ");
|
|
|
|
switch (exception_state->vector) {
|
|
|
|
case EXC_PF:
|
|
|
|
print_page_fault_error_code(exception_state->error_code);
|
|
|
|
break;
|
|
|
|
case EXC_TS:
|
|
|
|
case EXC_NP:
|
|
|
|
case EXC_SS:
|
|
|
|
case EXC_GP:
|
|
|
|
print_segment_error_code(exception_state->error_code);
|
|
|
|
break;
|
|
|
|
case EXC_DF:
|
|
|
|
case EXC_AC:
|
|
|
|
case EXC_SX:
|
|
|
|
print_raw_error_code(exception_state->error_code);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("n/a");
|
|
|
|
break;
|
2013-12-07 13:25:01 +01:00
|
|
|
}
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
printf("\n");
|
|
|
|
printf("EIP: 0x%08x\n", exception_state->regs.eip);
|
|
|
|
printf("CS: 0x%04x\n", exception_state->regs.cs);
|
|
|
|
printf("EFLAGS: 0x%08x\n", exception_state->regs.eflags);
|
|
|
|
printf("EAX: 0x%08x\n", exception_state->regs.eax);
|
|
|
|
printf("ECX: 0x%08x\n", exception_state->regs.ecx);
|
|
|
|
printf("EDX: 0x%08x\n", exception_state->regs.edx);
|
|
|
|
printf("EBX: 0x%08x\n", exception_state->regs.ebx);
|
|
|
|
printf("ESP: 0x%08x\n", exception_state->regs.esp);
|
|
|
|
printf("EBP: 0x%08x\n", exception_state->regs.ebp);
|
|
|
|
printf("ESI: 0x%08x\n", exception_state->regs.esi);
|
|
|
|
printf("EDI: 0x%08x\n", exception_state->regs.edi);
|
|
|
|
printf("DS: 0x%04x\n", exception_state->regs.ds);
|
|
|
|
printf("ES: 0x%04x\n", exception_state->regs.es);
|
|
|
|
printf("SS: 0x%04x\n", exception_state->regs.ss);
|
|
|
|
printf("FS: 0x%04x\n", exception_state->regs.fs);
|
|
|
|
printf("GS: 0x%04x\n", exception_state->regs.gs);
|
2013-12-11 09:23:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void exception_dispatch(void)
|
|
|
|
{
|
2018-10-01 22:34:31 +02:00
|
|
|
die_if(exception_state->vector >= ARRAY_SIZE(handlers),
|
|
|
|
"Invalid vector %u\n", exception_state->vector);
|
2018-08-22 18:03:05 +02:00
|
|
|
|
2018-10-01 22:34:31 +02:00
|
|
|
u8 vec = exception_state->vector;
|
2018-08-22 18:03:05 +02:00
|
|
|
|
|
|
|
if (handlers[vec]) {
|
|
|
|
handlers[vec](vec);
|
2018-10-02 17:45:06 +02:00
|
|
|
goto success;
|
|
|
|
} else if (vec >= EXC_COUNT
|
2019-03-06 01:55:15 +01:00
|
|
|
&& CONFIG(LP_IGNORE_UNKNOWN_INTERRUPTS)) {
|
2018-10-02 17:45:06 +02:00
|
|
|
goto success;
|
|
|
|
} else if (vec >= EXC_COUNT
|
2019-03-06 01:55:15 +01:00
|
|
|
&& CONFIG(LP_LOG_UNKNOWN_INTERRUPTS)) {
|
2018-10-02 17:45:06 +02:00
|
|
|
printf("Ignoring interrupt vector %u\n", vec);
|
|
|
|
goto success;
|
2018-08-22 18:03:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
die_if(vec >= EXC_COUNT || !names[vec], "Bad exception vector %u\n",
|
|
|
|
vec);
|
2013-12-11 09:23:15 +01:00
|
|
|
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
dump_exception_state();
|
|
|
|
dump_stack(exception_state->regs.esp, 512);
|
2018-10-02 17:45:06 +02:00
|
|
|
/* We don't call apic_eoi because we don't want to ack the interrupt and
|
|
|
|
allow another interrupt to wake the processor. */
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
halt();
|
2018-10-02 17:45:06 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
success:
|
2019-03-06 01:55:15 +01:00
|
|
|
if (CONFIG(LP_ENABLE_APIC))
|
2018-10-02 17:45:06 +02:00
|
|
|
apic_eoi(vec);
|
2013-12-07 13:25:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void exception_init(void)
|
|
|
|
{
|
libpayload: Rework exception hook interface
This patch makes some slight changes to the exception hook interface.
The old code provides a different handler hook for every exception
type... however, in practice all those hook functions often need to look
very similar, so this creates more boilerplate than it removes. The new
interface just allows for a single hook with the exception type passed
as an argument, and the consumer can signal whether the exception was
handled through the return value. (Right now this still only supports
one consumer, but it could easily be extended to walk through a list of
hooks if the need arises.)
Also move the excepton state from an argument to a global. This avoids a
lot of boilerplate since some consumers need to change the state from
many places, so they would have to pass the same pointer around many
times. It also removes the false suggestion that the exception state was
not global and you could have multiple copies of it (which the exception
core doesn't support for any architecture).
On the ARM side, the exception state is separated from the exception
stack for easier access. (This requires some assembly changes, and I
threw in a few comments and corrected the immediate sigils from '$' to
the official '#' while I'm there.) Since the exception state is now both
stored and loaded through an indirection pointer, this allows for some
very limited reentrance (you could point it to a different struct while
handling an exception, and while you still won't be able to return to
the outer-level exception from there, you could at least swap out the
pointer and return back to System Mode in one go).
BUG=chrome-os-partner:18390
TEST=Made sure normal exceptions still get dumped correctly on both
archs.
Original-Change-Id: I5d9a934fab7c14ccb2c9d7ee4b3465c825521fa2
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/202562
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
(cherry picked from commit 97542110f0b385b9b8d89675866e65db8ca32aeb)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
*** Squashed to prevent build failures. ***
libpayload: align arm64 with new exception handling model
The exception handling was previously updated, however the
arm64 changes raced with hat one. Make the arm64 align with
the new model. Without these changes compilation will fail.
BUG=None
BRANCH=None
TEST=Can build libpayload for rush.
Original-Change-Id: I320b39a57b985d1f87446ea7757955664f8dba8f
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/204402
Original-Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 0080df41b311ef20f9214b386fa4e38ee54aa1a1)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I9a0bb3848cf5286f9f4bb08172a9f4a15278348e
Reviewed-on: http://review.coreboot.org/8117
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2014-05-16 04:41:52 +02:00
|
|
|
exception_stack_end = exception_stack + ARRAY_SIZE(exception_stack);
|
2013-12-07 13:25:01 +01:00
|
|
|
exception_init_asm();
|
|
|
|
}
|
2013-12-11 09:23:15 +01:00
|
|
|
|
2018-08-22 18:03:05 +02:00
|
|
|
void set_interrupt_handler(u8 vector, interrupt_handler handler)
|
|
|
|
{
|
|
|
|
handlers[vector] = handler;
|
|
|
|
}
|
|
|
|
|
2018-08-22 18:03:05 +02:00
|
|
|
static uint32_t eflags(void)
|
|
|
|
{
|
|
|
|
uint32_t eflags;
|
|
|
|
asm volatile(
|
|
|
|
"pushf\n\t"
|
|
|
|
"pop %0\n\t"
|
|
|
|
: "=rm" (eflags));
|
|
|
|
return eflags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void enable_interrupts(void)
|
|
|
|
{
|
|
|
|
asm volatile (
|
|
|
|
"sti\n"
|
|
|
|
: : : "cc"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
void disable_interrupts(void)
|
|
|
|
{
|
|
|
|
asm volatile (
|
|
|
|
"cli\n"
|
|
|
|
: : : "cc"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
int interrupts_enabled(void)
|
|
|
|
{
|
|
|
|
return !!(eflags() & IF_FLAG);
|
|
|
|
}
|