2 * Copyright (c) 2000-2004 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 <mach/mach_types.h>
31 #include <mach/mach_traps.h>
32 #include <mach/thread_status.h>
34 #include <kern/processor.h>
35 #include <kern/thread.h>
36 #include <kern/exception.h>
37 #include <kern/syscall_sw.h>
38 #include <kern/cpu_data.h>
39 #include <kern/debug.h>
41 #include <vm/vm_fault.h>
42 #include <vm/vm_kern.h> /* For kernel_map */
44 #include <ppc/misc_protos.h>
46 #include <ppc/exception.h>
47 #include <ppc/proc_reg.h> /* for SR_xxx definitions */
50 #include <ppc/mappings.h>
51 #include <ppc/Firmware.h>
52 #include <ppc/low_trace.h>
53 #include <ppc/Diagnostics.h>
54 #include <ppc/hw_perfmon.h>
56 #include <sys/kdebug.h>
58 perfCallback perfTrapHook
= 0; /* Pointer to CHUD trap hook routine */
59 perfCallback perfASTHook
= 0; /* Pointer to CHUD AST hook routine */
62 #include <ddb/db_watch.h>
63 #include <ddb/db_run.h>
64 #include <ddb/db_break.h>
65 #include <ddb/db_trap.h>
67 boolean_t let_ddb_vm_fault
= FALSE
;
68 boolean_t debug_all_traps_with_kdb
= FALSE
;
69 extern struct db_watchpoint
*db_watchpoint_list
;
70 extern boolean_t db_watchpoints_inserted
;
71 extern boolean_t db_breakpoints_inserted
;
77 extern task_t bsd_init_task
;
78 extern char init_task_failure_data
[];
79 extern int not_in_kdp
;
81 #define PROT_EXEC (VM_PROT_EXECUTE)
82 #define PROT_RO (VM_PROT_READ)
83 #define PROT_RW (VM_PROT_READ|VM_PROT_WRITE)
85 /* A useful macro to update the ppc_exception_state in the PCB
86 * before calling doexception
88 #define UPDATE_PPC_EXCEPTION_STATE { \
89 thread_t _thread = current_thread(); \
90 _thread->machine.pcb->save_dar = (uint64_t)dar; \
91 _thread->machine.pcb->save_dsisr = dsisr; \
92 _thread->machine.pcb->save_exception = trapno / T_VECTOR_SIZE; /* back to powerpc */ \
95 void unresolved_kernel_trap(int trapno
,
101 static void handleMck(struct savearea
*ssp
); /* Common machine check handler */
104 extern void get_procrustime(time_value_t
*);
105 extern void bsd_uprofil(time_value_t
*, user_addr_t
);
106 #endif /* MACH_BSD */
109 struct savearea
*trap(int trapno
,
110 struct savearea
*ssp
,
119 unsigned int space
, space2
;
120 vm_map_offset_t offset
;
121 thread_t thread
= current_thread();
127 #endif /* MACH_BSD */
129 myast
= ast_pending();
131 if(*myast
& AST_PPC_CHUD_ALL
) {
132 perfASTHook(trapno
, ssp
, dsisr
, (unsigned int)dar
);
135 *myast
&= ~AST_PPC_CHUD_ALL
;
138 if(perfTrapHook
) { /* Is there a hook? */
139 if(perfTrapHook(trapno
, ssp
, dsisr
, (unsigned int)dar
) == KERN_SUCCESS
) return ssp
; /* If it succeeds, we are done... */
144 extern void fctx_text(void);
149 exception
= 0; /* Clear exception for now */
152 * Remember that we are disabled for interruptions when we come in here. Because
153 * of latency concerns, we need to enable interruptions in the interrupted process
154 * was enabled itself as soon as we can.
157 intr
= (ssp
->save_srr1
& MASK(MSR_EE
)) != 0; /* Remember if we were enabled */
159 /* Handle kernel traps first */
161 if (!USER_MODE(ssp
->save_srr1
)) {
163 * Trap came from kernel
167 case T_PREEMPT
: /* Handle a preempt trap */
168 ast_taken(AST_PREEMPTION
, FALSE
);
172 perfmon_handle_pmi(ssp
);
175 case T_RESET
: /* Reset interruption */
176 if (!Call_Debugger(trapno
, ssp
))
177 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
178 break; /* We just ignore these */
181 * These trap types should never be seen by trap()
182 * in kernel mode, anyway.
183 * Some are interrupts that should be seen by
184 * interrupt() others just don't happen because they
185 * are handled elsewhere. Some could happen but are
186 * considered to be fatal in kernel mode.
189 case T_IN_VAIN
: /* Shouldn't ever see this, lowmem_vectors eats it */
190 case T_SYSTEM_MANAGEMENT
:
191 case T_ALTIVEC_ASSIST
:
193 case T_FP_UNAVAILABLE
:
197 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
202 * Here we handle a machine check in the kernel
205 case T_MACHINE_CHECK
:
206 handleMck(ssp
); /* Common to both user and kernel */
212 * If enaNotifyEMb is set, we get here, and
213 * we have actually already emulated the unaligned access.
214 * All that we want to do here is to ignore the interrupt. This is to allow logging or
215 * tracing of unaligned accesses.
218 if(ssp
->save_hdr
.save_misc3
) { /* Was it a handled exception? */
219 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
); /* Go panic */
222 KERNEL_DEBUG_CONSTANT(
223 MACHDBG_CODE(DBG_MACH_EXCP_ALNG
, 0) | DBG_FUNC_NONE
,
224 (int)ssp
->save_srr0
- 4, (int)dar
, (int)dsisr
, (int)ssp
->save_lr
, 0);
229 * If enaNotifyEMb is set we get here, and
230 * we have actually already emulated the instruction.
231 * All that we want to do here is to ignore the interrupt. This is to allow logging or
232 * tracing of emulated instructions.
235 KERNEL_DEBUG_CONSTANT(
236 MACHDBG_CODE(DBG_MACH_EXCP_EMUL
, 0) | DBG_FUNC_NONE
,
237 (int)ssp
->save_srr0
- 4, (int)((savearea_comm
*)ssp
)->save_misc2
, (int)dsisr
, (int)ssp
->save_lr
, 0);
245 case T_RUNMODE_TRACE
:
246 case T_INSTRUCTION_BKPT
:
247 if (!Call_Debugger(trapno
, ssp
))
248 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
252 if (ssp
->save_srr1
& MASK(SRR1_PRG_TRAP
)) {
253 if (!Call_Debugger(trapno
, ssp
))
254 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
256 unresolved_kernel_trap(trapno
, ssp
,
263 mp_disable_preemption();
265 && getPerProc()->debugger_active
266 && !let_ddb_vm_fault
) {
268 * Force kdb to handle this one.
270 kdb_trap(trapno
, ssp
);
272 mp_enable_preemption();
273 #endif /* MACH_KDB */
274 /* can we take this during normal panic dump operation? */
276 && getPerProc()->debugger_active
279 * Access fault while in kernel core dump.
281 kdp_dump_trap(trapno
, ssp
);
285 if(ssp
->save_dsisr
& dsiInvMode
) { /* Did someone try to reserve cache inhibited? */
286 panic("trap: disallowed access to cache inhibited memory - %016llX\n", dar
);
289 if(intr
) ml_set_interrupts_enabled(TRUE
); /* Enable if we were */
291 if(((dar
>> 28) < 0xE) | ((dar
>> 28) > 0xF)) { /* User memory window access? */
293 offset
= (vm_map_offset_t
)dar
; /* Set the failing address */
294 map
= kernel_map
; /* No, this is a normal kernel access */
297 * Note: Some ROM device drivers will access page 0 when they start. The IOKit will
298 * set a flag to tell us to ignore any access fault on page 0. After the driver is
299 * opened, it will clear the flag.
301 if((0 == (offset
& -PAGE_SIZE
)) && /* Check for access of page 0 and */
302 ((thread
->machine
.specFlags
) & ignoreZeroFault
)) { /* special case of ignoring page zero faults */
303 ssp
->save_srr0
+= 4; /* Point to next instruction */
307 code
= vm_fault(map
, vm_map_trunc_page(offset
),
308 dsisr
& MASK(DSISR_WRITE
) ? PROT_RW
: PROT_RO
,
309 FALSE
, THREAD_UNINT
, NULL
, vm_map_trunc_page(0));
311 if (code
!= KERN_SUCCESS
) {
312 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
314 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
315 ssp
->save_dsisr
= (ssp
->save_dsisr
&
316 ~((MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
321 /* If we get here, the fault was due to a user memory window access */
325 offset
= (vm_map_offset_t
)(thread
->machine
.umwRelo
+ dar
); /* Compute the user space address */
327 code
= vm_fault(map
, vm_map_trunc_page(offset
),
328 dsisr
& MASK(DSISR_WRITE
) ? PROT_RW
: PROT_RO
,
329 FALSE
, THREAD_UNINT
, NULL
, vm_map_trunc_page(0));
331 /* If we failed, there should be a recovery
334 if (code
!= KERN_SUCCESS
) {
335 if (thread
->recover
) {
336 ssp
->save_srr0
= thread
->recover
;
337 thread
->recover
= (vm_offset_t
)NULL
;
339 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, "copyin/out has no recovery point");
343 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
344 ssp
->save_dsisr
= (ssp
->save_dsisr
&
345 ~((MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
350 case T_INSTRUCTION_ACCESS
:
354 && getPerProc()->debugger_active
355 && !let_ddb_vm_fault
) {
357 * Force kdb to handle this one.
359 kdb_trap(trapno
, ssp
);
361 #endif /* MACH_KDB */
363 /* Same as for data access, except fault type
364 * is PROT_EXEC and addr comes from srr0
367 if(intr
) ml_set_interrupts_enabled(TRUE
); /* Enable if we were */
371 code
= vm_fault(map
, vm_map_trunc_page(ssp
->save_srr0
),
372 PROT_EXEC
, FALSE
, THREAD_UNINT
, NULL
, vm_map_trunc_page(0));
374 if (code
!= KERN_SUCCESS
) {
375 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
377 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
378 ssp
->save_srr1
= (ssp
->save_srr1
&
379 ~((unsigned long long)(MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
383 /* Usually shandler handles all the system calls, but the
384 * atomic thread switcher may throwup (via thandler) and
385 * have to pass it up to the exception handler.
389 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
393 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
399 * Processing for user state traps with interrupt enabled
400 * For T_AST, interrupts are enabled in the AST delivery
403 ml_set_interrupts_enabled(TRUE
);
407 get_procrustime(&tv
);
409 #endif /* MACH_BSD */
413 * Trap came from user task
419 unresolved_kernel_trap(trapno
, ssp
, dsisr
, dar
, NULL
);
423 perfmon_handle_pmi(ssp
);
427 * These trap types should never be seen by trap()
428 * Some are interrupts that should be seen by
429 * interrupt() others just don't happen because they
430 * are handled elsewhere.
433 case T_IN_VAIN
: /* Shouldn't ever see this, lowmem_vectors eats it */
435 case T_FP_UNAVAILABLE
:
436 case T_SYSTEM_MANAGEMENT
:
442 ml_set_interrupts_enabled(FALSE
); /* Turn off interruptions */
444 panic("Unexpected user state trap(cpu %d): 0x%08X DSISR=0x%08X DAR=0x%016llX PC=0x%016llX, MSR=0x%016llX\n",
445 cpu_number(), trapno
, dsisr
, dar
, ssp
->save_srr0
, ssp
->save_srr1
);
450 * Here we handle a machine check in user state
453 case T_MACHINE_CHECK
:
454 handleMck(ssp
); /* Common to both user and kernel */
458 ml_set_interrupts_enabled(FALSE
); /* Turn off interruptions */
459 if (!Call_Debugger(trapno
, ssp
))
460 panic("Unexpected Reset exception: srr0 = %016llx, srr1 = %016llx\n",
461 ssp
->save_srr0
, ssp
->save_srr1
);
462 break; /* We just ignore these */
466 * If enaNotifyEMb is set, we get here, and
467 * we have actually already emulated the unaligned access.
468 * All that we want to do here is to ignore the interrupt. This is to allow logging or
469 * tracing of unaligned accesses.
472 KERNEL_DEBUG_CONSTANT(
473 MACHDBG_CODE(DBG_MACH_EXCP_ALNG
, 0) | DBG_FUNC_NONE
,
474 (int)ssp
->save_srr0
- 4, (int)dar
, (int)dsisr
, (int)ssp
->save_lr
, 0);
476 if(ssp
->save_hdr
.save_misc3
) { /* Was it a handled exception? */
477 exception
= EXC_BAD_ACCESS
; /* Yes, throw exception */
478 code
= EXC_PPC_UNALIGNED
;
479 subcode
= (unsigned int)dar
;
485 * If enaNotifyEMb is set we get here, and
486 * we have actually already emulated the instruction.
487 * All that we want to do here is to ignore the interrupt. This is to allow logging or
488 * tracing of emulated instructions.
491 KERNEL_DEBUG_CONSTANT(
492 MACHDBG_CODE(DBG_MACH_EXCP_EMUL
, 0) | DBG_FUNC_NONE
,
493 (int)ssp
->save_srr0
- 4, (int)((savearea_comm
*)ssp
)->save_misc2
, (int)dsisr
, (int)ssp
->save_lr
, 0);
496 case T_TRACE
: /* Real PPC chips */
503 case T_INSTRUCTION_BKPT
:
504 exception
= EXC_BREAKPOINT
;
505 code
= EXC_PPC_TRACE
;
506 subcode
= (unsigned int)ssp
->save_srr0
;
510 if (ssp
->save_srr1
& MASK(SRR1_PRG_FE
)) {
511 fpu_save(thread
->machine
.curctx
);
512 UPDATE_PPC_EXCEPTION_STATE
;
513 exception
= EXC_ARITHMETIC
;
514 code
= EXC_ARITHMETIC
;
516 mp_disable_preemption();
517 subcode
= ssp
->save_fpscr
;
518 mp_enable_preemption();
520 else if (ssp
->save_srr1
& MASK(SRR1_PRG_ILL_INS
)) {
522 UPDATE_PPC_EXCEPTION_STATE
523 exception
= EXC_BAD_INSTRUCTION
;
524 code
= EXC_PPC_UNIPL_INST
;
525 subcode
= (unsigned int)ssp
->save_srr0
;
526 } else if ((unsigned int)ssp
->save_srr1
& MASK(SRR1_PRG_PRV_INS
)) {
528 UPDATE_PPC_EXCEPTION_STATE
;
529 exception
= EXC_BAD_INSTRUCTION
;
530 code
= EXC_PPC_PRIVINST
;
531 subcode
= (unsigned int)ssp
->save_srr0
;
532 } else if (ssp
->save_srr1
& MASK(SRR1_PRG_TRAP
)) {
536 //iaddr = CAST_DOWN(char *, ssp->save_srr0); /* Trim from long long and make a char pointer */
537 if (copyin(ssp
->save_srr0
, (char *) &inst
, 4 )) panic("copyin failed\n");
539 if(dgWork
.dgFlags
& enaDiagTrap
) { /* Is the diagnostic trap enabled? */
540 if((inst
& 0xFFFFFFF0) == 0x0FFFFFF0) { /* Is this a TWI 31,R31,0xFFFx? */
541 if(diagTrap(ssp
, inst
& 0xF)) { /* Call the trap code */
542 ssp
->save_srr0
+= 4ULL; /* If we eat the trap, bump pc */
543 exception
= 0; /* Clear exception */
544 break; /* All done here */
549 UPDATE_PPC_EXCEPTION_STATE
;
551 if (inst
== 0x7FE00008) {
552 exception
= EXC_BREAKPOINT
;
553 code
= EXC_PPC_BREAKPOINT
;
555 exception
= EXC_SOFTWARE
;
558 subcode
= (unsigned int)ssp
->save_srr0
;
562 case T_ALTIVEC_ASSIST
:
563 UPDATE_PPC_EXCEPTION_STATE
;
564 exception
= EXC_ARITHMETIC
;
565 code
= EXC_PPC_ALTIVECASSIST
;
566 subcode
= (unsigned int)ssp
->save_srr0
;
572 if(ssp
->save_dsisr
& dsiInvMode
) { /* Did someone try to reserve cache inhibited? */
573 UPDATE_PPC_EXCEPTION_STATE
; /* Don't even bother VM with this one */
574 exception
= EXC_BAD_ACCESS
;
575 subcode
= (unsigned int)dar
;
579 code
= vm_fault(map
, vm_map_trunc_page(dar
),
580 dsisr
& MASK(DSISR_WRITE
) ? PROT_RW
: PROT_RO
,
581 FALSE
, THREAD_ABORTSAFE
, NULL
, vm_map_trunc_page(0));
583 if ((code
!= KERN_SUCCESS
) && (code
!= KERN_ABORTED
)) {
584 UPDATE_PPC_EXCEPTION_STATE
;
585 exception
= EXC_BAD_ACCESS
;
586 subcode
= (unsigned int)dar
;
588 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
589 ssp
->save_dsisr
= (ssp
->save_dsisr
&
590 ~((MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
594 case T_INSTRUCTION_ACCESS
:
595 /* Same as for data access, except fault type
596 * is PROT_EXEC and addr comes from srr0
600 code
= vm_fault(map
, vm_map_trunc_page(ssp
->save_srr0
),
601 PROT_EXEC
, FALSE
, THREAD_ABORTSAFE
, NULL
, vm_map_trunc_page(0));
603 if ((code
!= KERN_SUCCESS
) && (code
!= KERN_ABORTED
)) {
604 UPDATE_PPC_EXCEPTION_STATE
;
605 exception
= EXC_BAD_ACCESS
;
606 subcode
= (unsigned int)ssp
->save_srr0
;
608 ssp
->save_hdr
.save_flags
|= SAVredrive
; /* Tell low-level to re-try fault */
609 ssp
->save_srr1
= (ssp
->save_srr1
&
610 ~((unsigned long long)(MASK(DSISR_NOEX
) | MASK(DSISR_PROT
)))) | MASK(DSISR_HASH
); /* Make sure this is marked as a miss */
615 /* AST delivery is done below */
621 bsd_uprofil(&tv
, ssp
->save_srr0
);
623 #endif /* MACH_BSD */
627 /* if this is the init task, save the exception information */
628 /* this probably is a fatal exception */
630 if(bsd_init_task
== current_task()) {
634 buf
= init_task_failure_data
;
637 buf
+= sprintf(buf
, "Exception Code = 0x%x, Subcode = 0x%x\n", code
, subcode
);
638 buf
+= sprintf(buf
, "DSISR = 0x%08x, DAR = 0x%016llx\n"
641 for (i
=0; i
<32; i
++) {
643 buf
+= sprintf(buf
, "\n%4d :",i
);
645 buf
+= sprintf(buf
, " %08x",*(&ssp
->save_r0
+i
));
648 buf
+= sprintf(buf
, "\n\n");
649 buf
+= sprintf(buf
, "cr = 0x%08X\t\t",ssp
->save_cr
);
650 buf
+= sprintf(buf
, "xer = 0x%08X\n",ssp
->save_xer
);
651 buf
+= sprintf(buf
, "lr = 0x%016llX\t\t",ssp
->save_lr
);
652 buf
+= sprintf(buf
, "ctr = 0x%016llX\n",ssp
->save_ctr
);
653 buf
+= sprintf(buf
, "srr0(iar) = 0x%016llX\t\t",ssp
->save_srr0
);
654 buf
+= sprintf(buf
, "srr1(msr) = 0x%016llX\n",ssp
->save_srr1
,
655 "\x10\x11""EE\x12PR\x13""FP\x14ME\x15""FE0\x16SE\x18"
656 "FE1\x19""AL\x1a""EP\x1bIT\x1c""DT");
657 buf
+= sprintf(buf
, "\n\n");
659 /* generate some stack trace */
660 buf
+= sprintf(buf
, "Application level back trace:\n");
661 if (ssp
->save_srr1
& MASK(MSR_PR
)) {
662 char *addr
= (char*)ssp
->save_r1
;
663 unsigned int stack_buf
[3];
664 for (i
= 0; i
< 8; i
++) {
665 if (addr
== (char*)NULL
)
667 if (!copyin(ssp
->save_r1
,(char*)stack_buf
,
669 buf
+= sprintf(buf
, "0x%08X : 0x%08X\n"
671 addr
= (char*)stack_buf
[0];
680 doexception(exception
, code
, subcode
);
683 * Check to see if we need an AST, if so take care of it here
685 ml_set_interrupts_enabled(FALSE
);
687 if (USER_MODE(ssp
->save_srr1
)) {
688 myast
= ast_pending();
689 while (*myast
& AST_ALL
) {
690 ast_taken(AST_ALL
, intr
);
691 ml_set_interrupts_enabled(FALSE
);
692 myast
= ast_pending();
699 /* This routine is called from assembly before each and every system call.
700 * It must preserve r3.
703 extern int syscall_trace(int, struct savearea
*);
708 int syscall_trace(int retval
, struct savearea
*ssp
)
712 /* Always prepare to trace mach system calls */
718 argc
= mach_trap_table
[-((unsigned int)ssp
->save_r0
)].mach_trap_arg_count
;
723 for (i
=0; i
< argc
; i
++)
724 kdarg
[i
] = (int)*(&ssp
->save_r3
+ i
);
726 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC
, (-(ssp
->save_r0
))) | DBG_FUNC_START
,
727 kdarg
[0], kdarg
[1], kdarg
[2], 0, 0);
732 /* This routine is called from assembly after each mach system call
733 * It must preserve r3.
736 extern int syscall_trace_end(int, struct savearea
*);
738 int syscall_trace_end(int retval
, struct savearea
*ssp
)
740 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC
,(-((unsigned int)ssp
->save_r0
))) | DBG_FUNC_END
,
746 * called from syscall if there is an error
753 struct savearea
*ssp
)
755 register thread_t thread
;
757 thread
= current_thread();
760 panic("syscall error in boot phase");
762 if (!USER_MODE(ssp
->save_srr1
))
763 panic("system call called from kernel");
765 doexception(exception
, code
, subcode
);
770 /* Pass up a server syscall/exception */
777 exception_data_type_t codes
[EXCEPTION_CODE_MAX
];
781 exception_triage(exc
, codes
, 2);
784 char *trap_type
[] = {
786 "0x100 - System reset",
787 "0x200 - Machine check",
788 "0x300 - Data access",
789 "0x400 - Inst access",
793 "0x800 - Floating point",
794 "0x900 - Decrementer",
797 "0xC00 - System call",
805 "0x1300 - Inst bkpnt",
807 "0x1600 - Altivec Assist",
818 "0x2000 - Run Mode/Trace",
825 int TRAP_TYPES
= sizeof (trap_type
) / sizeof (trap_type
[0]);
827 void unresolved_kernel_trap(int trapno
,
828 struct savearea
*ssp
,
834 extern void print_backtrace(struct savearea
*);
835 extern unsigned int debug_mode
, disableDebugOuput
;
836 extern unsigned long panic_caller
;
838 ml_set_interrupts_enabled(FALSE
); /* Turn off interruptions */
839 lastTrace
= LLTraceSet(0); /* Disable low-level tracing */
841 if( logPanicDataToScreen
)
842 disableDebugOuput
= FALSE
;
845 if ((unsigned)trapno
<= T_MAX
)
846 trap_name
= trap_type
[trapno
/ T_VECTOR_SIZE
];
848 trap_name
= "???? unrecognized exception";
852 kdb_printf("\n\nUnresolved kernel trap(cpu %d): %s DAR=0x%016llX PC=0x%016llX\n",
853 cpu_number(), trap_name
, dar
, ssp
->save_srr0
);
855 print_backtrace(ssp
);
857 panic_caller
= (0xFFFF0000 | (trapno
/ T_VECTOR_SIZE
) );
861 (void *)Call_Debugger(trapno
, ssp
);
865 const char *corr
[2] = {"uncorrected", "corrected "};
867 void handleMck(struct savearea
*ssp
) { /* Common machine check handler */
873 printf("Machine check (%d) - %s - pc = %016llX, msr = %016llX, dsisr = %08X, dar = %016llX\n",
874 cpu
, corr
[ssp
->save_hdr
.save_misc3
], ssp
->save_srr0
, ssp
->save_srr1
, ssp
->save_dsisr
, ssp
->save_dar
); /* Tell us about it */
875 printf("Machine check (%d) - AsyncSrc = %016llX, CoreFIR = %016llx\n", cpu
, ssp
->save_xdat0
, ssp
->save_xdat1
);
876 printf("Machine check (%d) - L2FIR = %016llX, BusFir = %016llx\n", cpu
, ssp
->save_xdat2
, ssp
->save_xdat3
);
878 if(ssp
->save_hdr
.save_misc3
) return; /* Leave the the machine check was recovered */
880 panic("Uncorrectable machine check: pc = %016llX, msr = %016llX, dsisr = %08X, dar = %016llX\n"
881 " AsyncSrc = %016llX, CoreFIR = %016llx\n"
882 " L2FIR = %016llX, BusFir = %016llx\n",
883 ssp
->save_srr0
, ssp
->save_srr1
, ssp
->save_dsisr
, ssp
->save_dar
,
884 ssp
->save_xdat0
, ssp
->save_xdat1
, ssp
->save_xdat2
, ssp
->save_xdat3
);
890 thread_syscall_return(
893 register thread_t thread
= current_thread();
894 register struct savearea
*regs
= USER_REGS(thread
);
896 if (kdebug_enable
&& ((unsigned int)regs
->save_r0
& 0x80000000)) {
898 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_EXCP_SC
,(-(regs
->save_r0
))) | DBG_FUNC_END
,
903 thread_exception_return();
910 thread_kdb_return(void)
912 register thread_t thread
= current_thread();
913 register struct savearea
*regs
= USER_REGS(thread
);
915 Call_Debugger(thread
->machine
.pcb
->save_exception
, regs
);
916 thread_exception_return();
919 #endif /* MACH_KDB */