patch-2.4.1 linux/arch/ppc/kernel/traps.c

Next file: linux/arch/ppc/lib/Makefile
Previous file: linux/arch/ppc/kernel/time.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0/linux/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c
@@ -65,21 +65,37 @@
 void (*debugger_fault_handler)(struct pt_regs *regs);
 #endif
 #endif
+
 /*
  * Trap & Exception support
  */
 
+
+spinlock_t oops_lock = SPIN_LOCK_UNLOCKED;
+
+void die(const char * str, struct pt_regs * fp, long err)
+{
+	console_verbose();
+	spin_lock_irq(&oops_lock);
+	printk("Oops: %s, sig: %ld\n", str, err);
+	show_regs(fp);
+	print_backtrace((unsigned long *)fp->gpr[1]);
+	spin_unlock_irq(&oops_lock);
+	/* do_exit() should take care of panic'ing from an interrupt
+	 * context so we don't handle it here
+	 */
+	do_exit(err);
+}
+
 void
 _exception(int signr, struct pt_regs *regs)
 {
 	if (!user_mode(regs))
 	{
-		show_regs(regs);
 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
 		debugger(regs);
 #endif
-		print_backtrace((unsigned long *)regs->gpr[1]);
-		panic("Exception in kernel pc %lx signal %d",regs->nip,signr);
+		die("Exception in kernel mode", regs, signr);
 	}
 	force_sig(signr, current);
 }
@@ -98,7 +114,7 @@
 
 #if defined(CONFIG_8xx) && defined(CONFIG_PCI)
 	/* the qspan pci read routines can cause machine checks -- Cort */
-	bad_page_fault(regs, regs->dar);
+	bad_page_fault(regs, regs->dar, SIGBUS);
 	return;
 #endif
 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
@@ -151,12 +167,10 @@
 	default:
 		printk("Unknown values in msr\n");
 	}
-	show_regs(regs);
 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
 	debugger(regs);
 #endif
-	print_backtrace((unsigned long *)regs->gpr[1]);
-	panic("machine check");
+	die("machine check", regs, SIGBUS);
 }
 
 void
@@ -217,13 +231,13 @@
 	uint    rd;
 	uint    retval;
 
-	retval = EFAULT;
+	retval = EINVAL;
 
 	if (!user_mode(regs))
 		return retval;
 
 	if (get_user(instword, (uint *)(regs->nip)))
-		return retval;
+		return EFAULT;
 
 	/* Emulate the mfspr rD, PVR.
 	 */
@@ -337,12 +351,10 @@
 	int errcode;
 
 	if (!user_mode(regs)) {
-		show_regs(regs);
 #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
 		debugger(regs);
 #endif
-		print_backtrace((unsigned long *)regs->gpr[1]);
-		panic("Kernel Mode Software FPU Emulation");
+		die("Kernel Mode Software FPU Emulation", regs, SIGFPE);
 	}
 
 #ifdef CONFIG_MATH_EMULATION

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)