powerpc: Hide empty pt_regs at base of the stack
[linux-2.6-block.git] / arch / powerpc / kernel / process.c
index b68898ac07e1999d4ae74467c1cdbcfcc419a31d..392404688cec353f68b6a2a47eeff7e97c618048 100644 (file)
@@ -2258,6 +2258,22 @@ unsigned long __get_wchan(struct task_struct *p)
        return ret;
 }
 
+static bool empty_user_regs(struct pt_regs *regs, struct task_struct *tsk)
+{
+       unsigned long stack_page;
+
+       // A non-empty pt_regs should never have a zero MSR or TRAP value.
+       if (regs->msr || regs->trap)
+               return false;
+
+       // Check it sits at the very base of the stack
+       stack_page = (unsigned long)task_stack_page(tsk);
+       if ((unsigned long)(regs + 1) != stack_page + THREAD_SIZE)
+               return false;
+
+       return true;
+}
+
 static int kstack_depth_to_print = CONFIG_PRINT_STACK_DEPTH;
 
 void __no_sanitize_address show_stack(struct task_struct *tsk,
@@ -2322,9 +2338,13 @@ void __no_sanitize_address show_stack(struct task_struct *tsk,
                        lr = regs->link;
                        printk("%s--- interrupt: %lx at %pS\n",
                               loglvl, regs->trap, (void *)regs->nip);
-                       __show_regs(regs);
-                       printk("%s--- interrupt: %lx\n",
-                              loglvl, regs->trap);
+
+                       // Detect the case of an empty pt_regs at the very base
+                       // of the stack and suppress showing it in full.
+                       if (!empty_user_regs(regs, tsk)) {
+                               __show_regs(regs);
+                               printk("%s--- interrupt: %lx\n", loglvl, regs->trap);
+                       }
 
                        firstframe = 1;
                }