Kernel/aarch64: Make register dump output a bit nicer

This commit is contained in:
Timon Kruiper 2023-01-30 14:36:27 +01:00 committed by Linus Groh
parent a9f7267cbd
commit 3106a72a72

View file

@ -20,17 +20,29 @@ namespace Kernel {
static void dump_exception_syndrome_register(Aarch64::ESR_EL1 const& esr_el1)
{
dbgln("esr_el1: EC({:#b}) IL({:#b}) ISS({:#b}) ISS2({:#b})", esr_el1.EC, esr_el1.IL, esr_el1.ISS, esr_el1.ISS2);
dbgln("Exception Class: {}", Aarch64::exception_class_to_string(esr_el1.EC));
if (Aarch64::exception_class_has_set_far(esr_el1.EC))
dbgln("Faulting Virtual Address: 0x{:x}", Aarch64::FAR_EL1::read().virtual_address);
dbgln("Exception Syndrome: EC({:#b}) IL({:#b}) ISS({:#b}) ISS2({:#b})", esr_el1.EC, esr_el1.IL, esr_el1.ISS, esr_el1.ISS2);
dbgln(" Class: {}", Aarch64::exception_class_to_string(esr_el1.EC));
if (Aarch64::exception_class_is_data_abort(esr_el1.EC))
dbgln("Data Fault Status Code: {}", Aarch64::data_fault_status_code_to_string(esr_el1.ISS));
dbgln(" Data Fault Status Code: {}", Aarch64::data_fault_status_code_to_string(esr_el1.ISS));
if (Aarch64::exception_class_has_set_far(esr_el1.EC))
dbgln(" Faulting Virtual Address: 0x{:x}", Aarch64::FAR_EL1::read().virtual_address);
}
void dump_registers(RegisterState const& regs)
{
auto esr_el1 = Kernel::Aarch64::ESR_EL1::read();
dump_exception_syndrome_register(esr_el1);
// Special registers
Aarch64::SPSR_EL1 spsr_el1 = {};
memcpy(&spsr_el1, (u8 const*)&regs.spsr_el1, sizeof(u64));
dbgln("Saved Program Status: (NZCV({:#b}) DAIF({:#b}) M({:#b})) / 0x{:x}", ((regs.spsr_el1 >> 28) & 0b1111), ((regs.spsr_el1 >> 6) & 0b1111), regs.spsr_el1 & 0b1111, regs.spsr_el1);
dbgln("Exception Link Register: 0x{:x}", regs.elr_el1);
dbgln("Software Thread ID: 0x{:x}", regs.tpidr_el0);
dbgln("Stack Pointer (EL0): 0x{:x}", regs.sp_el0);
dbgln(" x0={:p} x1={:p} x2={:p} x3={:p} x4={:p}", regs.x[0], regs.x[1], regs.x[2], regs.x[3], regs.x[4]);
dbgln(" x5={:p} x6={:p} x7={:p} x8={:p} x9={:p}", regs.x[5], regs.x[6], regs.x[7], regs.x[8], regs.x[9]);
dbgln("x10={:p} x11={:p} x12={:p} x13={:p} x14={:p}", regs.x[10], regs.x[11], regs.x[12], regs.x[13], regs.x[14]);
@ -38,18 +50,6 @@ void dump_registers(RegisterState const& regs)
dbgln("x20={:p} x21={:p} x22={:p} x23={:p} x24={:p}", regs.x[20], regs.x[21], regs.x[22], regs.x[23], regs.x[24]);
dbgln("x25={:p} x26={:p} x27={:p} x28={:p} x29={:p}", regs.x[25], regs.x[26], regs.x[27], regs.x[28], regs.x[29]);
dbgln("x30={:p}", regs.x[30]);
// Special registers
Aarch64::SPSR_EL1 spsr_el1 = {};
memcpy(&spsr_el1, (u8 const*)&regs.spsr_el1, sizeof(u64));
dbgln("spsr_el1: 0x{:x} (NZCV({:#b}) DAIF({:#b}) M({:#b}))", regs.spsr_el1, ((regs.spsr_el1 >> 28) & 0b1111), ((regs.spsr_el1 >> 6) & 0b1111), regs.spsr_el1 & 0b1111);
dbgln("elr_el1: 0x{:x}", regs.elr_el1);
dbgln("tpidr_el0: 0x{:x}", regs.tpidr_el0);
dbgln("sp_el0: 0x{:x}", regs.sp_el0);
auto esr_el1 = Kernel::Aarch64::ESR_EL1::read();
dump_exception_syndrome_register(esr_el1);
}
static PageFault page_fault_from_exception_syndrome_register(VirtualAddress fault_address, Aarch64::ESR_EL1 esr_el1)