Merge branch 'x86/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[pandora-kernel.git] / arch / x86 / kernel / traps_64.c
index 019a06f..2696a68 100644 (file)
@@ -105,30 +105,7 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
 
 void printk_address(unsigned long address, int reliable)
 {
-#ifdef CONFIG_KALLSYMS
-       unsigned long offset = 0, symsize;
-       const char *symname;
-       char *modname;
-       char *delim = ":";
-       char namebuf[KSYM_NAME_LEN];
-       char reliab[4] = "";
-
-       symname = kallsyms_lookup(address, &symsize, &offset,
-                                       &modname, namebuf);
-       if (!symname) {
-               printk(" [<%016lx>]\n", address);
-               return;
-       }
-       if (!reliable)
-               strcpy(reliab, "? ");
-
-       if (!modname)
-               modname = delim = "";
-       printk(" [<%016lx>] %s%s%s%s%s+0x%lx/0x%lx\n",
-               address, reliab, delim, modname, delim, symname, offset, symsize);
-#else
-       printk(" [<%016lx>]\n", address);
-#endif
+       printk(" [<%016lx>] %s%pS\n", address, reliable ? "": "? ", (void *) address);
 }
 
 static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
@@ -268,7 +245,6 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
 
        if (!task)
                task = current;
-       tinfo = task_thread_info(task);
 
        if (!stack) {
                unsigned long dummy;
@@ -294,6 +270,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
         * current stack address. If the stacks consist of nested
         * exceptions
         */
+       tinfo = task_thread_info(task);
        for (;;) {
                char *id;
                unsigned long *estack_end;
@@ -435,8 +412,8 @@ void show_stack(struct task_struct *task, unsigned long *sp)
  */
 void dump_stack(void)
 {
-       unsigned long stack;
        unsigned long bp = 0;
+       unsigned long stack;
 
 #ifdef CONFIG_FRAME_POINTER
        if (!bp)
@@ -459,12 +436,8 @@ void show_registers(struct pt_regs *regs)
        unsigned long sp;
        const int cpu = smp_processor_id();
        struct task_struct *cur = cpu_pda(cpu)->pcurrent;
-       u8 *ip;
-       unsigned int code_prologue = code_bytes * 43 / 64;
-       unsigned int code_len = code_bytes;
 
        sp = regs->sp;
-       ip = (u8 *) regs->ip - code_prologue;
        printk("CPU %d ", cpu);
        __show_regs(regs);
        printk("Process %s (pid: %d, threadinfo %p, task %p)\n",
@@ -475,12 +448,18 @@ void show_registers(struct pt_regs *regs)
         * time of the fault..
         */
        if (!user_mode(regs)) {
+               unsigned int code_prologue = code_bytes * 43 / 64;
+               unsigned int code_len = code_bytes;
                unsigned char c;
+               u8 *ip;
+
                printk("Stack: ");
                _show_stack(NULL, regs, (unsigned long *)sp, regs->bp);
                printk("\n");
 
                printk(KERN_EMERG "Code: ");
+
+               ip = (u8 *)regs->ip - code_prologue;
                if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
                        /* try starting at RIP */
                        ip = (u8 *)regs->ip;
@@ -585,7 +564,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
        return 0;
 }
 
-void die(const char * str, struct pt_regs *regs, long err)
+void die(const char *str, struct pt_regs *regs, long err)
 {
        unsigned long flags = oops_begin();
 
@@ -630,38 +609,38 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
 {
        struct task_struct *tsk = current;
 
-       if (user_mode(regs)) {
-               /*
-                * We want error_code and trap_no set for userspace
-                * faults and kernelspace faults which result in
-                * die(), but not kernelspace faults which are fixed
-                * up.  die() gives the process no chance to handle
-                * the signal and notice the kernel fault information,
-                * so that won't result in polluting the information
-                * about previously queued, but not yet delivered,
-                * faults.  See also do_general_protection below.
-                */
-               tsk->thread.error_code = error_code;
-               tsk->thread.trap_no = trapnr;
-
-               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);
-                       print_vma_addr(" in ", regs->ip);
-                       printk("\n");
-               }
+       if (!user_mode(regs))
+               goto kernel_trap;
 
-               if (info)
-                       force_sig_info(signr, info, tsk);
-               else
-                       force_sig(signr, tsk);
-               return;
+       /*
+        * We want error_code and trap_no set for userspace faults and
+        * kernelspace faults which result in die(), but not
+        * kernelspace faults which are fixed up.  die() gives the
+        * process no chance to handle the signal and notice the
+        * kernel fault information, so that won't result in polluting
+        * the information about previously queued, but not yet
+        * delivered, faults.  See also do_general_protection below.
+        */
+       tsk->thread.error_code = error_code;
+       tsk->thread.trap_no = trapnr;
+
+       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);
+               print_vma_addr(" in ", regs->ip);
+               printk("\n");
        }
 
+       if (info)
+               force_sig_info(signr, info, tsk);
+       else
+               force_sig(signr, tsk);
+       return;
 
+kernel_trap:
        if (!fixup_exception(regs)) {
                tsk->thread.error_code = error_code;
                tsk->thread.trap_no = trapnr;
@@ -733,31 +712,34 @@ asmlinkage void do_double_fault(struct pt_regs * regs, long error_code)
                die(str, regs, error_code);
 }
 
-asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
-                                               long error_code)
+asmlinkage void __kprobes
+do_general_protection(struct pt_regs *regs, long error_code)
 {
-       struct task_struct *tsk = current;
+       struct task_struct *tsk;
 
        conditional_sti(regs);
 
-       if (user_mode(regs)) {
-               tsk->thread.error_code = error_code;
-               tsk->thread.trap_no = 13;
-
-               if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
-                   printk_ratelimit()) {
-                       printk(KERN_INFO
-                      "%s[%d] general protection ip:%lx sp:%lx error:%lx",
-                              tsk->comm, tsk->pid,
-                              regs->ip, regs->sp, error_code);
-                       print_vma_addr(" in ", regs->ip);
-                       printk("\n");
-               }
+       tsk = current;
+       if (!user_mode(regs))
+               goto gp_in_kernel;
 
-               force_sig(SIGSEGV, tsk);
-               return;
-       } 
+       tsk->thread.error_code = error_code;
+       tsk->thread.trap_no = 13;
+
+       if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
+                       printk_ratelimit()) {
+               printk(KERN_INFO
+                       "%s[%d] general protection ip:%lx sp:%lx error:%lx",
+                       tsk->comm, tsk->pid,
+                       regs->ip, regs->sp, error_code);
+               print_vma_addr(" in ", regs->ip);
+               printk("\n");
+       }
 
+       force_sig(SIGSEGV, tsk);
+       return;
+
+gp_in_kernel:
        if (fixup_exception(regs))
                return;
 
@@ -824,7 +806,7 @@ unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
 
 /* Runs on IST stack. This code must keep interrupts off all the time.
    Nested NMIs are prevented by the CPU. */
-asmlinkage notrace  __kprobes void default_do_nmi(struct pt_regs *regs)
+asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs)
 {
        unsigned char reason = 0;
        int cpu;
@@ -924,8 +906,8 @@ asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
 asmlinkage void __kprobes do_debug(struct pt_regs * regs,
                                   unsigned long error_code)
 {
-       unsigned long condition;
        struct task_struct *tsk = current;
+       unsigned long condition;
        siginfo_t info;
 
        trace_hardirqs_fixup();
@@ -1198,7 +1180,7 @@ void __init trap_init(void)
        /*
         * initialize the per thread extended state:
         */
-        init_thread_xstate();
+       init_thread_xstate();
        /*
         * Should be a barrier for any external CPU state:
         */