traps.c (c818c778b0384e5d9e8184ec43b73e05a7ced86f) | traps.c (ba12eedee321eeb5baecaada285daeb3462c35f5) |
---|---|
1/* 2 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright 2007-2010 Freescale Semiconductor, Inc. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 8 * 2 of the License, or (at your option) any later version. --- 21 unchanged lines hidden (view full) --- 30#include <linux/delay.h> 31#include <linux/kprobes.h> 32#include <linux/kexec.h> 33#include <linux/backlight.h> 34#include <linux/bug.h> 35#include <linux/kdebug.h> 36#include <linux/debugfs.h> 37#include <linux/ratelimit.h> | 1/* 2 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 3 * Copyright 2007-2010 Freescale Semiconductor, Inc. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 8 * 2 of the License, or (at your option) any later version. --- 21 unchanged lines hidden (view full) --- 30#include <linux/delay.h> 31#include <linux/kprobes.h> 32#include <linux/kexec.h> 33#include <linux/backlight.h> 34#include <linux/bug.h> 35#include <linux/kdebug.h> 36#include <linux/debugfs.h> 37#include <linux/ratelimit.h> |
38#include <linux/context_tracking.h> |
|
38 39#include <asm/emulated_ops.h> 40#include <asm/pgtable.h> 41#include <asm/uaccess.h> 42#include <asm/io.h> 43#include <asm/machdep.h> 44#include <asm/rtas.h> 45#include <asm/pmc.h> --- 616 unchanged lines hidden (view full) --- 662 printk("Unknown values in msr\n"); 663 } 664 return 0; 665} 666#endif /* everything else */ 667 668void machine_check_exception(struct pt_regs *regs) 669{ | 39 40#include <asm/emulated_ops.h> 41#include <asm/pgtable.h> 42#include <asm/uaccess.h> 43#include <asm/io.h> 44#include <asm/machdep.h> 45#include <asm/rtas.h> 46#include <asm/pmc.h> --- 616 unchanged lines hidden (view full) --- 663 printk("Unknown values in msr\n"); 664 } 665 return 0; 666} 667#endif /* everything else */ 668 669void machine_check_exception(struct pt_regs *regs) 670{ |
671 enum ctx_state prev_state = exception_enter(); |
|
670 int recover = 0; 671 672 __get_cpu_var(irq_stat).mce_exceptions++; 673 674 /* See if any machine dependent calls. In theory, we would want 675 * to call the CPU first, and call the ppc_md. one if the CPU 676 * one returns a positive number. However there is existing code 677 * that assumes the board gets a first chance, so let's keep it 678 * that way for now and fix things later. --BenH. 679 */ 680 if (ppc_md.machine_check_exception) 681 recover = ppc_md.machine_check_exception(regs); 682 else if (cur_cpu_spec->machine_check) 683 recover = cur_cpu_spec->machine_check(regs); 684 685 if (recover > 0) | 672 int recover = 0; 673 674 __get_cpu_var(irq_stat).mce_exceptions++; 675 676 /* See if any machine dependent calls. In theory, we would want 677 * to call the CPU first, and call the ppc_md. one if the CPU 678 * one returns a positive number. However there is existing code 679 * that assumes the board gets a first chance, so let's keep it 680 * that way for now and fix things later. --BenH. 681 */ 682 if (ppc_md.machine_check_exception) 683 recover = ppc_md.machine_check_exception(regs); 684 else if (cur_cpu_spec->machine_check) 685 recover = cur_cpu_spec->machine_check(regs); 686 687 if (recover > 0) |
686 return; | 688 goto bail; |
687 688#if defined(CONFIG_8xx) && defined(CONFIG_PCI) 689 /* the qspan pci read routines can cause machine checks -- Cort 690 * 691 * yuck !!! that totally needs to go away ! There are better ways 692 * to deal with that than having a wart in the mcheck handler. 693 * -- BenH 694 */ 695 bad_page_fault(regs, regs->dar, SIGBUS); | 689 690#if defined(CONFIG_8xx) && defined(CONFIG_PCI) 691 /* the qspan pci read routines can cause machine checks -- Cort 692 * 693 * yuck !!! that totally needs to go away ! There are better ways 694 * to deal with that than having a wart in the mcheck handler. 695 * -- BenH 696 */ 697 bad_page_fault(regs, regs->dar, SIGBUS); |
696 return; | 698 goto bail; |
697#endif 698 699 if (debugger_fault_handler(regs)) | 699#endif 700 701 if (debugger_fault_handler(regs)) |
700 return; | 702 goto bail; |
701 702 if (check_io_access(regs)) | 703 704 if (check_io_access(regs)) |
703 return; | 705 goto bail; |
704 705 die("Machine check", regs, SIGBUS); 706 707 /* Must die if the interrupt is not recoverable */ 708 if (!(regs->msr & MSR_RI)) 709 panic("Unrecoverable Machine check"); | 706 707 die("Machine check", regs, SIGBUS); 708 709 /* Must die if the interrupt is not recoverable */ 710 if (!(regs->msr & MSR_RI)) 711 panic("Unrecoverable Machine check"); |
712 713bail: 714 exception_exit(prev_state); |
|
710} 711 712void SMIException(struct pt_regs *regs) 713{ 714 die("System Management Interrupt", regs, SIGABRT); 715} 716 717void unknown_exception(struct pt_regs *regs) 718{ | 715} 716 717void SMIException(struct pt_regs *regs) 718{ 719 die("System Management Interrupt", regs, SIGABRT); 720} 721 722void unknown_exception(struct pt_regs *regs) 723{ |
724 enum ctx_state prev_state = exception_enter(); 725 |
|
719 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 720 regs->nip, regs->msr, regs->trap); 721 722 _exception(SIGTRAP, regs, 0, 0); | 726 printk("Bad trap at PC: %lx, SR: %lx, vector=%lx\n", 727 regs->nip, regs->msr, regs->trap); 728 729 _exception(SIGTRAP, regs, 0, 0); |
730 731 exception_exit(prev_state); |
|
723} 724 725void instruction_breakpoint_exception(struct pt_regs *regs) 726{ | 732} 733 734void instruction_breakpoint_exception(struct pt_regs *regs) 735{ |
736 enum ctx_state prev_state = exception_enter(); 737 |
|
727 if (notify_die(DIE_IABR_MATCH, "iabr_match", regs, 5, 728 5, SIGTRAP) == NOTIFY_STOP) | 738 if (notify_die(DIE_IABR_MATCH, "iabr_match", regs, 5, 739 5, SIGTRAP) == NOTIFY_STOP) |
729 return; | 740 goto bail; |
730 if (debugger_iabr_match(regs)) | 741 if (debugger_iabr_match(regs)) |
731 return; | 742 goto bail; |
732 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); | 743 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); |
744 745bail: 746 exception_exit(prev_state); |
|
733} 734 735void RunModeException(struct pt_regs *regs) 736{ 737 _exception(SIGTRAP, regs, 0, 0); 738} 739 740void __kprobes single_step_exception(struct pt_regs *regs) 741{ | 747} 748 749void RunModeException(struct pt_regs *regs) 750{ 751 _exception(SIGTRAP, regs, 0, 0); 752} 753 754void __kprobes single_step_exception(struct pt_regs *regs) 755{ |
756 enum ctx_state prev_state = exception_enter(); 757 |
|
742 clear_single_step(regs); 743 744 if (notify_die(DIE_SSTEP, "single_step", regs, 5, 745 5, SIGTRAP) == NOTIFY_STOP) | 758 clear_single_step(regs); 759 760 if (notify_die(DIE_SSTEP, "single_step", regs, 5, 761 5, SIGTRAP) == NOTIFY_STOP) |
746 return; | 762 goto bail; |
747 if (debugger_sstep(regs)) | 763 if (debugger_sstep(regs)) |
748 return; | 764 goto bail; |
749 750 _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip); | 765 766 _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip); |
767 768bail: 769 exception_exit(prev_state); |
|
751} 752 753/* 754 * After we have successfully emulated an instruction, we have to 755 * check if the instruction was being single-stepped, and if so, 756 * pretend we got a single-step exception. This was pointed out 757 * by Kumar Gala. -- paulus 758 */ --- 241 unchanged lines hidden (view full) --- 1000 1001int is_valid_bugaddr(unsigned long addr) 1002{ 1003 return is_kernel_addr(addr); 1004} 1005 1006void __kprobes program_check_exception(struct pt_regs *regs) 1007{ | 770} 771 772/* 773 * After we have successfully emulated an instruction, we have to 774 * check if the instruction was being single-stepped, and if so, 775 * pretend we got a single-step exception. This was pointed out 776 * by Kumar Gala. -- paulus 777 */ --- 241 unchanged lines hidden (view full) --- 1019 1020int is_valid_bugaddr(unsigned long addr) 1021{ 1022 return is_kernel_addr(addr); 1023} 1024 1025void __kprobes program_check_exception(struct pt_regs *regs) 1026{ |
1027 enum ctx_state prev_state = exception_enter(); |
|
1008 unsigned int reason = get_reason(regs); 1009 extern int do_mathemu(struct pt_regs *regs); 1010 1011 /* We can now get here via a FP Unavailable exception if the core 1012 * has no FPU, in that case the reason flags will be 0 */ 1013 1014 if (reason & REASON_FP) { 1015 /* IEEE FP exception */ 1016 parse_fpe(regs); | 1028 unsigned int reason = get_reason(regs); 1029 extern int do_mathemu(struct pt_regs *regs); 1030 1031 /* We can now get here via a FP Unavailable exception if the core 1032 * has no FPU, in that case the reason flags will be 0 */ 1033 1034 if (reason & REASON_FP) { 1035 /* IEEE FP exception */ 1036 parse_fpe(regs); |
1017 return; | 1037 goto bail; |
1018 } 1019 if (reason & REASON_TRAP) { 1020 /* Debugger is first in line to stop recursive faults in 1021 * rcu_lock, notify_die, or atomic_notifier_call_chain */ 1022 if (debugger_bpt(regs)) | 1038 } 1039 if (reason & REASON_TRAP) { 1040 /* Debugger is first in line to stop recursive faults in 1041 * rcu_lock, notify_die, or atomic_notifier_call_chain */ 1042 if (debugger_bpt(regs)) |
1023 return; | 1043 goto bail; |
1024 1025 /* trap exception */ 1026 if (notify_die(DIE_BPT, "breakpoint", regs, 5, 5, SIGTRAP) 1027 == NOTIFY_STOP) | 1044 1045 /* trap exception */ 1046 if (notify_die(DIE_BPT, "breakpoint", regs, 5, 5, SIGTRAP) 1047 == NOTIFY_STOP) |
1028 return; | 1048 goto bail; |
1029 1030 if (!(regs->msr & MSR_PR) && /* not user-mode */ 1031 report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { 1032 regs->nip += 4; | 1049 1050 if (!(regs->msr & MSR_PR) && /* not user-mode */ 1051 report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { 1052 regs->nip += 4; |
1033 return; | 1053 goto bail; |
1034 } 1035 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); | 1054 } 1055 _exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip); |
1036 return; | 1056 goto bail; |
1037 } 1038#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1039 if (reason & REASON_TM) { 1040 /* This is a TM "Bad Thing Exception" program check. 1041 * This occurs when: 1042 * - An rfid/hrfid/mtmsrd attempts to cause an illegal 1043 * transition in TM states. 1044 * - A trechkpt is attempted when transactional. 1045 * - A treclaim is attempted when non transactional. 1046 * - A tend is illegally attempted. 1047 * - writing a TM SPR when transactional. 1048 */ 1049 if (!user_mode(regs) && 1050 report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { 1051 regs->nip += 4; | 1057 } 1058#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1059 if (reason & REASON_TM) { 1060 /* This is a TM "Bad Thing Exception" program check. 1061 * This occurs when: 1062 * - An rfid/hrfid/mtmsrd attempts to cause an illegal 1063 * transition in TM states. 1064 * - A trechkpt is attempted when transactional. 1065 * - A treclaim is attempted when non transactional. 1066 * - A tend is illegally attempted. 1067 * - writing a TM SPR when transactional. 1068 */ 1069 if (!user_mode(regs) && 1070 report_bug(regs->nip, regs) == BUG_TRAP_TYPE_WARN) { 1071 regs->nip += 4; |
1052 return; | 1072 goto bail; |
1053 } 1054 /* If usermode caused this, it's done something illegal and 1055 * gets a SIGILL slap on the wrist. We call it an illegal 1056 * operand to distinguish from the instruction just being bad 1057 * (e.g. executing a 'tend' on a CPU without TM!); it's an 1058 * illegal /placement/ of a valid instruction. 1059 */ 1060 if (user_mode(regs)) { 1061 _exception(SIGILL, regs, ILL_ILLOPN, regs->nip); | 1073 } 1074 /* If usermode caused this, it's done something illegal and 1075 * gets a SIGILL slap on the wrist. We call it an illegal 1076 * operand to distinguish from the instruction just being bad 1077 * (e.g. executing a 'tend' on a CPU without TM!); it's an 1078 * illegal /placement/ of a valid instruction. 1079 */ 1080 if (user_mode(regs)) { 1081 _exception(SIGILL, regs, ILL_ILLOPN, regs->nip); |
1062 return; | 1082 goto bail; |
1063 } else { 1064 printk(KERN_EMERG "Unexpected TM Bad Thing exception " 1065 "at %lx (msr 0x%x)\n", regs->nip, reason); 1066 die("Unrecoverable exception", regs, SIGABRT); 1067 } 1068 } 1069#endif 1070 --- 7 unchanged lines hidden (view full) --- 1078 * that means ESR is sometimes set incorrectly - either to 1079 * ESR_DST (!?) or 0. In the process of chasing this with the 1080 * hardware people - not sure if it can happen on any illegal 1081 * instruction or only on FP instructions, whether there is a 1082 * pattern to occurrences etc. -dgibson 31/Mar/2003 */ 1083 switch (do_mathemu(regs)) { 1084 case 0: 1085 emulate_single_step(regs); | 1083 } else { 1084 printk(KERN_EMERG "Unexpected TM Bad Thing exception " 1085 "at %lx (msr 0x%x)\n", regs->nip, reason); 1086 die("Unrecoverable exception", regs, SIGABRT); 1087 } 1088 } 1089#endif 1090 --- 7 unchanged lines hidden (view full) --- 1098 * that means ESR is sometimes set incorrectly - either to 1099 * ESR_DST (!?) or 0. In the process of chasing this with the 1100 * hardware people - not sure if it can happen on any illegal 1101 * instruction or only on FP instructions, whether there is a 1102 * pattern to occurrences etc. -dgibson 31/Mar/2003 */ 1103 switch (do_mathemu(regs)) { 1104 case 0: 1105 emulate_single_step(regs); |
1086 return; | 1106 goto bail; |
1087 case 1: { 1088 int code = 0; 1089 code = __parse_fpscr(current->thread.fpscr.val); 1090 _exception(SIGFPE, regs, code, regs->nip); | 1107 case 1: { 1108 int code = 0; 1109 code = __parse_fpscr(current->thread.fpscr.val); 1110 _exception(SIGFPE, regs, code, regs->nip); |
1091 return; | 1111 goto bail; |
1092 } 1093 case -EFAULT: 1094 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); | 1112 } 1113 case -EFAULT: 1114 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); |
1095 return; | 1115 goto bail; |
1096 } 1097 /* fall through on any other errors */ 1098#endif /* CONFIG_MATH_EMULATION */ 1099 1100 /* Try to emulate it if we should. */ 1101 if (reason & (REASON_ILLEGAL | REASON_PRIVILEGED)) { 1102 switch (emulate_instruction(regs)) { 1103 case 0: 1104 regs->nip += 4; 1105 emulate_single_step(regs); | 1116 } 1117 /* fall through on any other errors */ 1118#endif /* CONFIG_MATH_EMULATION */ 1119 1120 /* Try to emulate it if we should. */ 1121 if (reason & (REASON_ILLEGAL | REASON_PRIVILEGED)) { 1122 switch (emulate_instruction(regs)) { 1123 case 0: 1124 regs->nip += 4; 1125 emulate_single_step(regs); |
1106 return; | 1126 goto bail; |
1107 case -EFAULT: 1108 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); | 1127 case -EFAULT: 1128 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip); |
1109 return; | 1129 goto bail; |
1110 } 1111 } 1112 1113 if (reason & REASON_PRIVILEGED) 1114 _exception(SIGILL, regs, ILL_PRVOPC, regs->nip); 1115 else 1116 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); | 1130 } 1131 } 1132 1133 if (reason & REASON_PRIVILEGED) 1134 _exception(SIGILL, regs, ILL_PRVOPC, regs->nip); 1135 else 1136 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); |
1137 1138bail: 1139 exception_exit(prev_state); |
|
1117} 1118 1119void alignment_exception(struct pt_regs *regs) 1120{ | 1140} 1141 1142void alignment_exception(struct pt_regs *regs) 1143{ |
1144 enum ctx_state prev_state = exception_enter(); |
|
1121 int sig, code, fixed = 0; 1122 1123 /* We restore the interrupt state now */ 1124 if (!arch_irq_disabled_regs(regs)) 1125 local_irq_enable(); 1126 1127 /* we don't implement logging of alignment exceptions */ 1128 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS)) 1129 fixed = fix_alignment(regs); 1130 1131 if (fixed == 1) { 1132 regs->nip += 4; /* skip over emulated instruction */ 1133 emulate_single_step(regs); | 1145 int sig, code, fixed = 0; 1146 1147 /* We restore the interrupt state now */ 1148 if (!arch_irq_disabled_regs(regs)) 1149 local_irq_enable(); 1150 1151 /* we don't implement logging of alignment exceptions */ 1152 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS)) 1153 fixed = fix_alignment(regs); 1154 1155 if (fixed == 1) { 1156 regs->nip += 4; /* skip over emulated instruction */ 1157 emulate_single_step(regs); |
1134 return; | 1158 goto bail; |
1135 } 1136 1137 /* Operand address was bad */ 1138 if (fixed == -EFAULT) { 1139 sig = SIGSEGV; 1140 code = SEGV_ACCERR; 1141 } else { 1142 sig = SIGBUS; 1143 code = BUS_ADRALN; 1144 } 1145 if (user_mode(regs)) 1146 _exception(sig, regs, code, regs->dar); 1147 else 1148 bad_page_fault(regs, regs->dar, sig); | 1159 } 1160 1161 /* Operand address was bad */ 1162 if (fixed == -EFAULT) { 1163 sig = SIGSEGV; 1164 code = SEGV_ACCERR; 1165 } else { 1166 sig = SIGBUS; 1167 code = BUS_ADRALN; 1168 } 1169 if (user_mode(regs)) 1170 _exception(sig, regs, code, regs->dar); 1171 else 1172 bad_page_fault(regs, regs->dar, sig); |
1173 1174bail: 1175 exception_exit(prev_state); |
|
1149} 1150 1151void StackOverflow(struct pt_regs *regs) 1152{ 1153 printk(KERN_CRIT "Kernel stack overflow in process %p, r1=%lx\n", 1154 current, regs->gpr[1]); 1155 debugger(regs); 1156 show_regs(regs); --- 12 unchanged lines hidden (view full) --- 1169{ 1170 printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n", 1171 current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0], 1172 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted()); 1173} 1174 1175void kernel_fp_unavailable_exception(struct pt_regs *regs) 1176{ | 1176} 1177 1178void StackOverflow(struct pt_regs *regs) 1179{ 1180 printk(KERN_CRIT "Kernel stack overflow in process %p, r1=%lx\n", 1181 current, regs->gpr[1]); 1182 debugger(regs); 1183 show_regs(regs); --- 12 unchanged lines hidden (view full) --- 1196{ 1197 printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n", 1198 current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0], 1199 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted()); 1200} 1201 1202void kernel_fp_unavailable_exception(struct pt_regs *regs) 1203{ |
1204 enum ctx_state prev_state = exception_enter(); 1205 |
|
1177 printk(KERN_EMERG "Unrecoverable FP Unavailable Exception " 1178 "%lx at %lx\n", regs->trap, regs->nip); 1179 die("Unrecoverable FP Unavailable Exception", regs, SIGABRT); | 1206 printk(KERN_EMERG "Unrecoverable FP Unavailable Exception " 1207 "%lx at %lx\n", regs->trap, regs->nip); 1208 die("Unrecoverable FP Unavailable Exception", regs, SIGABRT); |
1209 1210 exception_exit(prev_state); |
|
1180} 1181 1182void altivec_unavailable_exception(struct pt_regs *regs) 1183{ | 1211} 1212 1213void altivec_unavailable_exception(struct pt_regs *regs) 1214{ |
1215 enum ctx_state prev_state = exception_enter(); 1216 |
|
1184 if (user_mode(regs)) { 1185 /* A user program has executed an altivec instruction, 1186 but this kernel doesn't support altivec. */ 1187 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); | 1217 if (user_mode(regs)) { 1218 /* A user program has executed an altivec instruction, 1219 but this kernel doesn't support altivec. */ 1220 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); |
1188 return; | 1221 goto bail; |
1189 } 1190 1191 printk(KERN_EMERG "Unrecoverable VMX/Altivec Unavailable Exception " 1192 "%lx at %lx\n", regs->trap, regs->nip); 1193 die("Unrecoverable VMX/Altivec Unavailable Exception", regs, SIGABRT); | 1222 } 1223 1224 printk(KERN_EMERG "Unrecoverable VMX/Altivec Unavailable Exception " 1225 "%lx at %lx\n", regs->trap, regs->nip); 1226 die("Unrecoverable VMX/Altivec Unavailable Exception", regs, SIGABRT); |
1227 1228bail: 1229 exception_exit(prev_state); |
|
1194} 1195 1196void vsx_unavailable_exception(struct pt_regs *regs) 1197{ 1198 if (user_mode(regs)) { 1199 /* A user program has executed an vsx instruction, 1200 but this kernel doesn't support vsx. */ 1201 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); --- 578 unchanged lines hidden --- | 1230} 1231 1232void vsx_unavailable_exception(struct pt_regs *regs) 1233{ 1234 if (user_mode(regs)) { 1235 /* A user program has executed an vsx instruction, 1236 but this kernel doesn't support vsx. */ 1237 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); --- 578 unchanged lines hidden --- |