]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
x86: print CR2 in case the hypervisor causes a pagefault
authorHenning Schild <henning.schild@siemens.com>
Wed, 27 Aug 2014 12:16:40 +0000 (14:16 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 28 Aug 2014 06:36:29 +0000 (08:36 +0200)
When causing a pagefault the page fault address is important for
debugging.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/x86/control.c
hypervisor/arch/x86/include/asm/processor.h

index 92f7e6885d19f59612fee3cbcb41343d92c6ddfa..88e9f3549b014f8a640449f0b4824b70a0a13336 100644 (file)
@@ -279,6 +279,8 @@ void x86_exception_handler(struct exception_frame *frame)
        panic_printk("Physical CPU ID: %d\n", phys_processor_id());
        panic_printk("RIP: %p RSP: %p FLAGS: %x\n", frame->rip, frame->rsp,
                     frame->flags);
+       if (frame->vector == PF_VECTOR)
+               panic_printk("CR2: %p\n", read_cr2());
 
        panic_stop();
 }
index aaa96e81c1ddd366263cd237f1f1e18997c4b12a..a8ad12f104313e8fea4f9889f4fac09fee52929b 100644 (file)
@@ -83,6 +83,7 @@
 #define X86_OP_MOV_FROM_MEM                            0x8b
 
 #define NMI_VECTOR                                     2
+#define PF_VECTOR                                      14
 
 #define DESC_TSS_BUSY                                  (1UL << (9 + 32))
 #define DESC_PRESENT                                   (1UL << (15 + 32))
@@ -179,6 +180,14 @@ static inline void write_cr0(unsigned long val)
        asm volatile("mov %0,%%cr0" : : "r" (val), "m" (__force_order));
 }
 
+static inline unsigned long read_cr2(void)
+{
+       unsigned long cr2;
+
+       asm volatile("mov %%cr2,%0" : "=r" (cr2), "=m" (__force_order));
+       return cr2;
+}
+
 static inline unsigned long read_cr3(void)
 {
        unsigned long cr3;