Improve aarch64 debugger.

This commit is contained in:
4lDO2
2023-07-28 13:23:44 +02:00
parent d16569110e
commit e28fef09e3
3 changed files with 46 additions and 31 deletions
+13 -11
View File
@@ -32,9 +32,10 @@ unsafe fn far_el1() -> usize {
ret
}
unsafe fn instr_data_abort_inner(stack: &mut InterruptStack, from_user: bool, instr_not_data: bool) -> bool {
unsafe fn instr_data_abort_inner(stack: &mut InterruptStack, from_user: bool, instr_not_data: bool, from: &str) -> bool {
let iss = iss(stack.iret.esr_el1);
let fsc = iss & 0x3F;
//dbg!(fsc);
let was_translation_fault = fsc >= 0b000100 && fsc <= 0b000111;
//let was_permission_fault = fsc >= 0b001101 && fsc <= 0b001111;
@@ -50,44 +51,45 @@ unsafe fn instr_data_abort_inner(stack: &mut InterruptStack, from_user: bool, in
flags.set(GenericPfFlags::USER_NOT_SUPERVISOR, from_user);
let faulting_addr = VirtualAddress::new(far_el1());
//dbg!(faulting_addr, flags, from);
crate::memory::page_fault_handler(stack, flags, faulting_addr).is_ok()
}
exception_stack!(synchronous_exception_at_el1_with_spx, |stack| {
if !pf_inner(stack, exception_code(stack.iret.esr_el1)) {
if !pf_inner(stack, exception_code(stack.iret.esr_el1), "sync_exc_el1_spx") {
println!("Synchronous exception at EL1 with SPx");
stack.dump();
stack_trace();
loop {}
}
});
unsafe fn pf_inner(stack: &mut InterruptStack, ty: u8) -> bool {
unsafe fn pf_inner(stack: &mut InterruptStack, ty: u8, from: &str) -> bool {
match ty {
// "Data Abort taken from a lower Exception level"
0b100100 => instr_data_abort_inner(stack, true, false),
0b100100 => instr_data_abort_inner(stack, true, false, from),
// "Data Abort taken without a change in Exception level"
0b100101 => instr_data_abort_inner(stack, false, false),
0b100101 => instr_data_abort_inner(stack, false, false, from),
// "Instruction Abort taken from a lower Exception level"
0b100000 => instr_data_abort_inner(stack, true, true),
0b100000 => instr_data_abort_inner(stack, true, true, from),
// "Instruction Abort taken without a change in Exception level"
0b100001 => instr_data_abort_inner(stack, false, true),
0b100001 => instr_data_abort_inner(stack, false, true, from),
_ => return false,
}
}
exception_stack!(synchronous_exception_at_el0, |stack| {
match stack.iret.esr_el1 {
match exception_code(stack.iret.esr_el1) {
0b010101 => with_exception_stack!(|stack| {
let scratch = &stack.scratch;
syscall::syscall(scratch.x8, scratch.x0, scratch.x1, scratch.x2, scratch.x3, scratch.x4, stack)
}),
ty => if !pf_inner(stack, ty as u8) {
println!("FATAL: Not an SVC induced synchronous exception");
ty => if !pf_inner(stack, ty as u8, "sync_exc_el0") {
log::error!("FATAL: Not an SVC induced synchronous exception (ty={:b})", ty);
println!("FAR_EL1: {:#0x}", far_el1());
crate::debugger::debugger(None);
//crate::debugger::debugger(None);
stack.dump();
stack_trace();
crate::ksignal(SIGSEGV);