Powerpc port of the kprobe-based event tracer
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v3 1/1 Powerpc port of the kprobe-based event tracer
This patch ports the kprobe-based event tracer to powerpc. This patch is based on x86 port. This brings powerpc on par with x86.
ChangeLog:
v2:
- Removed regs_get_argument_nth() API as function argument access syntax is dropped from kprobe-tracer. Please refer to mails below on Linux PPC mailing list:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-January/079331.html
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-January/079332.html
v3:
- The registers gpr[0]...gpr[31] will now be represented as gpr0...gpr31
- The pt_regs structure members orig_gpr3 and result will not be exposed as they are not actual registers.
- Rebased to commit 605a39d5a0f4856214b37db954f553fba28bb616 of -tip
This patch is dependent on:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-January/079331.html
Port the following API's to ppc for accessing registers and stack entries from pt_regs.
- regs_query_register_offset(const char *name)
Query the offset of "name" register.
- regs_query_register_name(unsigned int offset)
Query the name of register by its offset.
- regs_get_register(struct pt_regs *regs, unsigned int offset) Get the value of a register by its offset.
- regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr) Check the address is in the kernel stack.
- regs_get_kernel_stack_nth(struct pt_regs *reg, unsigned int nth) Get Nth entry of the kernel stack. (N >= 0)
---
arch/powerpc/include/asm/ptrace.h | 61 ++++++++++++++++++++++ arch/powerpc/kernel/ptrace.c | 103 +++++++++++++++++++++++++++++++++++++ kernel/trace/Kconfig | 2 - 3 files changed, 165 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/ptrace.h +61 -0
@@ -83,6 +83,7 @@ struct pt_regs {#define instruction_pointer (regs) ((regs)->nip)#define user_stack_pointer (regs) ((regs)->gpr[1]) +#define kernel_stack_pointer (regs) ((regs)->gpr[1])#define regs_return_value (regs) ((regs)->gpr[3])#ifdef CONFIG_SMP
@@ -131,6 +132,66 @@ do { \ } while (0)#endif /* __powerpc64__ */ +/* Query offset/name of register from its name/offset */ +#include <linux/stddef.h> +#include <linux/thread_info.h> +extern int regs_query_register_offset (const char *name); +extern const char *regs_query_register_name (unsigned int offset); +#define MAX_REG_OFFSET (offsetof(struct pt_regs, dsisr)) + +/** +* regs_get_register() - get register value from its offset +* @regs: pt_regs from which register value is gotten +* @offset: offset number of the register. +* +* regs_get_register returns the value of a register whose offset from @regs. +* The @offset is the offset of the register in struct pt_regs. +* If @offset is bigger than MAX_REG_OFFSET, this returns 0. +*/ +static inline unsigned long regs_get_register (struct pt_regs *regs, +unsigned int offset) +{ +if (unlikely (offset >MAX_REG_OFFSET )) +return 0 ; +return *(unsigned long *)((unsigned long )regs + offset); +} + +/** +* regs_within_kernel_stack() - check the address in the stack +* @regs: pt_regs which contains kernel stack pointer. +* @addr: address which is checked. +* +* regs_within_kernel_stack() checks @addr is within the kernel stack page(s). +* If @addr is within the kernel stack, it returns true. If not, returns false. +*/ + +static inline bool regs_within_kernel_stack (struct pt_regs *regs, +unsigned long addr) +{ +return ((addr & ~(THREAD_SIZE -1 )) == + (kernel_stack_pointer (regs) & ~(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 specified by @regs. If the @n th entry is NOT in the kernel stack, +* this returns 0. +*/ +static inline unsigned long regs_get_kernel_stack_nth (struct pt_regs *regs, +unsigned int n) +{ +unsigned long *addr = (unsigned long *)kernel_stack_pointer (regs); + addr += n; +if (regs_within_kernel_stack (regs, (unsigned long )addr)) +return *addr; +else +return 0 ; +} +/* * These are defined as per linux/ptrace.h, which see. */
arch/powerpc/kernel/ptrace.c +103 -0
109 lines not on this page · raw message
kernel/trace/Kconfig +1 -1
@@ -451,7 +451,7 @@ config BLK_DEV_IO_TRACE config KPROBE_EVENT depends on KPROBES - depends on X86 + depends on X86 || PPC bool "Enable kprobes-based dynamic events" select TRACING default y