Skip to content

Commit f01b0ed

Browse files
rnavmpe
authored andcommitted
powerpc/trace: Add support for HAVE_FUNCTION_ARG_ACCESS_API
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent d42f55e commit f01b0ed

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ config PPC
237237
select HAVE_EFFICIENT_UNALIGNED_ACCESS
238238
select HAVE_FAST_GUP
239239
select HAVE_FTRACE_MCOUNT_RECORD
240+
select HAVE_FUNCTION_ARG_ACCESS_API
240241
select HAVE_FUNCTION_DESCRIPTORS if PPC64_ELF_ABI_V1
241242
select HAVE_FUNCTION_ERROR_INJECTION
242243
select HAVE_FUNCTION_GRAPH_TRACER

arch/powerpc/include/asm/ptrace.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,23 @@ static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
397397
return 0;
398398
}
399399

400+
/**
401+
* regs_get_kernel_argument() - get Nth function argument in kernel
402+
* @regs: pt_regs of that context
403+
* @n: function argument number (start from 0)
404+
*
405+
* We support up to 8 arguments and assume they are sent in through the GPRs.
406+
* This will fail for fp/vector arguments, but those aren't usually found in
407+
* kernel code. This is expected to be called from kprobes or ftrace with regs.
408+
*/
409+
static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, unsigned int n)
410+
{
411+
#define NR_REG_ARGUMENTS 8
412+
if (n < NR_REG_ARGUMENTS)
413+
return regs_get_register(regs, offsetof(struct pt_regs, gpr[3 + n]));
414+
return 0;
415+
}
416+
400417
#endif /* __ASSEMBLY__ */
401418

402419
#ifndef __powerpc64__

0 commit comments

Comments
 (0)