aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/ptrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/kernel/ptrace.c')
-rw-r--r--arch/s390/kernel/ptrace.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 13815d39f7dd..1720f380add5 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -984,3 +984,61 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
984#endif 984#endif
985 return &user_s390_view; 985 return &user_s390_view;
986} 986}
987
988static const char *gpr_names[NUM_GPRS] = {
989 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
990 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
991};
992
993unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)
994{
995 if (offset >= NUM_GPRS)
996 return 0;
997 return regs->gprs[offset];
998}
999
1000int regs_query_register_offset(const char *name)
1001{
1002 unsigned long offset;
1003
1004 if (!name || *name != 'r')
1005 return -EINVAL;
1006 if (strict_strtoul(name + 1, 10, &offset))
1007 return -EINVAL;
1008 if (offset >= NUM_GPRS)
1009 return -EINVAL;
1010 return offset;
1011}
1012
1013const char *regs_query_register_name(unsigned int offset)
1014{
1015 if (offset >= NUM_GPRS)
1016 return NULL;
1017 return gpr_names[offset];
1018}
1019
1020static int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr)
1021{
1022 unsigned long ksp = kernel_stack_pointer(regs);
1023
1024 return (addr & ~(THREAD_SIZE - 1)) == (ksp & ~(THREAD_SIZE - 1));
1025}
1026
1027/**
1028 * regs_get_kernel_stack_nth() - get Nth entry of the stack
1029 * @regs:pt_regs which contains kernel stack pointer.
1030 * @n:stack entry number.
1031 *
1032 * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
1033 * is specifined by @regs. If the @n th entry is NOT in the kernel stack,
1034 * this returns 0.
1035 */
1036unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n)
1037{
1038 unsigned long addr;
1039
1040 addr = kernel_stack_pointer(regs) + n * sizeof(long);
1041 if (!regs_within_kernel_stack(regs, addr))
1042 return 0;
1043 return *(unsigned long *)addr;
1044}