Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/cooloney...
[sfrench/cifs-2.6.git] / arch / arm / kernel / traps.c
index 6055ab4b58d922e72f367e750be2aa3371d8b20e..8ad47619c07906b31dcd60c97490426f6330e34c 100644 (file)
@@ -181,9 +181,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 
 void dump_stack(void)
 {
-#ifdef CONFIG_DEBUG_ERRORS
        __backtrace();
-#endif
 }
 
 EXPORT_SYMBOL(dump_stack);
@@ -204,12 +202,24 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
        barrier();
 }
 
+#ifdef CONFIG_PREEMPT
+#define S_PREEMPT " PREEMPT"
+#else
+#define S_PREEMPT ""
+#endif
+#ifdef CONFIG_SMP
+#define S_SMP " SMP"
+#else
+#define S_SMP ""
+#endif
+
 static void __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs)
 {
        struct task_struct *tsk = thread->task;
        static int die_counter;
 
-       printk("Internal error: %s: %x [#%d]\n", str, err, ++die_counter);
+       printk("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n",
+              str, err, ++die_counter);
        print_modules();
        __show_regs(regs);
        printk("Process %s (pid: %d, stack limit = 0x%p)\n",
@@ -232,21 +242,28 @@ NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
 {
        struct thread_info *thread = current_thread_info();
 
+       oops_enter();
+
        console_verbose();
        spin_lock_irq(&die_lock);
        bust_spinlocks(1);
        __die(str, err, thread, regs);
        bust_spinlocks(0);
+       add_taint(TAINT_DIE);
        spin_unlock_irq(&die_lock);
 
+       if (in_interrupt())
+               panic("Fatal exception in interrupt");
+
        if (panic_on_oops)
                panic("Fatal exception");
 
+       oops_exit();
        do_exit(SIGSEGV);
 }
 
-void notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
-               unsigned long err, unsigned long trap)
+void arm_notify_die(const char *str, struct pt_regs *regs,
+               struct siginfo *info, unsigned long err, unsigned long trap)
 {
        if (user_mode(regs)) {
                current->thread.error_code = err;
@@ -286,6 +303,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
        struct undef_hook *hook;
        siginfo_t info;
        void __user *pc;
+       unsigned long flags;
 
        /*
         * According to the ARM ARM, PC is 2 or 4 bytes ahead,
@@ -304,7 +322,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
                get_user(instr, (u32 __user *)pc);
        }
 
-       spin_lock_irq(&undef_lock);
+       spin_lock_irqsave(&undef_lock, flags);
        list_for_each_entry(hook, &undef_hook, node) {
                if ((instr & hook->instr_mask) == hook->instr_val &&
                    (regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val) {
@@ -314,7 +332,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
                        }
                }
        }
-       spin_unlock_irq(&undef_lock);
+       spin_unlock_irqrestore(&undef_lock, flags);
 
 #ifdef CONFIG_DEBUG_USER
        if (user_debug & UDBG_UNDEFINED) {
@@ -329,15 +347,13 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
        info.si_code  = ILL_ILLOPC;
        info.si_addr  = pc;
 
-       notify_die("Oops - undefined instruction", regs, &info, 0, 6);
+       arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6);
 }
 
 asmlinkage void do_unexp_fiq (struct pt_regs *regs)
 {
-#ifndef CONFIG_IGNORE_FIQ
        printk("Hmm.  Unexpected FIQ received, but trying to continue\n");
        printk("You may have a hardware problem...\n");
-#endif
 }
 
 /*
@@ -383,7 +399,7 @@ static int bad_syscall(int n, struct pt_regs *regs)
        info.si_addr  = (void __user *)instruction_pointer(regs) -
                         (thumb_mode(regs) ? 2 : 4);
 
-       notify_die("Oops - bad syscall", regs, &info, n, 0);
+       arm_notify_die("Oops - bad syscall", regs, &info, n, 0);
 
        return regs->ARM_r0;
 }
@@ -427,7 +443,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
                info.si_code  = SEGV_MAPERR;
                info.si_addr  = NULL;
 
-               notify_die("branch through zero", regs, &info, 0, 0);
+               arm_notify_die("branch through zero", regs, &info, 0, 0);
                return 0;
 
        case NR(breakpoint): /* SWI BREAK_POINT */
@@ -563,7 +579,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
        info.si_addr  = (void __user *)instruction_pointer(regs) -
                         (thumb_mode(regs) ? 2 : 4);
 
-       notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
+       arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
        return 0;
 }
 
@@ -637,7 +653,7 @@ baddataabort(int code, unsigned long instr, struct pt_regs *regs)
        info.si_code  = ILL_ILLOPC;
        info.si_addr  = (void __user *)addr;
 
-       notify_die("unknown data abort code", regs, &info, instr, 0);
+       arm_notify_die("unknown data abort code", regs, &info, instr, 0);
 }
 
 void __attribute__((noreturn)) __bug(const char *file, int line)