x86: Unspaghettize do_general_protection()
[deliverable/linux.git] / arch / x86 / kernel / traps.c
index 05b31d92f69cdf7b7e9ccc22c82835a5e6286bbc..74850e5594498fb288721cb1fe80ff9589e7f260 100644 (file)
@@ -9,6 +9,9 @@
 /*
  * Handle hardware traps and faults.
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/interrupt.h>
 #include <linux/kallsyms.h>
 #include <linux/spinlock.h>
@@ -143,12 +146,11 @@ trap_signal:
 #ifdef CONFIG_X86_64
        if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
            printk_ratelimit()) {
-               printk(KERN_INFO
-                      "%s[%d] trap %s ip:%lx sp:%lx error:%lx",
-                      tsk->comm, tsk->pid, str,
-                      regs->ip, regs->sp, error_code);
+               pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
+                       tsk->comm, tsk->pid, str,
+                       regs->ip, regs->sp, error_code);
                print_vma_addr(" in ", regs->ip);
-               printk("\n");
+               pr_cont("\n");
        }
 #endif
 
@@ -256,47 +258,40 @@ do_general_protection(struct pt_regs *regs, long error_code)
        conditional_sti(regs);
 
 #ifdef CONFIG_X86_32
-       if (regs->flags & X86_VM_MASK)
-               goto gp_in_vm86;
+       if (regs->flags & X86_VM_MASK) {
+               local_irq_enable();
+               handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
+               return;
+       }
 #endif
 
        tsk = current;
-       if (!user_mode(regs))
-               goto gp_in_kernel;
+       if (!user_mode(regs)) {
+               if (fixup_exception(regs))
+                       return;
+
+               tsk->thread.error_code = error_code;
+               tsk->thread.trap_nr = X86_TRAP_GP;
+               if (!notify_die(DIE_GPF, "general protection fault", regs, error_code,
+                              X86_TRAP_GP, SIGSEGV) == NOTIFY_STOP)
+                       die("general protection fault", regs, error_code);
+               return;
+       }
 
        tsk->thread.error_code = error_code;
        tsk->thread.trap_nr = X86_TRAP_GP;
 
        if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
                        printk_ratelimit()) {
-               printk(KERN_INFO
-                       "%s[%d] general protection ip:%lx sp:%lx error:%lx",
+               pr_info("%s[%d] general protection ip:%lx sp:%lx error:%lx",
                        tsk->comm, task_pid_nr(tsk),
                        regs->ip, regs->sp, error_code);
                print_vma_addr(" in ", regs->ip);
-               printk("\n");
+               pr_cont("\n");
        }
 
        force_sig(SIGSEGV, tsk);
        return;
-
-#ifdef CONFIG_X86_32
-gp_in_vm86:
-       local_irq_enable();
-       handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
-       return;
-#endif
-
-gp_in_kernel:
-       if (fixup_exception(regs))
-               return;
-
-       tsk->thread.error_code = error_code;
-       tsk->thread.trap_nr = X86_TRAP_GP;
-       if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
-                       X86_TRAP_GP, SIGSEGV) == NOTIFY_STOP)
-               return;
-       die("general protection fault", regs, error_code);
 }
 
 /* May run on IST stack. */
@@ -570,7 +565,7 @@ do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
        conditional_sti(regs);
 #if 0
        /* No need to warn about this any longer. */
-       printk(KERN_INFO "Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
+       pr_info("Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
 #endif
 }
 
This page took 0.035276 seconds and 5 git commands to generate.