]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/trap.c
xnu-792.25.20.tar.gz
[apple/xnu.git] / osfmk / i386 / trap.c
index bb395224973a2fda38d97edb6466f7340427573b..7c9aa04f1fd828c101de2639492ab72312f9f3bb 100644 (file)
@@ -63,7 +63,7 @@
 #include <i386/trap.h>
 #include <i386/pmap.h>
 #include <i386/fpu.h>
-#include <architecture/i386/pio.h> /* inb() */
+#include <i386/misc_protos.h> /* panic_io_port_read() */
 
 #include <mach/exception.h>
 #include <mach/kern_return.h>
 #include <i386/postcode.h>
 #include <i386/mp_desc.h>
 #include <i386/proc_reg.h>
+#include <i386/machine_check.h>
 #include <mach/i386/syscall_sw.h>
 
 /*
@@ -281,8 +282,6 @@ extern struct recovery      recover_table_end[];
 const char *   trap_type[] = {TRAP_NAMES};
 unsigned       TRAP_TYPES = sizeof(trap_type)/sizeof(trap_type[0]);
 
-extern unsigned panic_io_port;
-
 static inline void
 reset_dr7(void)
 {
@@ -617,8 +616,7 @@ panic_trap(x86_saved_state32_t *regs)
        uint32_t        cr3 = get_cr3();
        uint32_t        cr4 = get_cr4();
 
-       if (panic_io_port)
-         (void)inb(panic_io_port);
+       panic_io_port_read();
 
        kprintf("panic trap number 0x%x, eip 0x%x\n", regs->trapno, regs->eip);
        kprintf("cr0 0x%08x cr2 0x%08x cr3 0x%08x cr4 0x%08x\n",
@@ -663,8 +661,7 @@ panic_double_fault(int code)
 /* Issue an I/O port read if one has been requested - this is an event logic
  * analyzers can use as a trigger point.
  */
-       if (panic_io_port)
-               (void)inb(panic_io_port);
+       panic_io_port_read();
 
        /*
         * Break kprintf lock in case of recursion,
@@ -709,6 +706,15 @@ panic_machine_check(int code)
         * and record originally faulted instruction address.
         */
        kprintf_break_lock();
+
+       /*
+        * Dump the contents of the machine check MSRs (if any).
+        */
+       mca_dump();
+
+       /*
+        * And that's all folks, we don't attempt recovery...
+        */
        panic("Machine-check (CPU:%d, thread:%p, code:0x%x),"
              "registers:\n"
              "CR0: 0x%08x, CR2: 0x%08x, CR3: 0x%08x, CR4: 0x%08x\n"
@@ -746,14 +752,14 @@ panic_double_fault64(x86_saved_state_t *esp)
                      "RSP: 0x%016qx, RBP: 0x%016qx, RSI: 0x%016qx, RDI: 0x%016qx\n"
                      "R8:  0x%016qx, R9:  0x%016qx, R10: 0x%016qx, R11: 0x%016qx\n"
                      "R12: 0x%016qx, R13: 0x%016qx, R14: 0x%016qx, R15: 0x%016qx\n"
-                     "RFL: 0x%016qx, RIP: 0x%016qx\n",
+                     "RFL: 0x%016qx, RIP: 0x%016qx, CR2: 0x%016qx\n",
                      cpu_number(), current_thread(), ss64p->isf.trapno, ss64p->isf.err,
                      get_cr0(), get_cr2(), get_cr3(), get_cr4(),
                      ss64p->rax, ss64p->rbx, ss64p->rcx, ss64p->rdx,
                      ss64p->isf.rsp, ss64p->rbp, ss64p->rsi, ss64p->rdi,
                      ss64p->r8, ss64p->r9, ss64p->r10, ss64p->r11,
                      ss64p->r12, ss64p->r13, ss64p->r14, ss64p->r15,
-                     ss64p->isf.rflags, ss64p->isf.rip);
+                     ss64p->isf.rflags, ss64p->isf.rip, ss64p->cr2);
        } else {
                x86_saved_state32_t     *ss32p = saved_state32(esp);
                panic("Double fault (CPU:%d, thread:%p, trapno:0x%x, err:0x%x),"
@@ -771,11 +777,7 @@ panic_double_fault64(x86_saved_state_t *esp)
 }
 
 /*
- * Simplistic machine check handler.
- * We could peruse all those MSRs but we only dump register state as we do for
- * the double fault exception.
- * Note: the machine check registers are non-volatile across warm boot - so
- * they'll be around when we return.
+ * Machine check handler for 64-bit.
  */
 void
 panic_machine_check64(x86_saved_state_t *esp)
@@ -790,7 +792,12 @@ panic_machine_check64(x86_saved_state_t *esp)
        kprintf_break_lock();
 
        /*
-        * Dump the interrupt stack frame at last kernel entry.
+        * Dump the contents of the machine check MSRs (if any).
+        */
+       mca_dump();
+
+       /*
+        * And that's all folks, we don't attempt recovery...
         */
        if (is_saved_state64(esp)) {
                x86_saved_state64_t     *ss64p = saved_state64(esp);