Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / arch / s390 / kernel / ptrace.c
index 7cf4642..9f654da 100644 (file)
@@ -640,7 +640,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 {
-       long ret;
+       long ret = 0;
 
        /* Do the secure computing check first. */
        secure_computing(regs->gprs[2]);
@@ -649,7 +649,6 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
         * The sysc_tracesys code in entry.S stored the system
         * call number to gprs[2].
         */
-       ret = regs->gprs[2];
        if (test_thread_flag(TIF_SYSCALL_TRACE) &&
            (tracehook_report_syscall_entry(regs) ||
             regs->gprs[2] >= NR_syscalls)) {
@@ -671,7 +670,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
                                    regs->gprs[2], regs->orig_gpr2,
                                    regs->gprs[3], regs->gprs[4],
                                    regs->gprs[5]);
-       return ret;
+       return ret ?: regs->gprs[2];
 }
 
 asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
@@ -992,3 +991,61 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 #endif
        return &user_s390_view;
 }
+
+static const char *gpr_names[NUM_GPRS] = {
+       "r0", "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",
+       "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+};
+
+unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)
+{
+       if (offset >= NUM_GPRS)
+               return 0;
+       return regs->gprs[offset];
+}
+
+int regs_query_register_offset(const char *name)
+{
+       unsigned long offset;
+
+       if (!name || *name != 'r')
+               return -EINVAL;
+       if (strict_strtoul(name + 1, 10, &offset))
+               return -EINVAL;
+       if (offset >= NUM_GPRS)
+               return -EINVAL;
+       return offset;
+}
+
+const char *regs_query_register_name(unsigned int offset)
+{
+       if (offset >= NUM_GPRS)
+               return NULL;
+       return gpr_names[offset];
+}
+
+static int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr)
+{
+       unsigned long ksp = kernel_stack_pointer(regs);
+
+       return (addr & ~(THREAD_SIZE - 1)) == (ksp & ~(THREAD_SIZE - 1));
+}
+
+/**
+ * regs_get_kernel_stack_nth() - get Nth entry of the stack
+ * @regs:pt_regs which contains kernel stack pointer.
+ * @n:stack entry number.
+ *
+ * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
+ * is specifined by @regs. If the @n th entry is NOT in the kernel stack,
+ * this returns 0.
+ */
+unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n)
+{
+       unsigned long addr;
+
+       addr = kernel_stack_pointer(regs) + n * sizeof(long);
+       if (!regs_within_kernel_stack(regs, addr))
+               return 0;
+       return *(unsigned long *)addr;
+}