* [PATCH] powerpc/trace: Add support for HAVE_FUNCTION_ARG_ACCESS_API
@ 2023-06-14 8:59 Naveen N Rao
2023-10-27 9:59 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Naveen N Rao @ 2023-06-14 8:59 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Masami Hiramatsu
When creating a kprobe on function entry through tracefs, enable
arguments to be recorded to be specified using $argN syntax.
Signed-off-by: Naveen N Rao <naveen@kernel.org>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/ptrace.h | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index bff5820b7cda14..bd76ae95146b42 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -233,6 +233,7 @@ config PPC
select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_FAST_GUP
select HAVE_FTRACE_MCOUNT_RECORD
+ select HAVE_FUNCTION_ARG_ACCESS_API
select HAVE_FUNCTION_DESCRIPTORS if PPC64_ELF_ABI_V1
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUNCTION_GRAPH_TRACER
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index 0eb90a01334666..68ce2381b18ae1 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -397,6 +397,23 @@ static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
return 0;
}
+/**
+ * regs_get_kernel_argument() - get Nth function argument in kernel
+ * @regs: pt_regs of that context
+ * @n: function argument number (start from 0)
+ *
+ * We support up to 8 arguments and assume they are sent in through the GPRs.
+ * This will fail for fp/vector arguments, but those aren't usually found in
+ * kernel code. This is expected to be called from kprobes or ftrace with regs.
+ */
+static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, unsigned int n)
+{
+#define NR_REG_ARGUMENTS 8
+ if (n < NR_REG_ARGUMENTS)
+ return regs_get_register(regs, offsetof(struct pt_regs, gpr[3 + n]));
+ return 0;
+}
+
#endif /* __ASSEMBLY__ */
#ifndef __powerpc64__
base-commit: bd517a8442b6c6646a136421cd4c1b95bf4ce32b
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc/trace: Add support for HAVE_FUNCTION_ARG_ACCESS_API
2023-06-14 8:59 [PATCH] powerpc/trace: Add support for HAVE_FUNCTION_ARG_ACCESS_API Naveen N Rao
@ 2023-10-27 9:59 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2023-10-27 9:59 UTC (permalink / raw)
To: linuxppc-dev, Naveen N Rao; +Cc: Masami Hiramatsu
On Wed, 14 Jun 2023 14:29:26 +0530, Naveen N Rao wrote:
> When creating a kprobe on function entry through tracefs, enable
> arguments to be recorded to be specified using $argN syntax.
>
>
Applied to powerpc/next.
[1/1] powerpc/trace: Add support for HAVE_FUNCTION_ARG_ACCESS_API
https://git.kernel.org/powerpc/c/f01b0edd562ef5a05bae31fe3a296721f89af7d9
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-27 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 8:59 [PATCH] powerpc/trace: Add support for HAVE_FUNCTION_ARG_ACCESS_API Naveen N Rao
2023-10-27 9:59 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).