[PATCH] powerpc: Add rN aliases to the pt_regs_offset table.

Subsystems: linux for powerpc (32-bit and 64-bit), ptrace support, the rest

STALE3938d

4 messages, 3 authors, 2015-11-26 · open the first message on its own page

[PATCH] powerpc: Add rN aliases to the pt_regs_offset table.

From: Rashmica Gupta <hidden>
Date: 2015-11-21 06:08:38

It is common practice with powerpc to use 'rN' to refer to register 'N'. However
when using the pt_regs_offset table we have to use 'gprN'.

So add aliases such that both 'rN' and 'gprN' can be used.

For example, we can currently do:
$ su -
$ echo "p:probe/sys_fchownat .sys_fchownat %gpr3:s32 +0(%gpr4):string %gpr5:s32
%gpr6:s32 %gpr7:s32" > /sys/kernel/debug/tracing/kprobe_events
$ echo 1 > /sys/kernel/debug/tracing/events/probe/sys_fchownat/enable
$ touch /tmp/foo
$ chown root /tmp/foo
$ echo 0 > /sys/kernel/debug/tracing/events/enable
$ cat /sys/kernel/debug/tracing/trace
           chown-5040  [001] d... 24800.047211: sys_fchownat:
(.SyS_fchownat+0x0/0x190) arg1=-100 arg2="foo" arg3=0 arg4=-1 arg5=0

Instead we'd like to be able to use:
$ echo "p:probe/sys_fchownat sys_fchownat %r3:s32 +0(%r4):string %r5:s32
%r6:s32 %r7:s32" > /sys/kernel/debug/tracing/kprobe_events

Signed-off-by: Rashmica Gupta <redacted>
---
 arch/powerpc/kernel/ptrace.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 737c0d0b53ac..30a03c03fe73 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -60,6 +60,7 @@ struct pt_regs_offset {
 #define STR(s)	#s			/* convert to string */
 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
 #define GPR_OFFSET_NAME(num)	\
+	{.name = STR(r##num), .offset = offsetof(struct pt_regs, gpr[num])}, \
 	{.name = STR(gpr##num), .offset = offsetof(struct pt_regs, gpr[num])}
 #define REG_OFFSET_END {.name = NULL, .offset = 0}
 
-- 
2.5.0

Re: [PATCH] powerpc: Add rN aliases to the pt_regs_offset table.

From: Anshuman Khandual <hidden>
Date: 2015-11-23 08:24:51

On 11/21/2015 11:38 AM, Rashmica Gupta wrote:
It is common practice with powerpc to use 'rN' to refer to register 'N'. However
when using the pt_regs_offset table we have to use 'gprN'.

So add aliases such that both 'rN' and 'gprN' can be used.

For example, we can currently do:
$ su -
$ echo "p:probe/sys_fchownat .sys_fchownat %gpr3:s32 +0(%gpr4):string %gpr5:s32
%gpr6:s32 %gpr7:s32" > /sys/kernel/debug/tracing/kprobe_events
$ echo 1 > /sys/kernel/debug/tracing/events/probe/sys_fchownat/enable
$ touch /tmp/foo
$ chown root /tmp/foo
$ echo 0 > /sys/kernel/debug/tracing/events/enable
$ cat /sys/kernel/debug/tracing/trace
           chown-5040  [001] d... 24800.047211: sys_fchownat:
(.SyS_fchownat+0x0/0x190) arg1=-100 arg2="foo" arg3=0 arg4=-1 arg5=0

Instead we'd like to be able to use:
$ echo "p:probe/sys_fchownat sys_fchownat %r3:s32 +0(%r4):string %r5:s32
%r6:s32 %r7:s32" > /sys/kernel/debug/tracing/kprobe_events
This makes sense and works for me on a LE guest. Just that the symbol
should not have the "." before it. 

Re: [PATCH] powerpc: Add rN aliases to the pt_regs_offset table.

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2015-11-23 10:15:24

On Mon, 2015-11-23 at 13:54 +0530, Anshuman Khandual wrote:
On 11/21/2015 11:38 AM, Rashmica Gupta wrote:
quoted
It is common practice with powerpc to use 'rN' to refer to register 'N'. However
when using the pt_regs_offset table we have to use 'gprN'.

So add aliases such that both 'rN' and 'gprN' can be used.

For example, we can currently do:
$ su -
$ echo "p:probe/sys_fchownat .sys_fchownat %gpr3:s32 +0(%gpr4):string %gpr5:s32
%gpr6:s32 %gpr7:s32" > /sys/kernel/debug/tracing/kprobe_events
$ echo 1 > /sys/kernel/debug/tracing/events/probe/sys_fchownat/enable
$ touch /tmp/foo
$ chown root /tmp/foo
$ echo 0 > /sys/kernel/debug/tracing/events/enable
$ cat /sys/kernel/debug/tracing/trace
           chown-5040  [001] d... 24800.047211: sys_fchownat:
(.SyS_fchownat+0x0/0x190) arg1=-100 arg2="foo" arg3=0 arg4=-1 arg5=0

Instead we'd like to be able to use:
$ echo "p:probe/sys_fchownat sys_fchownat %r3:s32 +0(%r4):string %r5:s32
%r6:s32 %r7:s32" > /sys/kernel/debug/tracing/kprobe_events
This makes sense and works for me on a LE guest. Just that the symbol
should not have the "." before it. 
Yeah that's probably my fault for giving Rashmica an example from a BE system.
I'll fix up the example before I commit it.

cheers

Re: powerpc: Add rN aliases to the pt_regs_offset table.

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2015-11-26 12:15:57

On Sat, 2015-21-11 at 06:08:16 UTC, Rashmica Gupta wrote:
It is common practice with powerpc to use 'rN' to refer to register 'N'. However
when using the pt_regs_offset table we have to use 'gprN'.

So add aliases such that both 'rN' and 'gprN' can be used.

For example, we can currently do:
$ su -
$ echo "p:probe/sys_fchownat .sys_fchownat %gpr3:s32 +0(%gpr4):string %gpr5:s32
%gpr6:s32 %gpr7:s32" > /sys/kernel/debug/tracing/kprobe_events
$ echo 1 > /sys/kernel/debug/tracing/events/probe/sys_fchownat/enable
$ touch /tmp/foo
$ chown root /tmp/foo
$ echo 0 > /sys/kernel/debug/tracing/events/enable
$ cat /sys/kernel/debug/tracing/trace
           chown-5040  [001] d... 24800.047211: sys_fchownat:
(.SyS_fchownat+0x0/0x190) arg1=-100 arg2="foo" arg3=0 arg4=-1 arg5=0

Instead we'd like to be able to use:
$ echo "p:probe/sys_fchownat sys_fchownat %r3:s32 +0(%r4):string %r5:s32
%r6:s32 %r7:s32" > /sys/kernel/debug/tracing/kprobe_events

Signed-off-by: Rashmica Gupta <redacted>
Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/343c3327c12b136551929830

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help