Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/52861 )
Change subject: x86/exception: Print the offset within the stage that caused the fault ......................................................................
x86/exception: Print the offset within the stage that caused the fault
To ease debugging print the offset if it's within the current stage. This is more convenient than searching the log for the rmodule loading address and subtracting it manually from the IP.
Change-Id: I0c44e4ee773ccf4bdd25b551949e02d754681417 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/arch/x86/exception.c 1 file changed, 19 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/52861/1
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index f10c7bf..e9a0da2 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -372,9 +372,17 @@ #endif /* CONFIG_GDB_STUB */
#include <arch/registers.h> +#include <symbols.h>
void x86_exception(struct eregs *info);
+static void program_offset(uintptr_t IP) +{ + if ((uintptr_t)_program <= IP && (uintptr_t)_eprogram > IP ) + printk(BIOS_EMERG, + "Faulty instruction is in " ENV_STRING " at offset 0x%zx\n", IP - (uintptr_t)_program); +} + void x86_exception(struct eregs *info) { #if CONFIG(GDB_STUB) @@ -496,6 +504,10 @@ printk(BIOS_EMERG, "CPU Index %d - APIC %d Unexpected Exception:\n" "%lld @ %02llx:%016llx - Halting\n" + logical_processor, (unsigned int)lapicid(), + info->vector, info->cs, info->rip); + program_offset(info->rip); + printk(BIOS_EMERG, "Code: %lld rflags: %016llx cr2: %016llx\n" "rax: %016llx rbx: %016llx\n" "rcx: %016llx rdx: %016llx\n" @@ -505,8 +517,6 @@ "r10: %016llx r11: %016llx\n" "r12: %016llx r13: %016llx\n" "r14: %016llx r15: %016llx\n", - logical_processor, (unsigned int)lapicid(), - info->vector, info->cs, info->rip, info->error_code, info->rflags, read_cr2(), info->rax, info->rbx, info->rcx, info->rdx, info->rdi, info->rsi, info->rbp, info->rsp, @@ -518,12 +528,16 @@
printk(BIOS_EMERG, "CPU Index %d - APIC %d Unexpected Exception:" - "%d @ %02x:%08x - Halting\n" + "%d @ %02x:%08x - Halting\n", + logical_processor, (unsigned int)lapicid(), + info->vector, info->cs, info->eip); + + program_offset(info->eip); + + printk(BIOS_EMERG, "Code: %d eflags: %08x cr2: %08x\n" "eax: %08x ebx: %08x ecx: %08x edx: %08x\n" "edi: %08x esi: %08x ebp: %08x esp: %08x\n", - logical_processor, (unsigned int)lapicid(), - info->vector, info->cs, info->eip, info->error_code, info->eflags, read_cr2(), info->eax, info->ebx, info->ecx, info->edx, info->edi, info->esi, info->ebp, info->esp);