summaryrefslogtreecommitdiff
path: root/payloads/libpayload/arch
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2014-08-27 21:43:36 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-03-21 13:35:38 +0100
commit3b1ee0387c70f0b31307f50a5efa5a2b584a3635 (patch)
tree4f5072c847d94279afdbd35c450e0076736cf4e7 /payloads/libpayload/arch
parent02efc9413b076d869da86017eff188741d114991 (diff)
downloadcoreboot-3b1ee0387c70f0b31307f50a5efa5a2b584a3635.tar.xz
libpayload arm64: Make exceptions work
BUG=chrome-os-partner:31634 BRANCH=None TEST=test_exc generates and handles exceptions properly Change-Id: If3ecab93be6d02942b52960ec97edc687bedf64b Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: bba2caae0bd436ba9e5215f5d8606ce8c4987c98 Original-Change-Id: I4abe8a0e426eab2532852179dbb32505353cd0a1 Original-Signed-off-by: Furquan Shaikh <furquan@google.com> Original-Reviewed-on: https://chromium-review.googlesource.com/214609 Original-Tested-by: Furquan Shaikh <furquan@chromium.org> Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org> Reviewed-on: http://review.coreboot.org/8783 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'payloads/libpayload/arch')
-rw-r--r--payloads/libpayload/arch/arm64/exception.c35
-rw-r--r--payloads/libpayload/arch/arm64/exception_asm.S61
-rw-r--r--payloads/libpayload/arch/arm64/gdb.c21
-rw-r--r--payloads/libpayload/arch/arm64/main.c12
4 files changed, 73 insertions, 56 deletions
diff --git a/payloads/libpayload/arch/arm64/exception.c b/payloads/libpayload/arch/arm64/exception.c
index 226f5ca27d..2330a98456 100644
--- a/payloads/libpayload/arch/arm64/exception.c
+++ b/payloads/libpayload/arch/arm64/exception.c
@@ -40,22 +40,34 @@ struct exception_handler_info
static exception_hook hook;
struct exception_state *exception_state;
+
static struct exception_handler_info exceptions[EXC_COUNT] = {
- [EXC_INV] = { "_invalid_exception" },
- [EXC_SYNC] = { "_sync" },
- [EXC_IRQ] = { "_irq" },
- [EXC_FIQ] = { "_fiq" },
- [EXC_SERROR] = {"_serror"}
+ [EXC_SYNC_SP0] = { "_sync_sp_el0" },
+ [EXC_IRQ_SP0] = { "_irq_sp_el0" },
+ [EXC_FIQ_SP0] = { "_fiq_sp_el0" },
+ [EXC_SERROR_SP0] = {"_serror_sp_el0"},
+ [EXC_SYNC_SPX] = { "_sync_spx" },
+ [EXC_IRQ_SPX] = { "_irq_spx" },
+ [EXC_FIQ_SPX] = { "_fiq_spx" },
+ [EXC_SERROR_SPX] = {"_serror_spx"},
+ [EXC_SYNC_ELX_64] = { "_sync_elx_64" },
+ [EXC_IRQ_ELX_64] = { "_irq_elx_64" },
+ [EXC_FIQ_ELX_64] = { "_fiq_elx_64" },
+ [EXC_SERROR_ELX_64] = {"_serror_elx_64"},
+ [EXC_SYNC_ELX_32] = { "_sync_elx_32" },
+ [EXC_IRQ_ELX_32] = { "_irq_elx_32" },
+ [EXC_FIQ_ELX_32] = { "_fiq_elx_32" },
+ [EXC_SERROR_ELX_32] = {"_serror_elx_32"},
};
static void print_regs(struct exception_state *state)
{
int i;
- printf("ELR = 0x%016llx ",state->elr);
- printf("ESR = 0x%08llx ",state->esr);
+ printf("ELR = 0x%016llx\n",state->elr);
+ printf("ESR = 0x%08llx\n",state->esr);
for (i = 0; i < 31; i++) {
- printf("X%02d = 0x%016llx ", i, state->regs[i]);
+ printf("X%02d = 0x%016llx\n", i, state->regs[i]);
}
}
@@ -78,8 +90,11 @@ void exception_dispatch(struct exception_state *state, int idx)
}
print_regs(state);
- if (test_exc)
+ if (test_exc) {
+ state->elr += 4;
test_exc = 0;
+ printf("returning back now\n");
+ }
else
halt();
}
@@ -87,7 +102,7 @@ void exception_dispatch(struct exception_state *state, int idx)
void exception_init(void)
{
extern void* exception_table;
- set_vbar(exception_table);
+ set_vbar(&exception_table);
}
void exception_install_hook(exception_hook h)
diff --git a/payloads/libpayload/arch/arm64/exception_asm.S b/payloads/libpayload/arch/arm64/exception_asm.S
index c68ba5a7c6..8e69ddad86 100644
--- a/payloads/libpayload/arch/arm64/exception_asm.S
+++ b/payloads/libpayload/arch/arm64/exception_asm.S
@@ -35,11 +35,13 @@
* Move exception id into x1
* Branch to exception_handler
*/
-.macro eentry id
- stp x30, xzr, [sp, #-16]!
- bl exception_prologue
- mov x1, \id
- bl exception_handler
+.macro eentry lbl id
+ .align 7
+\lbl:
+ stp x30, xzr, [sp, #-16]!
+ bl exception_prologue
+ mov x1, \id
+ bl exception_handler
.endm
/* Exception table has 16 entries and each of 128 bytes
@@ -51,37 +53,22 @@
.global exception_table
exception_table:
- .align 7
-sync_el0:
- eentry #0
-
- .align 7
-irq_el0:
- eentry #0
-
- .align 7
-fiq_el0:
- eentry #0
-
- .align 7
-serror_el0:
- eentry #0
-
- .align 7
-sync_elx:
- eentry #1
-
- .align 7
-irq_elx:
- eentry #2
-
- .align 7
-fiq_elx:
- eentry #3
-
- .align 7
-serror_elx:
- eentry #4
+eentry sync_sp0,#0
+eentry irq_sp0,#1
+eentry fiq_sp0,#2
+eentry serror_sp0,#3
+eentry sync_spx,#4
+eentry irq_spx,#5
+eentry fiq_spx,#6
+eentry serror_spx,#7
+eentry sync_elx_64,#8
+eentry irq_elx_64,#9
+eentry fiq_elx_64,#10
+eentry serror_elx_64,#11
+eentry sync_elx_32,#12
+eentry irq_elx_32,#13
+eentry fiq_elx_32,#14
+eentry serror_elx_32,#15
exception_prologue:
/* Save all registers x0-x29 */
@@ -119,6 +106,8 @@ exception_handler:
/* Pop return address saved on stack */
ldp x0, x1, [sp], #16
+ msr elr_el3, x0
+ msr esr_el3, x1
/* Pop exception reason saved on stack, followed by regs x0-x30 */
ldp x0, x1, [sp], #16
ldp x2, x3, [sp], #16
diff --git a/payloads/libpayload/arch/arm64/gdb.c b/payloads/libpayload/arch/arm64/gdb.c
index 857272f095..c976483f04 100644
--- a/payloads/libpayload/arch/arm64/gdb.c
+++ b/payloads/libpayload/arch/arm64/gdb.c
@@ -33,11 +33,22 @@ struct gdb_regs
} __attribute__((packed));
static const u8 type_to_signal[] = {
- [EXC_INV] = GDB_SIGILL,
- [EXC_SYNC] = GDB_SIGTRAP,
- [EXC_IRQ] = GDB_SIGSEGV,
- [EXC_FIQ] = GDB_SIGSEGV,
- [EXC_SERROR] = GDB_SIGSEGV
+ [EXC_SYNC_SP0] = GDB_SIGTRAP,
+ [EXC_IRQ_SP0] = GDB_SIGSEGV,
+ [EXC_FIQ_SP0] = GDB_SIGSEGV,
+ [EXC_SERROR_SP0] = GDB_SIGSEGV,
+ [EXC_SYNC_SPX] = GDB_SIGTRAP,
+ [EXC_IRQ_SPX] = GDB_SIGSEGV,
+ [EXC_FIQ_SPX] = GDB_SIGSEGV,
+ [EXC_SERROR_SPX] = GDB_SIGSEGV,
+ [EXC_SYNC_ELX_64] = GDB_SIGTRAP,
+ [EXC_IRQ_ELX_64] = GDB_SIGSEGV,
+ [EXC_FIQ_ELX_64] = GDB_SIGSEGV,
+ [EXC_SERROR_ELX_64] = GDB_SIGSEGV,
+ [EXC_SYNC_ELX_32] = GDB_SIGTRAP,
+ [EXC_IRQ_ELX_32] = GDB_SIGSEGV,
+ [EXC_FIQ_ELX_32] = GDB_SIGSEGV,
+ [EXC_SERROR_ELX_32] = GDB_SIGSEGV
};
static int gdb_exception_hook(u32 type)
diff --git a/payloads/libpayload/arch/arm64/main.c b/payloads/libpayload/arch/arm64/main.c
index 864e3cafd1..6b45a018c2 100644
--- a/payloads/libpayload/arch/arm64/main.c
+++ b/payloads/libpayload/arch/arm64/main.c
@@ -37,13 +37,15 @@ char *main_argv[MAX_ARGC_COUNT];
unsigned int test_exc;
-int test_exception(void);
-int test_exception(void)
+static int test_exception(void)
{
- int a = 1;
- int b = 0;
+ uint64_t *a = (uint64_t *)0xfffffffff0000000ULL;
+
test_exc = 1;
- return a/b;
+
+ printf("%llx\n", *a);
+
+ return 0;
}
/**