aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arch/x86/exception.c5
-rw-r--r--src/include/cpu/x86/cr.h12
2 files changed, 15 insertions, 2 deletions
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c
index 5a5dfd2831..c89371ee7f 100644
--- a/src/arch/x86/exception.c
+++ b/src/arch/x86/exception.c
@@ -17,6 +17,7 @@
#include <compiler.h>
#include <console/console.h>
#include <console/streams.h>
+#include <cpu/x86/cr.h>
#include <rules.h>
#include <stdint.h>
#include <string.h>
@@ -503,11 +504,11 @@ void x86_exception(struct eregs *info)
#define MDUMP_SIZE 0x80
printk(BIOS_EMERG,
"Unexpected Exception: %d @ %02x:%08x - Halting\n"
- "Code: %d eflags: %08x\n"
+ "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",
info->vector, info->cs, info->eip,
- info->error_code, info->eflags,
+ info->error_code, info->eflags, read_cr2(),
info->eax, info->ebx, info->ecx, info->edx,
info->edi, info->esi, info->ebp, info->esp);
u8 *code = (u8 *)((uintptr_t)info->eip - (MDUMP_SIZE >> 1));
diff --git a/src/include/cpu/x86/cr.h b/src/include/cpu/x86/cr.h
index 9eb94022f5..5183c77f89 100644
--- a/src/include/cpu/x86/cr.h
+++ b/src/include/cpu/x86/cr.h
@@ -59,6 +59,18 @@ static alwaysinline void write_cr0(CRx_TYPE data)
);
}
+static alwaysinline CRx_TYPE read_cr2(void)
+{
+ CRx_TYPE value;
+ __asm__ __volatile__ (
+ "mov %%cr2, %0"
+ : CRx_RET(value)
+ :
+ : COMPILER_BARRIER
+ );
+ return value;
+}
+
static alwaysinline CRx_TYPE read_cr3(void)
{
CRx_TYPE value;