From 37f581eb6afecc0acb143987e34dec1f719db06f Mon Sep 17 00:00:00 2001 From: KAAAsS Date: Sat, 15 May 2021 00:15:51 +0800 Subject: [PATCH] finish exec3.3 --- lab3/.gdbinit | 2 +- lab3/kernel/exception/exception.c | 5 +++++ lab3/kernel/exception/exception_table.S | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lab3/.gdbinit b/lab3/.gdbinit index 598decb..3070b32 100644 --- a/lab3/.gdbinit +++ b/lab3/.gdbinit @@ -13,4 +13,4 @@ define add-symbol-file-auto end add-symbol-file-auto ./build/kernel.img -add-symbol-file-auto ./user/build/ramdisk/hello.bin +add-symbol-file-auto ./user/build/ramdisk/badinsn.bin diff --git a/lab3/kernel/exception/exception.c b/lab3/kernel/exception/exception.c index 163f65c..8a141f9 100644 --- a/lab3/kernel/exception/exception.c +++ b/lab3/kernel/exception/exception.c @@ -25,6 +25,7 @@ void exception_init_per_cpu(void) * Lab3: Your code here * Setup the exception vector with the asm function written in exception.S */ + set_exception_vector(); disable_irq(); } @@ -48,6 +49,10 @@ void handle_entry_c(int type, u64 esr, u64 address) * Handle exceptions as required in the lab document. Checking exception codes in * esr.h may help. */ + case ESR_EL1_EC_UNKNOWN: + // Unknown instruction + kinfo("%s", UNKNOWN); + sys_exit(-ESUPPORT); default: kdebug("Unsupported Exception ESR %lx\n", esr); break; diff --git a/lab3/kernel/exception/exception_table.S b/lab3/kernel/exception/exception_table.S index cb172f9..5431cf8 100644 --- a/lab3/kernel/exception/exception_table.S +++ b/lab3/kernel/exception/exception_table.S @@ -120,6 +120,30 @@ .align 11 EXPORT(el1_vector) + // ELx SP_EL0 + exception_entry sync_el1t + exception_entry irq_el1t + exception_entry fiq_el1t + exception_entry error_el1t + + // ELx SP_ELx + exception_entry sync_el1h + exception_entry irq_el1h + exception_entry fiq_el1h + exception_entry error_el1h + + // EL0 AArch64 + exception_entry sync_el0_64 + exception_entry irq_el0_64 + exception_entry fiq_el0_64 + exception_entry error_el0_64 + + // EL0 AArch32 + exception_entry sync_el0_32 + exception_entry irq_el0_32 + exception_entry fiq_el0_32 + exception_entry error_el0_32 + sync_el1t: handle_entry 1, SYNC_EL1t