2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
30 #include <kern/thread.h>
31 #include <kern/exception.h>
32 #include <kern/syscall_sw.h>
33 #include <kern/cpu_data.h>
34 #include <kern/debug.h>
35 #include <mach/thread_status.h>
36 #include <vm/vm_fault.h>
37 #include <vm/vm_kern.h> /* For kernel_map */
38 #include <ppc/misc_protos.h>
40 #include <ppc/exception.h>
41 #include <ppc/proc_reg.h> /* for SR_xxx definitions */
44 #include <ppc/mappings.h>
45 #include <ppc/Firmware.h>
46 #include <ppc/low_trace.h>
47 #include <ppc/Diagnostics.h>
48 #include <ppc/hw_perfmon.h>
50 #include <sys/kdebug.h>
52 perfTrap perfTrapHook
= 0; /* Pointer to performance trap hook routine */
55 #include <ddb/db_watch.h>
56 #include <ddb/db_run.h>
57 #include <ddb/db_break.h>
58 #include <ddb/db_trap.h>
60 boolean_t let_ddb_vm_fault
= FALSE
;
61 boolean_t debug_all_traps_with_kdb
= FALSE
;
62 extern struct db_watchpoint
*db_watchpoint_list
;
63 extern boolean_t db_watchpoints_inserted
;
64 extern boolean_t db_breakpoints_inserted
;
70 extern int debugger_active
[NCPUS
];
71 extern task_t bsd_init_task
;
72 extern char init_task_failure_data
[];
73 extern int not_in_kdp
;
75 #define PROT_EXEC (VM_PROT_EXECUTE)
76 #define PROT_RO (VM_PROT_READ)
77 #define PROT_RW (VM_PROT_READ|VM_PROT_WRITE)
79 /* A useful macro to update the ppc_exception_state in the PCB
80 * before calling doexception
82 #define UPDATE_PPC_EXCEPTION_STATE { \
83 thread_act_t thr_act = current_act(); \
84 thr_act->mact.pcb->save_dar = (uint64_t)dar; \
85 thr_act->mact.pcb->save_dsisr = dsisr; \
86 thr_act->mact.pcb->save_exception = trapno / T_VECTOR_SIZE; /* back to powerpc */ \
89 static void unresolved_kernel_trap(int trapno
,
95 static void handleMck(struct savearea
*ssp
); /* Common machine check handler */
98 struct savearea
*trap(int trapno
,
108 unsigned int space
, space2
;
110 thread_act_t thr_act
;
115 #endif /* MACH_BSD */
117 if(perfTrapHook
) { /* Is there a hook? */
118 if(perfTrapHook(trapno
, ssp
, dsisr
, (unsigned int)dar
) == KERN_SUCCESS
) return ssp
; /* If it succeeds, we are done... */
123 extern void fctx_text(void);
128 thr_act
= current_act(); /* Get current activation */
129 exception
= 0; /* Clear exception for now */
132 * Remember that we are disabled for interruptions when we come in here. Because
133 * of latency concerns, we need to enable interruptions in the interrupted process
134 * was enabled itself as soon as we can.
137 intr
= (ssp
->save_srr1
& MASK(MSR_EE
)) != 0; /* Remember if we were enabled */
139 /* Handle kernel traps first */
141 if (!USER_MODE(ssp
->save_srr1
)) {
143 * Trap came from kernel
147 case T_PREEMPT
: /* Handle a preempt trap */
148 ast_taken(AST_PREEMPTION
, FALSE
);
152 perfmon_handle_pmi(ssp
);
155 case T_RESET
: /* Reset interruption */
156 if (!Call_Debugger(trapno
, ssp
))
157 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
158 break; /* We just ignore these */
161 * These trap types should never be seen by trap()
162 * in kernel mode, anyway.
163 * Some are interrupts that should be seen by
164 * interrupt() others just don't happen because they
165 * are handled elsewhere. Some could happen but are
166 * considered to be fatal in kernel mode.
169 case T_IN_VAIN
: /* Shouldn't ever see this, lowmem_vectors eats it */
170 case T_SYSTEM_MANAGEMENT
:
171 case T_ALTIVEC_ASSIST
:
173 case T_FP_UNAVAILABLE
:
177 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
182 * Here we handle a machine check in the kernel
185 case T_MACHINE_CHECK
:
186 handleMck(ssp
); /* Common to both user and kernel */
192 * If enaNotifyEMb is set, we get here, and
193 * we have actually already emulated the unaligned access.
194 * All that we want to do here is to ignore the interrupt. This is to allow logging or
195 * tracing of unaligned accesses.
198 KERNEL_DEBUG_CONSTANT(
199 MACHDBG_CODE(DBG_MACH_EXCP_ALNG
, 0) | DBG_FUNC_NONE
,
200 (int)ssp
->save_srr0
- 4, (int)dar
, (int)dsisr
, (int)ssp
->save_lr
, 0);
205 * If enaNotifyEMb is set we get here, and
206 * we have actually already emulated the instruction.
207 * All that we want to do here is to ignore the interrupt. This is to allow logging or
208 * tracing of emulated instructions.
211 KERNEL_DEBUG_CONSTANT(
212 MACHDBG_CODE(DBG_MACH_EXCP_EMUL
, 0) | DBG_FUNC_NONE
,
213 (int)ssp
->save_srr0
- 4, (int)((savearea_comm
*)ssp
)->save_misc2
, (int)dsisr
, (int)ssp
->save_lr
, 0);
221 case T_RUNMODE_TRACE
:
222 case T_INSTRUCTION_BKPT
:
223 if (!Call_Debugger(trapno
, ssp
))
224 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
228 if (ssp
->save_srr1
& MASK(SRR1_PRG_TRAP
)) {
229 if (!Call_Debugger(trapno
, ssp
))
230 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
232 unresolved_kernel_trap(trapno
, ssp
,
239 mp_disable_preemption();
241 && debugger_active
[cpu_number()]
242 && !let_ddb_vm_fault
) {
244 * Force kdb to handle this one.
246 kdb_trap(trapno
, ssp
);
248 mp_enable_preemption();
249 #endif /* MACH_KDB */
250 /* can we take this during normal panic dump operation? */
252 && debugger_active
[cpu_number()]
255 * Access fault while in kernel core dump.
257 kdp_dump_trap(trapno
, ssp
);
261 if(ssp
->save_dsisr
& dsiInvMode
) { /* Did someone try to reserve cache inhibited? */
262 panic("trap: disallowed access to cache inhibited memory - %016llX\n", dar
);
265 if(intr
) ml_set_interrupts_enabled(TRUE
); /* Enable if we were */
267 if(((dar
>> 28) < 0xE) | ((dar
>> 28) > 0xF)) { /* Is this a copy in/out? */
269 offset
= (unsigned int)dar
; /* Set the failing address */
270 map
= kernel_map
; /* No, this is a normal kernel access */
273 * Note: Some ROM device drivers will access page 0 when they start. The IOKit will
274 * set a flag to tell us to ignore any access fault on page 0. After the driver is
275 * opened, it will clear the flag.
277 if((0 == (offset
& -PAGE_SIZE
)) && /* Check for access of page 0 and */
278 ((thr_act
->mact
.specFlags
) & ignoreZeroFault
)) { /* special case of ignoring page zero faults */
279 ssp
->save_srr0
+= 4; /* Point to next instruction */
283 code
= vm_fault(map
, trunc_page_32(offset
),
284 dsisr
& MASK(DSISR_WRITE
) ? PROT_RW
: PROT_RO
,
285 FALSE
, THREAD_UNINT
, NULL
, 0);
287 if (code
!= KERN_SUCCESS
) {
288 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
290 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
291 ssp
->save_dsisr
= (ssp
->save_dsisr
&
292 ~((MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
297 /* If we get here, the fault was due to a copyin/out */
301 offset
= (unsigned int)(thr_act
->mact
.cioRelo
+ dar
); /* Compute the user space address */
303 code
= vm_fault(map
, trunc_page_32(offset
),
304 dsisr
& MASK(DSISR_WRITE
) ? PROT_RW
: PROT_RO
,
305 FALSE
, THREAD_UNINT
, NULL
, 0);
307 /* If we failed, there should be a recovery
310 if (code
!= KERN_SUCCESS
) {
312 if (thr_act
->thread
->recover
) {
314 act_lock_thread(thr_act
);
315 ssp
->save_srr0
= thr_act
->thread
->recover
;
316 thr_act
->thread
->recover
=
318 act_unlock_thread(thr_act
);
320 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, "copyin/out has no recovery point");
324 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
325 ssp
->save_dsisr
= (ssp
->save_dsisr
&
326 ~((MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
331 case T_INSTRUCTION_ACCESS
:
335 && debugger_active
[cpu_number()]
336 && !let_ddb_vm_fault
) {
338 * Force kdb to handle this one.
340 kdb_trap(trapno
, ssp
);
342 #endif /* MACH_KDB */
344 /* Same as for data access, except fault type
345 * is PROT_EXEC and addr comes from srr0
348 if(intr
) ml_set_interrupts_enabled(TRUE
); /* Enable if we were */
352 code
= vm_fault(map
, trunc_page_64(ssp
->save_srr0
),
353 PROT_EXEC
, FALSE
, THREAD_UNINT
, NULL
, 0);
355 if (code
!= KERN_SUCCESS
) {
356 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
358 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
359 ssp
->save_srr1
= (ssp
->save_srr1
&
360 ~((unsigned long long)(MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
364 /* Usually shandler handles all the system calls, but the
365 * atomic thread switcher may throwup (via thandler) and
366 * have to pass it up to the exception handler.
370 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
374 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
379 ml_set_interrupts_enabled(TRUE
); /* Processing for user state traps is always enabled */
383 void get_procrustime(time_value_t
*);
385 get_procrustime(&tv
);
387 #endif /* MACH_BSD */
391 * Trap came from user task
397 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
401 perfmon_handle_pmi(ssp
);
405 * These trap types should never be seen by trap()
406 * Some are interrupts that should be seen by
407 * interrupt() others just don't happen because they
408 * are handled elsewhere.
411 case T_IN_VAIN
: /* Shouldn't ever see this, lowmem_vectors eats it */
413 case T_FP_UNAVAILABLE
:
414 case T_SYSTEM_MANAGEMENT
:
420 ml_set_interrupts_enabled(FALSE
); /* Turn off interruptions */
422 panic("Unexpected user state trap(cpu %d): 0x%08X DSISR=0x%08X DAR=0x%016llX PC=0x%016llX, MSR=0x%016llX\n",
423 cpu_number(), trapno
, dsisr
, dar
, ssp
->save_srr0
, ssp
->save_srr1
);
428 * Here we handle a machine check in user state
431 case T_MACHINE_CHECK
:
432 handleMck(ssp
); /* Common to both user and kernel */
436 ml_set_interrupts_enabled(FALSE
); /* Turn off interruptions */
437 if (!Call_Debugger(trapno
, ssp
))
438 panic("Unexpected Reset exception: srr0 = %016llx, srr1 = %016llx\n",
439 ssp
->save_srr0
, ssp
->save_srr1
);
440 break; /* We just ignore these */
444 * If enaNotifyEMb is set, we get here, and
445 * we have actually already emulated the unaligned access.
446 * All that we want to do here is to ignore the interrupt. This is to allow logging or
447 * tracing of unaligned accesses.
450 KERNEL_DEBUG_CONSTANT(
451 MACHDBG_CODE(DBG_MACH_EXCP_ALNG
, 0) | DBG_FUNC_NONE
,
452 (int)ssp
->save_srr0
- 4, (int)dar
, (int)dsisr
, (int)ssp
->save_lr
, 0);
457 * If enaNotifyEMb is set we get here, and
458 * we have actually already emulated the instruction.
459 * All that we want to do here is to ignore the interrupt. This is to allow logging or
460 * tracing of emulated instructions.
463 KERNEL_DEBUG_CONSTANT(
464 MACHDBG_CODE(DBG_MACH_EXCP_EMUL
, 0) | DBG_FUNC_NONE
,
465 (int)ssp
->save_srr0
- 4, (int)((savearea_comm
*)ssp
)->save_misc2
, (int)dsisr
, (int)ssp
->save_lr
, 0);
468 case T_TRACE
: /* Real PPC chips */
475 case T_INSTRUCTION_BKPT
:
476 exception
= EXC_BREAKPOINT
;
477 code
= EXC_PPC_TRACE
;
478 subcode
= (unsigned int)ssp
->save_srr0
;
482 if (ssp
->save_srr1
& MASK(SRR1_PRG_FE
)) {
483 fpu_save(thr_act
->mact
.curctx
);
484 UPDATE_PPC_EXCEPTION_STATE
;
485 exception
= EXC_ARITHMETIC
;
486 code
= EXC_ARITHMETIC
;
488 mp_disable_preemption();
489 subcode
= ssp
->save_fpscr
;
490 mp_enable_preemption();
492 else if (ssp
->save_srr1
& MASK(SRR1_PRG_ILL_INS
)) {
494 UPDATE_PPC_EXCEPTION_STATE
495 exception
= EXC_BAD_INSTRUCTION
;
496 code
= EXC_PPC_UNIPL_INST
;
497 subcode
= (unsigned int)ssp
->save_srr0
;
498 } else if ((unsigned int)ssp
->save_srr1
& MASK(SRR1_PRG_PRV_INS
)) {
500 UPDATE_PPC_EXCEPTION_STATE
;
501 exception
= EXC_BAD_INSTRUCTION
;
502 code
= EXC_PPC_PRIVINST
;
503 subcode
= (unsigned int)ssp
->save_srr0
;
504 } else if (ssp
->save_srr1
& MASK(SRR1_PRG_TRAP
)) {
508 iaddr
= CAST_DOWN(char *, ssp
->save_srr0
); /* Trim from long long and make a char pointer */
509 if (copyin(iaddr
, (char *) &inst
, 4 )) panic("copyin failed\n");
511 if(dgWork
.dgFlags
& enaDiagTrap
) { /* Is the diagnostic trap enabled? */
512 if((inst
& 0xFFFFFFF0) == 0x0FFFFFF0) { /* Is this a TWI 31,R31,0xFFFx? */
513 if(diagTrap(ssp
, inst
& 0xF)) { /* Call the trap code */
514 ssp
->save_srr0
+= 4ULL; /* If we eat the trap, bump pc */
515 exception
= 0; /* Clear exception */
516 break; /* All done here */
521 UPDATE_PPC_EXCEPTION_STATE
;
523 if (inst
== 0x7FE00008) {
524 exception
= EXC_BREAKPOINT
;
525 code
= EXC_PPC_BREAKPOINT
;
527 exception
= EXC_SOFTWARE
;
530 subcode
= (unsigned int)ssp
->save_srr0
;
534 case T_ALTIVEC_ASSIST
:
535 UPDATE_PPC_EXCEPTION_STATE
;
536 exception
= EXC_ARITHMETIC
;
537 code
= EXC_PPC_ALTIVECASSIST
;
538 subcode
= (unsigned int)ssp
->save_srr0
;
544 if(ssp
->save_dsisr
& dsiInvMode
) { /* Did someone try to reserve cache inhibited? */
545 UPDATE_PPC_EXCEPTION_STATE
; /* Don't even bother VM with this one */
546 exception
= EXC_BAD_ACCESS
;
547 subcode
= (unsigned int)dar
;
551 code
= vm_fault(map
, trunc_page_64(dar
),
552 dsisr
& MASK(DSISR_WRITE
) ? PROT_RW
: PROT_RO
,
553 FALSE
, THREAD_ABORTSAFE
, NULL
, 0);
555 if ((code
!= KERN_SUCCESS
) && (code
!= KERN_ABORTED
)) {
556 UPDATE_PPC_EXCEPTION_STATE
;
557 exception
= EXC_BAD_ACCESS
;
558 subcode
= (unsigned int)dar
;
560 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
561 ssp
->save_dsisr
= (ssp
->save_dsisr
&
562 ~((MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
566 case T_INSTRUCTION_ACCESS
:
567 /* Same as for data access, except fault type
568 * is PROT_EXEC and addr comes from srr0
572 code
= vm_fault(map
, trunc_page_64(ssp
->save_srr0
),
573 PROT_EXEC
, FALSE
, THREAD_ABORTSAFE
, NULL
, 0);
575 if ((code
!= KERN_SUCCESS
) && (code
!= KERN_ABORTED
)) {
576 UPDATE_PPC_EXCEPTION_STATE
;
577 exception
= EXC_BAD_ACCESS
;
578 subcode
= (unsigned int)ssp
->save_srr0
;
580 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
581 ssp
->save_srr1
= (ssp
->save_srr1
&
582 ~((unsigned long long)(MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
587 ml_set_interrupts_enabled(FALSE
);
588 ast_taken(AST_ALL
, intr
);
594 void bsd_uprofil(time_value_t
*, unsigned int);
596 bsd_uprofil(&tv
, ssp
->save_srr0
);
598 #endif /* MACH_BSD */
602 /* if this is the init task, save the exception information */
603 /* this probably is a fatal exception */
605 if(bsd_init_task
== current_task()) {
609 buf
= init_task_failure_data
;
612 buf
+= sprintf(buf
, "Exception Code = 0x%x, Subcode = 0x%x\n", code
, subcode
);
613 buf
+= sprintf(buf
, "DSISR = 0x%08x, DAR = 0x%016llx\n"
616 for (i
=0; i
<32; i
++) {
618 buf
+= sprintf(buf
, "\n%4d :",i
);
620 buf
+= sprintf(buf
, " %08x",*(&ssp
->save_r0
+i
));
623 buf
+= sprintf(buf
, "\n\n");
624 buf
+= sprintf(buf
, "cr = 0x%08X\t\t",ssp
->save_cr
);
625 buf
+= sprintf(buf
, "xer = 0x%08X\n",ssp
->save_xer
);
626 buf
+= sprintf(buf
, "lr = 0x%016llX\t\t",ssp
->save_lr
);
627 buf
+= sprintf(buf
, "ctr = 0x%016llX\n",ssp
->save_ctr
);
628 buf
+= sprintf(buf
, "srr0(iar) = 0x%016llX\t\t",ssp
->save_srr0
);
629 buf
+= sprintf(buf
, "srr1(msr) = 0x%016llX\n",ssp
->save_srr1
,
630 "\x10\x11""EE\x12PR\x13""FP\x14ME\x15""FE0\x16SE\x18"
631 "FE1\x19""AL\x1a""EP\x1bIT\x1c""DT");
632 buf
+= sprintf(buf
, "\n\n");
634 /* generate some stack trace */
635 buf
+= sprintf(buf
, "Application level back trace:\n");
636 if (ssp
->save_srr1
& MASK(MSR_PR
)) {
637 char *addr
= (char*)ssp
->save_r1
;
638 unsigned int stack_buf
[3];
639 for (i
= 0; i
< 8; i
++) {
640 if (addr
== (char*)NULL
)
642 if (!copyin(addr
,(char*)stack_buf
,
644 buf
+= sprintf(buf
, "0x%08X : 0x%08X\n"
646 addr
= (char*)stack_buf
[0];
655 doexception(exception
, code
, subcode
);
658 * Check to see if we need an AST, if so take care of it here
660 ml_set_interrupts_enabled(FALSE
);
661 if (USER_MODE(ssp
->save_srr1
))
662 while (ast_needed(cpu_number())) {
663 ast_taken(AST_ALL
, intr
);
664 ml_set_interrupts_enabled(FALSE
);
670 /* This routine is called from assembly before each and every system call.
671 * It must preserve r3.
674 extern int syscall_trace(int, struct savearea
*);
679 int syscall_trace(int retval
, struct savearea
*ssp
)
683 /* Always prepare to trace mach system calls */
689 argc
= mach_trap_table
[-((unsigned int)ssp
->save_r0
)].mach_trap_arg_count
;
694 for (i
=0; i
< argc
; i
++)
695 kdarg
[i
] = (int)*(&ssp
->save_r3
+ i
);
697 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC
, (-(ssp
->save_r0
))) | DBG_FUNC_START
,
698 kdarg
[0], kdarg
[1], kdarg
[2], 0, 0);
703 /* This routine is called from assembly after each mach system call
704 * It must preserve r3.
707 extern int syscall_trace_end(int, struct savearea
*);
709 int syscall_trace_end(int retval
, struct savearea
*ssp
)
711 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC
,(-((unsigned int)ssp
->save_r0
))) | DBG_FUNC_END
,
717 * called from syscall if there is an error
724 struct savearea
*ssp
)
726 register thread_t thread
;
728 thread
= current_thread();
731 panic("syscall error in boot phase");
733 if (!USER_MODE(ssp
->save_srr1
))
734 panic("system call called from kernel");
736 doexception(exception
, code
, subcode
);
741 /* Pass up a server syscall/exception */
748 exception_data_type_t codes
[EXCEPTION_CODE_MAX
];
752 exception(exc
, codes
, 2);
755 char *trap_type
[] = {
757 "0x100 - System reset",
758 "0x200 - Machine check",
759 "0x300 - Data access",
760 "0x400 - Inst access",
764 "0x800 - Floating point",
765 "0x900 - Decrementer",
768 "0xC00 - System call",
776 "0x1300 - Inst bkpnt",
778 "0x1600 - Altivec Assist",
789 "0x2000 - Run Mode/Trace",
796 int TRAP_TYPES
= sizeof (trap_type
) / sizeof (trap_type
[0]);
798 void unresolved_kernel_trap(int trapno
,
799 struct savearea
*ssp
,
805 extern void print_backtrace(struct savearea
*);
806 extern unsigned int debug_mode
, disableDebugOuput
;
808 ml_set_interrupts_enabled(FALSE
); /* Turn off interruptions */
809 lastTrace
= LLTraceSet(0); /* Disable low-level tracing */
811 if( logPanicDataToScreen
)
812 disableDebugOuput
= FALSE
;
815 if ((unsigned)trapno
<= T_MAX
)
816 trap_name
= trap_type
[trapno
/ T_VECTOR_SIZE
];
818 trap_name
= "???? unrecognized exception";
822 kdb_printf("\n\nUnresolved kernel trap(cpu %d): %s DAR=0x%016llX PC=0x%016llX\n",
823 cpu_number(), trap_name
, dar
, ssp
->save_srr0
);
825 print_backtrace(ssp
);
830 (void *)Call_Debugger(trapno
, ssp
);
834 char *corr
[2] = {"uncorrected", "corrected "};
836 void handleMck(struct savearea
*ssp
) { /* Common machine check handler */
842 printf("Machine check (%d) - %s - pc = %016llX, msr = %016llX, dsisr = %08X, dar = %016llX\n",
843 cpu
, corr
[ssp
->save_hdr
.save_misc3
], ssp
->save_srr0
, ssp
->save_srr1
, ssp
->save_dsisr
, ssp
->save_dar
); /* Tell us about it */
844 printf("Machine check (%d) - AsyncSrc = %016llX, CoreFIR = %016llx\n", cpu
, ssp
->save_xdat0
, ssp
->save_xdat1
);
845 printf("Machine check (%d) - L2FIR = %016llX, BusFir = %016llx\n", cpu
, ssp
->save_xdat2
, ssp
->save_xdat3
);
847 if(ssp
->save_hdr
.save_misc3
) return; /* Leave the the machine check was recovered */
849 panic("Uncorrectable machine check: pc = %016llX, msr = %016llX, dsisr = %08X, dar = %016llX\n"
850 " AsyncSrc = %016llX, CoreFIR = %016llx\n"
851 " L2FIR = %016llX, BusFir = %016llx\n",
852 ssp
->save_srr0
, ssp
->save_srr1
, ssp
->save_dsisr
, ssp
->save_dar
,
853 ssp
->save_xdat0
, ssp
->save_xdat1
, ssp
->save_xdat2
, ssp
->save_xdat3
);
859 thread_syscall_return(
862 register thread_act_t thr_act
= current_act();
863 register struct savearea
*regs
= USER_REGS(thr_act
);
865 if (kdebug_enable
&& ((unsigned int)regs
->save_r0
& 0x80000000)) {
867 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC
,(-(regs
->save_r0
))) | DBG_FUNC_END
,
872 thread_exception_return();
879 thread_kdb_return(void)
881 register thread_act_t thr_act
= current_act();
882 register thread_t cur_thr
= current_thread();
883 register struct savearea
*regs
= USER_REGS(thr_act
);
885 Call_Debugger(thr_act
->mact
.pcb
->save_exception
, regs
);
887 assert(cur_thr
->mutex_count
== 0);
888 #endif /* MACH_LDEBUG */
889 check_simple_locks();
890 thread_exception_return();
893 #endif /* MACH_KDB */