Changeset e3038b4 in mainline
- Timestamp:
- 2010-06-28T22:45:51Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 49eb681
- Parents:
- 05e3cb8 (diff), e4a4b44 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel
- Files:
-
- 1 added
- 5 deleted
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile
r05e3cb8 re3038b4 201 201 generic/src/debug/symtab.c \ 202 202 generic/src/debug/stacktrace.c \ 203 generic/src/debug/panic.c \ 203 204 generic/src/interrupt/interrupt.c \ 204 205 generic/src/main/main.c \ -
kernel/arch/abs32le/src/abs32le.c
r05e3cb8 re3038b4 114 114 } 115 115 116 void panic_printf(const char *fmt, ...)116 void istate_decode(istate_t *istate) 117 117 { 118 va_list args; 119 120 va_start(args, fmt); 121 vprintf(fmt, args); 122 va_end(args); 123 124 halt(); 118 (void) istate; 125 119 } 126 120 -
kernel/arch/amd64/include/interrupt.h
r05e3cb8 re3038b4 112 112 extern void (* eoi_function)(void); 113 113 114 extern void decode_istate(int n, istate_t *istate);115 114 extern void interrupt_init(void); 116 115 extern void trap_virtual_enable_irqs(uint16_t irqmask); -
kernel/arch/amd64/include/types.h
r05e3cb8 re3038b4 50 50 } fncptr_t; 51 51 52 /* *<Formats for uintptr_t, size_t */52 /* Formats for uintptr_t, size_t */ 53 53 #define PRIp "llx" 54 54 #define PRIs "llu" 55 55 56 /* *<Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */56 /* Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */ 57 57 #define PRId8 "d" 58 58 #define PRId16 "d" -
kernel/arch/amd64/src/asm_utils.S
r05e3cb8 re3038b4 51 51 .global interrupt_handlers 52 52 .global syscall_entry 53 .global panic_printf54 55 panic_printf:56 movabsq $halt, %rax57 movq %rax, (%rsp)58 jmp printf59 60 53 .global cpuid 61 54 .global has_cpuid … … 234 227 save_all_gpr 235 228 cld 236 237 # Stop stack traces here 238 xorq %rbp, %rbp 239 240 movq $(\i), %rdi # %rdi - first parameter 241 movq %rsp, %rsi # %rsi - pointer to istate 242 call exc_dispatch # exc_dispatch(i, istate) 229 230 # 231 # Stop stack traces here if we came from userspace. 232 # 233 movq %cs, %rax 234 xorq %rdx, %rdx 235 cmpq %rax, IREGISTER_SPACE+16(%rsp) 236 cmovneq %rdx, %rbp 237 238 movq $(\i), %rdi # %rdi - first parameter 239 movq %rsp, %rsi # %rsi - pointer to istate 240 call exc_dispatch # exc_dispatch(i, istate) 243 241 244 242 restore_all_gpr … … 290 288 pushq %rcx 291 289 pushq %r11 292 293 movq %r10, %rcx # Copy the 4th argument where it is expected 290 pushq %rbp 291 292 xorq %rbp, %rbp # stop the stack traces here 293 294 movq %r10, %rcx # Copy the 4th argument where it is expected 294 295 pushq %rax 295 296 call syscall_handler 296 297 addq $8, %rsp 297 298 299 popq %rbp 298 300 popq %r11 299 301 popq %rcx -
kernel/arch/amd64/src/interrupt.c
r05e3cb8 re3038b4 63 63 void (* eoi_function)(void) = NULL; 64 64 65 void decode_istate(int n, istate_t *istate) 66 { 67 const char *symbol = symtab_fmt_name_lookup(istate->rip); 68 69 printf("-----EXCEPTION(%d) OCCURED----- ( %s )\n", n, __func__); 70 printf("%%rip: %#llx (%s)\n", istate->rip, symbol); 71 printf("ERROR_WORD=%#llx\n", istate->error_word); 72 printf("%%cs=%#llx, rflags=%#llx, %%cr0=%#llx\n", istate->cs, 73 istate->rflags, read_cr0()); 74 printf("%%rax=%#llx, %%rcx=%#llx, %%rdx=%#llx\n", istate->rax, 65 void istate_decode(istate_t *istate) 66 { 67 printf("error_word=%#llx\n", istate->error_word); 68 printf("cs =%#0.16llx\trflags=%#0.16llx\n", istate->cs, 69 istate->rflags); 70 printf("rax=%#0.16llx\trbx=%#0.16llx\trcx=%#0.16llx\n", istate->rax, 75 71 istate->rcx, istate->rdx); 76 printf(" %%rsi=%#llx, %%rdi=%#llx, %%r8=%#llx\n", istate->rsi,72 printf("rsi=%#0.16llx\trdi=%#0.16llx\tr8 =%#0.16llx\n", istate->rsi, 77 73 istate->rdi, istate->r8); 78 printf(" %%r9=%#llx, %%r10=%#llx, %%r11=%#llx\n", istate->r9,74 printf("r9 =%#0.16llx\tr10=%#0.16llx\tr11=%#0.16llx\n", istate->r9, 79 75 istate->r10, istate->r11); 80 printf("%%rsp=%#llx\n", &istate->stack[0]);81 82 stack_trace_istate(istate);83 76 } 84 77 … … 95 88 { 96 89 fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n); 97 decode_istate(n, istate); 98 panic("Unserviced interrupt."); 90 panic_badtrap(istate, n, "Unserviced interrupt."); 99 91 } 100 92 … … 102 94 { 103 95 fault_if_from_uspace(istate, "Divide error."); 104 decode_istate(n, istate); 105 panic("Divide error."); 96 panic_badtrap(istate, n, "Divide error."); 106 97 } 107 98 … … 129 120 fault_if_from_uspace(istate, "General protection fault."); 130 121 } 131 132 decode_istate(n, istate); 133 panic("General protection fault."); 122 panic_badtrap(istate, n, "General protection fault."); 134 123 } 135 124 … … 137 126 { 138 127 fault_if_from_uspace(istate, "Stack fault."); 139 decode_istate(n, istate); 140 panic("Stack fault."); 128 panic_badtrap(istate, n, "Stack fault."); 141 129 } 142 130 -
kernel/arch/amd64/src/mm/page.c
r05e3cb8 re3038b4 89 89 90 90 if (as_page_fault(page, access, istate) == AS_PF_FAULT) { 91 fault_if_from_uspace(istate, "Page fault: %p.", page); 92 decode_istate(n, istate); 93 panic("Page fault: %p", page); 91 fault_if_from_uspace(istate, "Page fault: %#x.", page); 92 panic_memtrap(istate, access, page, "Page fault."); 94 93 } 95 94 } -
kernel/arch/arm32/Makefile.inc
r05e3cb8 re3038b4 46 46 arch/$(KARCH)/src/context.S \ 47 47 arch/$(KARCH)/src/dummy.S \ 48 arch/$(KARCH)/src/panic.S \49 48 arch/$(KARCH)/src/cpu/cpu.c \ 50 49 arch/$(KARCH)/src/ddi/ddi.c \ -
kernel/arch/arm32/include/exception.h
r05e3cb8 re3038b4 28 28 */ 29 29 30 /** @addtogroup arm32 30 /** @addtogroup arm32 31 31 * @{ 32 32 */ … … 141 141 extern void install_exception_handlers(void); 142 142 extern void exception_init(void); 143 extern void print_istate(istate_t *istate);144 143 extern void reset_exception_entry(void); 145 144 extern void irq_exception_entry(void); -
kernel/arch/arm32/src/exc_handler.S
r05e3cb8 re3038b4 98 98 stmfd r13!, {r13, lr}^ 99 99 stmfd r13!, {r2} 100 101 # Stop stack traces here 102 mov fp, #0 103 100 104 b 2f 101 105 … … 123 127 stmfd r13!, {r2} 124 128 2: 125 # Stop stack traces here126 mov fp, #0127 129 .endm 128 130 -
kernel/arch/arm32/src/exception.c
r05e3cb8 re3038b4 173 173 * @param istate Structure to be printed. 174 174 */ 175 void print_istate(istate_t *istate)175 void istate_decode(istate_t *istate) 176 176 { 177 printf("istate dump:\n"); 178 179 printf(" r0: %x r1: %x r2: %x r3: %x\n", 177 printf("r0 =%#0.8lx\tr1 =%#0.8lx\tr2 =%#0.8lx\tr3 =%#0.8lx\n", 180 178 istate->r0, istate->r1, istate->r2, istate->r3); 181 printf(" r4: %x r5: %x r6: %x r7: %x\n",179 printf("r4 =%#0.8lx\tr5 =%#0.8lx\tr6 =%#0.8lx\tr7 =%#0.8lx\n", 182 180 istate->r4, istate->r5, istate->r6, istate->r7); 183 printf(" r8: %x r8: %x r10: %x fp: %x\n",181 printf("r8 =%#0.8lx\tr9 =%#0.8lx\tr10=%#0.8lx\tfp =%#0.8lx\n", 184 182 istate->r8, istate->r9, istate->r10, istate->fp); 185 printf(" r12: %x sp: %x lr: %x spsr: %x\n",183 printf("r12=%#0.8lx\tsp =%#0.8lx\tlr =%#0.8lx\tspsr=%#0.8lx\n", 186 184 istate->r12, istate->sp, istate->lr, istate->spsr); 187 188 printf(" pc: %x\n", istate->pc);189 190 stack_trace_istate(istate);191 185 } 192 186 -
kernel/arch/arm32/src/mm/page.c
r05e3cb8 re3038b4 27 27 */ 28 28 29 /** @addtogroup arm32mm 29 /** @addtogroup arm32mm 30 30 * @{ 31 31 */ -
kernel/arch/arm32/src/mm/page_fault.c
r05e3cb8 re3038b4 183 183 if (ret == AS_PF_FAULT) { 184 184 fault_if_from_uspace(istate, "Page fault: %#x.", badvaddr); 185 print_istate(istate); 186 printf("page fault - pc: %x, va: %x, status: %x(%x), " 187 "access:%d\n", istate->pc, badvaddr, fsr.status, fsr, 188 access); 189 190 panic("Page fault."); 185 panic_memtrap(istate, access, badvaddr, "Page fault."); 191 186 } 192 187 } … … 203 198 204 199 if (ret == AS_PF_FAULT) { 205 printf("prefetch_abort\n"); 206 print_istate(istate); 207 panic("page fault - prefetch_abort at address: %x.", 208 istate->pc); 200 panic_memtrap(istate, PF_ACCESS_EXEC, istate->pc, 201 "Page fault - prefetch_abort."); 209 202 } 210 203 } -
kernel/arch/ia32/Makefile.inc
r05e3cb8 re3038b4 76 76 ARCH_SOURCES = \ 77 77 arch/$(KARCH)/src/context.S \ 78 arch/$(KARCH)/src/debug/panic.s \79 78 arch/$(KARCH)/src/debug/stacktrace.c \ 80 79 arch/$(KARCH)/src/debug/stacktrace_asm.S \ -
kernel/arch/ia32/include/interrupt.h
r05e3cb8 re3038b4 113 113 extern void (* eoi_function)(void); 114 114 115 extern void decode_istate(istate_t *istate);116 115 extern void interrupt_init(void); 117 116 extern void trap_virtual_enable_irqs(uint16_t irqmask); -
kernel/arch/ia32/src/asm.S
r05e3cb8 re3038b4 163 163 pushl %edi # remember return user address 164 164 165 xorl %ebp, %ebp # stop stack traces here 166 165 167 pushl %gs # remember TLS 166 168 … … 196 198 # and call exc_dispatch(). 197 199 # 198 #define INTERRUPT_ALIGN 64200 #define INTERRUPT_ALIGN 128 199 201 .macro handler i n 200 202 … … 224 226 movw %ax, %ds 225 227 movw %ax, %es 226 228 229 xorl %ebp, %ebp 230 227 231 cld 228 232 sti … … 230 234 call syscall_handler 231 235 cli 232 addl $28, %esp # clean-up of parameters 236 237 movl 20(%esp), %ebp # restore EBP 238 addl $28, %esp # clean-up of parameters 233 239 234 240 popl %gs … … 280 286 movw %ax, %es 281 287 282 # stop stack traces here 288 # stop stack traces here if we came from userspace 289 cmpl $8, 40(%esp) 290 jz 0f 283 291 xorl %ebp, %ebp 284 292 293 0: 285 294 pushl %esp # *istate 286 295 pushl $(\i) # intnum -
kernel/arch/ia32/src/interrupt.c
r05e3cb8 re3038b4 63 63 void (* eoi_function)(void) = NULL; 64 64 65 void decode_istate(istate_t *istate) 66 { 67 const char *symbol = symtab_fmt_name_lookup(istate->eip); 68 69 if (CPU) 70 printf("----------------EXCEPTION OCCURED (cpu%u)----------------\n", CPU->id); 71 else 72 printf("----------------EXCEPTION OCCURED----------------\n"); 73 74 printf("%%eip: %#lx (%s)\n", istate->eip, symbol); 75 printf("ERROR_WORD=%#lx\n", istate->error_word); 76 printf("%%cs=%#lx,flags=%#lx\n", istate->cs, istate->eflags); 77 printf("%%eax=%#lx, %%ecx=%#lx, %%edx=%#lx, %%esp=%p\n", istate->eax, istate->ecx, istate->edx, &istate->stack[0]); 78 printf("stack: %#lx, %#lx, %#lx, %#lx\n", istate->stack[0], istate->stack[1], istate->stack[2], istate->stack[3]); 79 printf(" %#lx, %#lx, %#lx, %#lx\n", istate->stack[4], istate->stack[5], istate->stack[6], istate->stack[7]); 80 81 stack_trace_istate(istate); 65 void istate_decode(istate_t *istate) 66 { 67 printf("error_word=%#lx\n", istate->error_word); 68 printf("cs =%#0.8lx\teflags=%#0.8lx\n", istate->cs, istate->eflags); 69 printf("eax=%#0.8lx\tecx=%#0.8lx\tedx=%#0.8lx\n", 70 istate->eax, istate->ecx, istate->edx); 82 71 } 83 72 … … 94 83 { 95 84 fault_if_from_uspace(istate, "Unserviced interrupt: %u.", n); 96 97 decode_istate(istate); 98 panic("Unserviced interrupt: %u.", n); 85 panic_badtrap(istate, n, "Unserviced interrupt: %u.", n); 99 86 } 100 87 … … 102 89 { 103 90 fault_if_from_uspace(istate, "Divide error."); 104 105 decode_istate(istate); 106 panic("Divide error."); 91 panic_badtrap(istate, n, "Divide error."); 107 92 } 108 93 … … 128 113 fault_if_from_uspace(istate, "General protection fault."); 129 114 } 130 131 decode_istate(istate); 132 panic("General protection fault."); 115 panic_badtrap(istate, n, "General protection fault."); 133 116 } 134 117 … … 136 119 { 137 120 fault_if_from_uspace(istate, "Stack fault."); 138 139 decode_istate(istate); 140 panic("Stack fault."); 121 panic_badtrap(istate, n, "Stack fault."); 141 122 } 142 123 … … 149 130 ); 150 131 151 fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR : %#zx.",132 fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR=%#0.8x.", 152 133 (unative_t) mxcsr); 153 154 decode_istate(istate); 155 printf("MXCSR: %#lx\n", mxcsr); 156 panic("SIMD FP exception(19)."); 134 panic_badtrap(istate, n, "SIMD FP exception, MXCSR=%#0.8x"); 157 135 } 158 136 … … 164 142 #else 165 143 fault_if_from_uspace(istate, "FPU fault."); 166 panic ("FPU fault.");144 panic_badtrap(istate, n, "FPU fault."); 167 145 #endif 168 146 } -
kernel/arch/ia32/src/mm/page.c
r05e3cb8 re3038b4 115 115 if (as_page_fault(page, access, istate) == AS_PF_FAULT) { 116 116 fault_if_from_uspace(istate, "Page fault: %#x.", page); 117 118 decode_istate(istate); 119 printf("page fault address: %#lx\n", page); 120 panic("Page fault."); 117 panic_memtrap(istate, access, page, "Page fault."); 121 118 } 122 119 } -
kernel/arch/ia64/src/asm.S
r05e3cb8 re3038b4 137 137 br cpu_halt 138 138 139 .global panic_printf140 panic_printf:141 {142 br.call.sptk.many b0=printf143 }144 br halt145 146 139 /** Switch to userspace - low level code. 147 140 * -
kernel/arch/ia64/src/interrupt.c
r05e3cb8 re3038b4 133 133 } 134 134 135 static void dump_interrupted_context(istate_t *istate) 136 { 137 putchar('\n'); 138 printf("Interrupted context dump:\n"); 135 void istate_decode(istate_t *istate) 136 { 139 137 printf("ar.bsp=%p\tar.bspstore=%p\n", istate->ar_bsp, 140 138 istate->ar_bspstore); … … 183 181 184 182 fault_if_from_uspace(istate, "General Exception (%s).", desc); 185 186 dump_interrupted_context(istate); 187 panic("General Exception (%s).", desc); 183 panic_badtrap(istate, vector, "General Exception (%s).", desc); 188 184 } 189 185 … … 195 191 fault_if_from_uspace(istate, "Interruption: %#hx (%s).", 196 192 (uint16_t) vector, vector_to_string(vector)); 197 dump_interrupted_context(istate); 198 panic("Interruption: %#hx (%s).", (uint16_t) vector, 199 vector_to_string(vector)); 193 panic_badtrap(istate, vector, "Interruption: %#hx (%s).", 194 (uint16_t) vector, vector_to_string(vector)); 200 195 #endif 201 196 } … … 226 221 fault_if_from_uspace(istate, "Interruption: %#hx (%s).", 227 222 (uint16_t) vector, vector_to_string(vector)); 228 dump_interrupted_context(istate); 229 panic("Interruption: %#hx (%s).", (uint16_t) vector, 230 vector_to_string(vector)); 223 panic_badtrap(istate, vector, "Interruption: %#hx (%s).", 224 (uint16_t) vector, vector_to_string(vector)); 231 225 } 232 226 -
kernel/arch/ia64/src/mm/tlb.c
r05e3cb8 re3038b4 500 500 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 501 501 fault_if_from_uspace(istate, "Page fault at %p.", va); 502 panic ("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,503 istate->cr_iip);502 panic_memtrap(istate, PF_ACCESS_EXEC, va, 503 "Page fault."); 504 504 } 505 505 } … … 622 622 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 623 623 fault_if_from_uspace(istate, "Page fault at %p.", va); 624 panic ("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,625 istate->cr_iip);624 panic_memtrap(istate, PF_ACCESS_READ, va, 625 "Page fault."); 626 626 } 627 627 } … … 671 671 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 672 672 fault_if_from_uspace(istate, "Page fault at %p.", va); 673 panic ("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,674 istate->cr_iip);673 panic_memtrap(istate, PF_ACCESS_WRITE, va, 674 "Page fault."); 675 675 } 676 676 } … … 708 708 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 709 709 fault_if_from_uspace(istate, "Page fault at %p.", va); 710 panic ("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,711 istate->cr_iip);710 panic_memtrap(istate, PF_ACCESS_EXEC, va, 711 "Page fault."); 712 712 } 713 713 } … … 745 745 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 746 746 fault_if_from_uspace(istate, "Page fault at %p.", va); 747 panic ("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid,748 istate->cr_iip);747 panic_memtrap(istate, PF_ACCESS_READ, va, 748 "Page fault."); 749 749 } 750 750 } … … 778 778 if (as_page_fault(va, PF_ACCESS_WRITE, istate) == AS_PF_FAULT) { 779 779 fault_if_from_uspace(istate, "Page fault at %p.", va); 780 panic("%s: va=%p, rid=%d, iip=%p.", __func__, va, rid, 781 istate->cr_iip); 780 panic_memtrap(istate, PF_ACCESS_WRITE, va, "Page fault."); 782 781 } 783 782 page_table_unlock(AS, true); … … 819 818 if (as_page_fault(va, PF_ACCESS_READ, istate) == AS_PF_FAULT) { 820 819 fault_if_from_uspace(istate, "Page fault at %p.", va); 821 panic("%s: va=%p, rid=%d.", __func__, va, rid); 820 panic_memtrap(istate, PF_ACCESS_READ, va, 821 "Page fault."); 822 822 } 823 823 } -
kernel/arch/mips32/Makefile.inc
r05e3cb8 re3038b4 54 54 arch/$(KARCH)/src/start.S \ 55 55 arch/$(KARCH)/src/context.S \ 56 arch/$(KARCH)/src/panic.S \57 56 arch/$(KARCH)/src/mips32.c \ 58 57 arch/$(KARCH)/src/asm.S \ -
kernel/arch/mips32/src/exception.c
r05e3cb8 re3038b4 72 72 }; 73 73 74 static void print_regdump(istate_t *istate) 75 { 76 printf("PC: %#x(%s) RA: %#x(%s), SP(%p)\n", istate->epc, 77 symtab_fmt_name_lookup(istate->epc), istate->ra, 78 symtab_fmt_name_lookup(istate->ra), istate->sp); 74 void istate_decode(istate_t *istate) 75 { 76 printf("at=%p\tv0=%p\tv1=%p\n", istate->at, istate->v0, istate->v1); 77 printf("a0=%p\ta1=%p\ta2=%p\n", istate->a0, istate->a1, istate->a2); 78 printf("a3=%p\tt0=%p\tt1=%p\n", istate->a3, istate->t0, istate->t1); 79 printf("t2=%p\tt3=%p\tt4=%p\n", istate->t2, istate->t3, istate->t4); 80 printf("t5=%p\tt6=%p\tt7=%p\n", istate->t5, istate->t6, istate->t7); 81 printf("t8=%p\tt9=%p\tgp=%p\n", istate->t8, istate->t9, istate->gp); 82 printf("sp=%p\tra=%p\t\n", istate->sp, istate->ra); 83 printf("lo=%p\thi=%p\t\n", istate->lo, istate->hi); 84 printf("cp0_status=%p\tcp0_epc=%p\tk1=%p\n", 85 istate->status, istate->epc, istate->k1); 79 86 } 80 87 … … 82 89 { 83 90 fault_if_from_uspace(istate, "Unhandled exception %s.", exctable[n]); 84 85 print_regdump(istate); 86 panic("Unhandled exception %s.", exctable[n]); 91 panic_badtrap(istate, n, "Unhandled exception %s.", exctable[n]); 87 92 } 88 93 … … 125 130 scheduler_fpu_lazy_request(); 126 131 else { 127 fault_if_from_uspace(istate, "Unhandled Coprocessor Unusable Exception."); 128 panic("Unhandled Coprocessor Unusable Exception."); 132 fault_if_from_uspace(istate, 133 "Unhandled Coprocessor Unusable Exception."); 134 panic_badtrap(istate, n, 135 "Unhandled Coprocessor Unusable Exception."); 129 136 } 130 137 } … … 162 169 static void syscall_exception(unsigned int n, istate_t *istate) 163 170 { 164 panic("Syscall is handled through shortcut.");171 fault_if_from_uspace(istate, "Syscall is handled through shortcut."); 165 172 } 166 173 -
kernel/arch/mips32/src/mm/tlb.c
r05e3cb8 re3038b4 321 321 void tlb_refill_fail(istate_t *istate) 322 322 { 323 const char *symbol = symtab_fmt_name_lookup(istate->epc); 324 const char *sym2 = symtab_fmt_name_lookup(istate->ra); 325 326 fault_if_from_uspace(istate, "TLB Refill Exception on %p.", 327 cp0_badvaddr_read()); 328 panic("%x: TLB Refill Exception at %x (%s<-%s).", cp0_badvaddr_read(), 329 istate->epc, symbol, sym2); 323 uintptr_t va = cp0_badvaddr_read(); 324 325 fault_if_from_uspace(istate, "TLB Refill Exception on %p.", va); 326 panic_memtrap(istate, PF_ACCESS_READ, va, "TLB Refill Exception."); 330 327 } 331 328 … … 333 330 void tlb_invalid_fail(istate_t *istate) 334 331 { 335 const char *symbol = symtab_fmt_name_lookup(istate->epc); 336 337 fault_if_from_uspace(istate, "TLB Invalid Exception on %p.", 338 cp0_badvaddr_read()); 339 panic("%x: TLB Invalid Exception at %x (%s).", cp0_badvaddr_read(), 340 istate->epc, symbol); 332 uintptr_t va = cp0_badvaddr_read(); 333 334 fault_if_from_uspace(istate, "TLB Invalid Exception on %p.", va); 335 panic_memtrap(istate, PF_ACCESS_READ, va, "TLB Invalid Exception."); 341 336 } 342 337 343 338 void tlb_modified_fail(istate_t *istate) 344 339 { 345 const char *symbol = symtab_fmt_name_lookup(istate->epc); 346 347 fault_if_from_uspace(istate, "TLB Modified Exception on %p.", 348 cp0_badvaddr_read()); 349 panic("%x: TLB Modified Exception at %x (%s).", cp0_badvaddr_read(), 350 istate->epc, symbol); 340 uintptr_t va = cp0_badvaddr_read(); 341 342 fault_if_from_uspace(istate, "TLB Modified Exception on %p.", va); 343 panic_memtrap(istate, PF_ACCESS_WRITE, va, "TLB Modified Exception."); 351 344 } 352 345 -
kernel/arch/ppc32/Makefile.inc
r05e3cb8 re3038b4 40 40 ARCH_SOURCES = \ 41 41 arch/$(KARCH)/src/context.S \ 42 arch/$(KARCH)/src/debug/panic.s \43 42 arch/$(KARCH)/src/debug/stacktrace.c \ 44 43 arch/$(KARCH)/src/debug/stacktrace_asm.S \ -
kernel/arch/ppc32/include/types.h
r05e3cb8 re3038b4 50 50 } fncptr_t; 51 51 52 /** <Formats for uintptr_t, size_t */52 /** Formats for uintptr_t, size_t */ 53 53 #define PRIp "x" 54 54 #define PRIs "u" 55 55 56 /** <Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */56 /** Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */ 57 57 #define PRId8 "d" 58 58 #define PRId16 "d" -
kernel/arch/ppc32/src/interrupt.c
r05e3cb8 re3038b4 50 50 :: [dec] "r" (1000) 51 51 ); 52 } 53 54 void istate_decode(istate_t *istate) 55 { 56 printf("r0 =%p\tr1 =%p\tr2 =%p\n", istate->r0, istate->sp, istate->r2); 57 printf("r3 =%p\tr4 =%p\tr5 =%p\n", istate->r3, istate->r4, istate->r5); 58 printf("r6 =%p\tr7 =%p\tr8 =%p\n", istate->r6, istate->r7, istate->r8); 59 printf("r9 =%p\tr10=%p\tr11=%p\n", 60 istate->r9, istate->r10, istate->r11); 61 printf("r12=%p\tr13=%p\tr14=%p\n", 62 istate->r12, istate->r13, istate->r14); 63 printf("r15=%p\tr16=%p\tr17=%p\n", 64 istate->r15, istate->r16, istate->r17); 65 printf("r18=%p\tr19=%p\tr20=%p\n", 66 istate->r18, istate->r19, istate->r20); 67 printf("r21=%p\tr22=%p\tr23=%p\n", 68 istate->r21, istate->r22, istate->r23); 69 printf("r24=%p\tr25=%p\tr26=%p\n", 70 istate->r24, istate->r25, istate->r26); 71 printf("r27=%p\tr28=%p\tr29=%p\n", 72 istate->r27, istate->r28, istate->r29); 73 printf("r30=%p\tr31=%p\n", istate->r30, istate->r31); 74 printf("cr =%p\tpc =%p\tlr =%p\n", istate->cr, istate->pc, istate->lr); 75 printf("ctr=%p\txer=%p\tdar=%p\n", 76 istate->ctr, istate->xer, istate->dar); 77 printf("srr1=%p\n", istate->srr1); 52 78 } 53 79 -
kernel/arch/ppc32/src/mm/tlb.c
r05e3cb8 re3038b4 111 111 static void pht_refill_fail(uintptr_t badvaddr, istate_t *istate) 112 112 { 113 const char *symbol = symtab_fmt_name_lookup(istate->pc); 114 const char *sym2 = symtab_fmt_name_lookup(istate->lr); 115 116 fault_if_from_uspace(istate, 117 "PHT Refill Exception on %p.", badvaddr); 118 panic("%p: PHT Refill Exception at %p (%s<-%s).", badvaddr, 119 istate->pc, symbol, sym2); 113 fault_if_from_uspace(istate, "PHT Refill Exception on %p.", badvaddr); 114 panic_memtrap(istate, PF_ACCESS_READ, badvaddr, 115 "PHT Refill Exception."); 120 116 } 121 117 -
kernel/arch/sparc64/Makefile.inc
r05e3cb8 re3038b4 64 64 arch/$(KARCH)/src/asm.S \ 65 65 arch/$(KARCH)/src/$(USARCH)/asm.S \ 66 arch/$(KARCH)/src/panic.S \67 66 arch/$(KARCH)/src/console.c \ 68 67 arch/$(KARCH)/src/context.S \ -
kernel/arch/sparc64/include/types.h
r05e3cb8 re3038b4 52 52 typedef uint8_t asi_t; 53 53 54 /** <Formats for uintptr_t, size_t */54 /** Formats for uintptr_t, size_t */ 55 55 #define PRIp "llx" 56 56 #define PRIs "llu" 57 57 58 /** <Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */58 /** Formats for (u)int8_t, (u)int16_t, (u)int32_t, (u)int64_t and (u)native_t */ 59 59 #define PRId8 "d" 60 60 #define PRId16 "d" -
kernel/arch/sparc64/src/mm/sun4u/tlb.c
r05e3cb8 re3038b4 27 27 */ 28 28 29 /** @addtogroup sparc64mm 29 /** @addtogroup sparc64mm 30 30 * @{ 31 31 */ … … 58 58 static void dtlb_pte_copy(pte_t *, size_t, bool); 59 59 static void itlb_pte_copy(pte_t *, size_t); 60 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, const char *); 60 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, uintptr_t, 61 const char *); 61 62 static void do_fast_data_access_mmu_miss_fault(istate_t *, tlb_tag_access_reg_t, 62 63 const char *); … … 222 223 * Forward the page fault to the address space page fault 223 224 * handler. 224 */ 225 */ 225 226 page_table_unlock(AS, true); 226 227 if (as_page_fault(page_16k, PF_ACCESS_EXEC, istate) == 227 228 AS_PF_FAULT) { 228 229 do_fast_instruction_access_mmu_miss_fault(istate, 229 __func__);230 istate->tpc, __func__); 230 231 } 231 232 } … … 258 259 /* NULL access in kernel */ 259 260 do_fast_data_access_mmu_miss_fault(istate, tag, 260 __func__);261 "Dereferencing NULL pointer"); 261 262 } else if (page_8k >= end_of_identity) { 262 263 /* … … 438 439 439 440 void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, 440 const char *str) 441 { 442 fault_if_from_uspace(istate, "%s.", str); 443 dump_istate(istate); 444 panic("%s.", str); 441 uintptr_t va, const char *str) 442 { 443 fault_if_from_uspace(istate, "%s, Address=%p.", str, va); 444 panic_memtrap(istate, PF_ACCESS_EXEC, va, "%s.", str); 445 445 } 446 446 … … 451 451 452 452 va = tag.vpn << MMU_PAGE_WIDTH; 453 if (tag.context) { 454 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 455 tag.context); 456 } 457 dump_istate(istate); 458 printf("Faulting page: %p, ASID=%d.\n", va, tag.context); 459 panic("%s.", str); 453 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 454 tag.context); 455 panic_memtrap(istate, PF_ACCESS_READ, va, "%s.", str); 460 456 } 461 457 … … 466 462 467 463 va = tag.vpn << MMU_PAGE_WIDTH; 468 469 if (tag.context) { 470 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 471 tag.context); 472 } 473 printf("Faulting page: %p, ASID=%d\n", va, tag.context); 474 dump_istate(istate); 475 panic("%s.", str); 464 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, va, 465 tag.context); 466 panic_memtrap(istate, PF_ACCESS_WRITE, va, "%s.", str); 476 467 } 477 468 -
kernel/arch/sparc64/src/mm/sun4v/tlb.c
r05e3cb8 re3038b4 28 28 */ 29 29 30 /** @addtogroup sparc64mm 30 /** @addtogroup sparc64mm 31 31 * @{ 32 32 */ … … 62 62 static void itlb_pte_copy(pte_t *); 63 63 static void dtlb_pte_copy(pte_t *, bool); 64 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, const char *); 64 static void do_fast_instruction_access_mmu_miss_fault(istate_t *, uintptr_t, 65 const char *); 65 66 static void do_fast_data_access_mmu_miss_fault(istate_t *, uint64_t, 66 67 const char *); … … 235 236 * Forward the page fault to the address space page fault 236 237 * handler. 237 */ 238 */ 238 239 page_table_unlock(AS, true); 239 240 if (as_page_fault(va, PF_ACCESS_EXEC, istate) == AS_PF_FAULT) { 240 241 do_fast_instruction_access_mmu_miss_fault(istate, 241 __func__);242 istate->tpc, __func__); 242 243 } 243 244 } … … 354 355 } 355 356 356 void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, 357 void do_fast_instruction_access_mmu_miss_fault(istate_t *istate, uintptr_t va, 357 358 const char *str) 358 359 { 359 fault_if_from_uspace(istate, "%s.", str); 360 dump_istate(istate); 361 panic("%s.", str); 360 fault_if_from_uspace(istate, "%s, Address=%p.", str, va); 361 panic_memtrap(istate, PF_ACCESS_EXEC, va, "%s.", str); 362 362 } 363 363 … … 365 365 uint64_t page_and_ctx, const char *str) 366 366 { 367 if (DMISS_CONTEXT(page_and_ctx)) { 368 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d)\n", str, DMISS_ADDRESS(page_and_ctx), 369 DMISS_CONTEXT(page_and_ctx)); 370 } 371 dump_istate(istate); 372 printf("Faulting page: %p, ASID=%d\n", DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx)); 373 panic("%s\n", str); 367 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, 368 DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx)); 369 panic_memtrap(istate, PF_ACCESS_READ, DMISS_ADDRESS(page_and_ctx), 370 "%s."); 374 371 } 375 372 … … 377 374 uint64_t page_and_ctx, const char *str) 378 375 { 379 if (DMISS_CONTEXT(page_and_ctx)) { 380 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d)\n", str, DMISS_ADDRESS(page_and_ctx), 381 DMISS_CONTEXT(page_and_ctx)); 382 } 383 printf("Faulting page: %p, ASID=%d\n", DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx)); 384 dump_istate(istate); 385 panic("%s\n", str); 376 fault_if_from_uspace(istate, "%s, Page=%p (ASID=%d).", str, 377 DMISS_ADDRESS(page_and_ctx), DMISS_CONTEXT(page_and_ctx)); 378 panic_memtrap(istate, PF_ACCESS_WRITE, DMISS_ADDRESS(page_and_ctx), 379 "%s."); 386 380 } 387 381 -
kernel/arch/sparc64/src/trap/exception.c
r05e3cb8 re3038b4 44 44 #include <symtab.h> 45 45 46 void dump_istate(istate_t *istate)46 void istate_decode(istate_t *istate) 47 47 { 48 48 const char *tpcs = symtab_fmt_name_lookup(istate->tpc); … … 58 58 { 59 59 fault_if_from_uspace(istate, "%s.", __func__); 60 dump_istate(istate); 61 panic("%s.", __func__); 60 panic_badtrap(istate, n, "%s.", __func__); 62 61 } 63 62 … … 66 65 { 67 66 fault_if_from_uspace(istate, "%s.", __func__); 68 dump_istate(istate); 69 panic("%s.", __func__); 67 panic_badtrap(istate, n, "%s.", __func__); 70 68 } 71 69 … … 74 72 { 75 73 fault_if_from_uspace(istate, "%s.", __func__); 76 dump_istate(istate); 77 panic("%s.", __func__); 74 panic_badtrap(istate, n, "%s.", __func__); 78 75 } 79 76 … … 82 79 { 83 80 fault_if_from_uspace(istate, "%s.", __func__); 84 dump_istate(istate); 85 panic("%s.", __func__); 81 panic_badtrap(istate, n, "%s.", __func__); 86 82 } 87 83 … … 90 86 { 91 87 fault_if_from_uspace(istate, "%s.", __func__); 92 dump_istate(istate); 93 panic("%s.", __func__); 88 panic_badtrap(istate, n, "%s.", __func__); 94 89 } 95 90 … … 98 93 { 99 94 fault_if_from_uspace(istate, "%s.", __func__); 100 dump_istate(istate); 101 panic("%s.", __func__); 95 panic_badtrap(istate, n, "%s.", __func__); 102 96 } 103 97 … … 118 112 #else 119 113 fault_if_from_uspace(istate, "%s.", __func__); 120 dump_istate(istate); 121 panic("%s.", __func__); 114 panic_badtrap(istate, n, "%s.", __func__); 122 115 #endif 123 116 } … … 127 120 { 128 121 fault_if_from_uspace(istate, "%s.", __func__); 129 dump_istate(istate); 130 panic("%s.", __func__); 122 panic_badtrap(istate, n, "%s.", __func__); 131 123 } 132 124 … … 135 127 { 136 128 fault_if_from_uspace(istate, "%s.", __func__); 137 dump_istate(istate); 138 panic("%s.", __func__); 129 panic_badtrap(istate, n, "%s.", __func__); 139 130 } 140 131 … … 143 134 { 144 135 fault_if_from_uspace(istate, "%s.", __func__); 145 dump_istate(istate); 146 panic("%s.", __func__); 136 panic_badtrap(istate, n, "%s.", __func__); 147 137 } 148 138 … … 151 141 { 152 142 fault_if_from_uspace(istate, "%s.", __func__); 153 dump_istate(istate); 154 panic("%s.", __func__); 143 panic_badtrap(istate, n, "%s.", __func__); 155 144 } 156 145 … … 159 148 { 160 149 fault_if_from_uspace(istate, "%s.", __func__); 161 dump_istate(istate); 162 describe_dmmu_fault(); 163 panic("%s.", __func__); 150 panic_badtrap(istate, n, "%s.", __func__); 164 151 } 165 152 … … 168 155 { 169 156 fault_if_from_uspace(istate, "%s.", __func__); 170 dump_istate(istate); 171 panic("%s.", __func__); 157 panic_badtrap(istate, n, "%s.", __func__); 172 158 } 173 159 … … 176 162 { 177 163 fault_if_from_uspace(istate, "%s.", __func__); 178 dump_istate(istate); 179 panic("%s.", __func__); 164 panic_badtrap(istate, n, "%s.", __func__); 180 165 } 181 166 … … 184 169 { 185 170 fault_if_from_uspace(istate, "%s.", __func__); 186 dump_istate(istate); 187 panic("%s.", __func__); 171 panic_badtrap(istate, n, "%s.", __func__); 188 172 } 189 173 … … 192 176 { 193 177 fault_if_from_uspace(istate, "%s.", __func__); 194 dump_istate(istate); 195 panic("%s.", __func__); 178 panic_badtrap(istate, n, "%s.", __func__); 196 179 } 197 180 … … 200 183 { 201 184 fault_if_from_uspace(istate, "%s.", __func__); 202 dump_istate(istate); 203 panic("%s.", __func__); 185 panic_badtrap(istate, n, "%s.", __func__); 204 186 } 205 187 … … 208 190 { 209 191 fault_if_from_uspace(istate, "%s.", __func__); 210 dump_istate(istate); 211 panic("%s.", __func__); 192 panic_badtrap(istate, n, "%s.", __func__); 212 193 } 213 194 … … 216 197 { 217 198 fault_if_from_uspace(istate, "%s.", __func__); 218 dump_istate(istate); 219 panic("%s.", __func__); 199 panic_badtrap(istate, n, "%s.", __func__); 220 200 } 221 201 -
kernel/generic/include/debug.h
r05e3cb8 re3038b4 55 55 do { \ 56 56 if (!(expr)) \ 57 panic ("Assertion failed (%s)", #expr); \57 panic_assert("%s", #expr); \ 58 58 } while (0) 59 59 … … 72 72 do { \ 73 73 if (!(expr)) \ 74 panic ("Assertion failed (%s, %s)", #expr, msg); \74 panic_assert("%s, %s", #expr, msg); \ 75 75 } while (0) 76 76 -
kernel/generic/include/interrupt.h
r05e3cb8 re3038b4 64 64 extern void irq_initialize_arch(irq_t *); 65 65 66 extern void istate_decode(istate_t *); 67 66 68 #endif 67 69 -
kernel/generic/include/panic.h
r05e3cb8 re3038b4 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 37 37 38 38 #include <typedefs.h> 39 #include <stacktrace.h>40 #include <print.h>41 39 42 #ifdef CONFIG_DEBUG 40 #define panic(fmt, ...) \ 41 panic_common(PANIC_OTHER, NULL, 0, 0, fmt, ##__VA_ARGS__) 43 42 44 #define panic(format, ...) \ 45 do { \ 46 silent = false; \ 47 printf("Kernel panic in %s() at %s:%u\n", \ 48 __func__, __FILE__, __LINE__); \ 49 stack_trace(); \ 50 panic_printf("Panic message: " format "\n", \ 51 ##__VA_ARGS__);\ 52 } while (0) 43 #define panic_assert(fmt, ...) \ 44 panic_common(PANIC_ASSERT, NULL, 0, 0, fmt, ##__VA_ARGS__) 53 45 54 #else /* CONFIG_DEBUG */ 46 #define panic_badtrap(istate, n, fmt, ...) \ 47 panic_common(PANIC_BADTRAP, istate, 0, n, fmt, ##__VA_ARGS__) 55 48 56 #define panic(format, ...) \ 57 do { \ 58 silent = false; \ 59 panic_printf("Kernel panic: " format "\n", ##__VA_ARGS__); \ 60 stack_trace(); \ 61 } while (0) 49 #define panic_memtrap(istate, access, addr, fmt, ...) \ 50 panic_common(PANIC_MEMTRAP, istate, access, addr, fmt, ##__VA_ARGS__) 62 51 63 #endif /* CONFIG_DEBUG */ 52 typedef enum { 53 PANIC_OTHER, 54 PANIC_ASSERT, 55 PANIC_BADTRAP, 56 PANIC_MEMTRAP 57 } panic_category_t; 58 59 struct istate; 64 60 65 61 extern bool silent; 66 62 67 extern void panic_printf(const char *fmt, ...) __attribute__((noreturn)); 63 extern void panic_common(panic_category_t, struct istate *, int, 64 uintptr_t, const char *, ...) __attribute__ ((noreturn)); 68 65 69 66 #endif -
kernel/generic/src/debug/stacktrace.c
r05e3cb8 re3038b4 37 37 #include <typedefs.h> 38 38 #include <symtab.h> 39 #include <print.h> 39 40 40 41 #define STACK_FRAMES_MAX 20
Note:
See TracChangeset
for help on using the changeset viewer.