aarch64: vectors: Manage unhandled exceptions

So we can more clearly see when things go wrong.
This commit is contained in:
Robin Randhawa
2021-01-17 09:55:10 +00:00
parent 17fd135017
commit 208fb681f4
3 changed files with 123 additions and 41 deletions

View File

@@ -10,92 +10,92 @@ exception_vector_base:
.align 7
__vec_00:
mov x18, #0xb0b0
wfi
b __vec_00
b do_exception_synchronous
b __vec_00
.align 7
__vec_01:
mov x18, #0xb0b1
wfi
b __vec_01
b do_exception_irq
b __vec_01
.align 7
__vec_02:
mov x18, #0xb0b2
wfi
b __vec_02
b do_exception_unhandled
b __vec_02
.align 7
__vec_03:
mov x18, #0xb0b3
wfi
b __vec_03
b do_exception_unhandled
b __vec_03
.align 7
__vec_04:
b do_report_exception
wfi
b __vec_04
mov x18, #0xb0b4
b do_exception_synchronous
b __vec_04
.align 7
__vec_05:
b do_irq // First level interrupt handler
wfi
b __vec_05
mov x18, #0xb0b5
b do_exception_irq
b __vec_05
.align 7
__vec_06:
mov x18, #0xb0b6
wfi
b __vec_06
b do_exception_unhandled
b __vec_06
.align 7
__vec_07:
mov x18, #0xb0b7
wfi
b __vec_07
b do_exception_unhandled
b __vec_07
.align 7
__vec_08:
b do_syscall // Syscall handler
wfi
b __vec_08
mov x18, #0xb0b8
b do_exception_synchronous
b __vec_08
.align 7
__vec_09:
b do_irq // First level interrupt handler
wfi
b __vec_09
mov x18, #0xb0b9
b do_exception_irq
b __vec_09
.align 7
__vec_10:
mov x18, #0xb0bb
wfi
b __vec_10
mov x18, #0xb0ba
b do_exception_unhandled
b __vec_10
.align 7
__vec_11:
mov x18, #0xb0bc
wfi
b __vec_11
mov x18, #0xb0bb
b do_exception_unhandled
b __vec_11
.align 7
__vec_12:
mov x18, #0xb0bd
wfi
b __vec_12
mov x18, #0xb0bc
b do_exception_unhandled
b __vec_12
.align 7
__vec_13:
mov x18, #0xb0be
wfi
b __vec_13
mov x18, #0xb0bd
b do_exception_unhandled
b __vec_13
.align 7
__vec_14:
mov x18, #0xb0bf
wfi
b __vec_14
mov x18, #0xb0be
b do_exception_unhandled
b __vec_14
.align 7
exception_vector_end:

View File

@@ -12,7 +12,7 @@ pub static PIT_TICKS: AtomicUsize = ATOMIC_USIZE_INIT;
#[naked]
#[no_mangle]
pub unsafe extern fn do_irq() {
pub unsafe extern fn do_exception_irq() {
#[inline(never)]
unsafe fn inner() {
irq_demux();

View File

@@ -3,9 +3,91 @@ use crate::syscall;
#[naked]
#[no_mangle]
pub unsafe extern fn do_syscall() {
pub unsafe extern fn do_exception_unhandled() {
#[inline(never)]
unsafe fn inner(stack: &mut InterruptStack) -> usize {
println!("do_exception_unhandled: ELR: 0x{:016x}", stack.elr_el1);
loop {}
}
llvm_asm!("str x0, [sp, #-8]!
str x1, [sp, #-8]!
str x2, [sp, #-8]!
str x3, [sp, #-8]!
str x4, [sp, #-8]!
str x5, [sp, #-8]!
str x6, [sp, #-8]!
str x7, [sp, #-8]!
str x8, [sp, #-8]!
str x9, [sp, #-8]!
str x10, [sp, #-8]!
str x11, [sp, #-8]!
str x12, [sp, #-8]!
str x13, [sp, #-8]!
str x14, [sp, #-8]!
str x15, [sp, #-8]!
str x16, [sp, #-8]!
str x17, [sp, #-8]!
str x18, [sp, #-8]!
str x19, [sp, #-8]!
str x20, [sp, #-8]!
str x21, [sp, #-8]!
str x22, [sp, #-8]!
str x23, [sp, #-8]!
str x24, [sp, #-8]!
str x25, [sp, #-8]!
str x26, [sp, #-8]!
str x27, [sp, #-8]!
str x28, [sp, #-8]!
str x29, [sp, #-8]!
str x30, [sp, #-8]!
mrs x18, sp_el0
str x18, [sp, #-8]!
mrs x18, esr_el1
str x18, [sp, #-8]!
mrs x18, spsr_el1
str x18, [sp, #-8]!
mrs x18, tpidrro_el0
str x18, [sp, #-8]!
mrs x18, tpidr_el0
str x18, [sp, #-8]!
str x18, [sp, #-8]!
mrs x18, elr_el1
str x18, [sp, #-8]!"
: : : : "volatile");
let sp: usize;
llvm_asm!("" : "={sp}"(sp) : : : "volatile");
llvm_asm!("mov x29, sp" : : : : "volatile");
let a = inner(&mut *(sp as *mut InterruptStack));
}
#[naked]
#[no_mangle]
pub unsafe extern fn do_exception_synchronous() {
#[inline(never)]
unsafe fn inner(stack: &mut InterruptStack) -> usize {
let exception_code = (stack.esr_el1 & (0x3f << 26)) >> 26;
if exception_code != 0b010101 {
println!("do_exception_synchronous: Non-SVC!!!");
loop {}
} else {
println!("do_exception_synchronous: SVC: x8: 0x{:016x}", stack.scratch.x8);
}
llvm_asm!("nop": : : : "volatile");
llvm_asm!("nop": : : : "volatile");
llvm_asm!("nop": : : : "volatile");
llvm_asm!("nop": : : : "volatile");
let fp;
llvm_asm!("" : "={fp}"(fp) : : : "volatile");