summaryrefslogtreecommitdiffstats
path: root/arch/s390/include
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2021-10-06 11:59:29 +0200
committerVasily Gorbik <gor@linux.ibm.com>2021-10-11 20:55:59 +0200
commita30b5b03047602be56c5b8ffc3a0e4cfed17561c (patch)
tree43460176f4fd420f8f9748519c355915ba9c986a /arch/s390/include
parentselftests/ftrace: add s390 support for kprobe args tests (diff)
downloadlinux-a30b5b03047602be56c5b8ffc3a0e4cfed17561c.tar.xz
linux-a30b5b03047602be56c5b8ffc3a0e4cfed17561c.zip
s390/ptrace: add function argument access API
Add regs_get_kernel_argument() which returns Nth argument of a function call. This enables ftrace kprobe events to access kernel function arguments via $argN syntax. This is the s390 variant of commit a823c35ff2ed ("arm64: ptrace: Add function argument access API"). Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Steffen Maier <maier@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch/s390/include')
-rw-r--r--arch/s390/include/asm/ptrace.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index 662ee212ba51..82fc11907451 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -196,6 +196,25 @@ const char *regs_query_register_name(unsigned int offset);
unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset);
unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
+/**
+ * regs_get_kernel_argument() - get Nth function argument in kernel
+ * @regs: pt_regs of that context
+ * @n: function argument number (start from 0)
+ *
+ * regs_get_kernel_argument() returns @n th argument of the function call.
+ */
+static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,
+ unsigned int n)
+{
+ unsigned int argoffset = STACK_FRAME_OVERHEAD / sizeof(long);
+
+#define NR_REG_ARGUMENTS 5
+ if (n < NR_REG_ARGUMENTS)
+ return regs_get_register(regs, 2 + n);
+ n -= NR_REG_ARGUMENTS;
+ return regs_get_kernel_stack_nth(regs, argoffset + n);
+}
+
static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
{
return regs->gprs[15];