Thread (17 messages) read the whole thread 17 messages, 3 authors, 2016-04-01

Re: [PATCH 4/4] samples/bpf: Enable powerpc support

From: Alexei Starovoitov <hidden>
Date: 2016-03-31 17:53:26
Also in: lkml, netdev

On 3/31/16 4:25 AM, Naveen N. Rao wrote:
Add the necessary definitions for building bpf samples on ppc.

Since ppc doesn't store function return address on the stack, modify how
PT_REGS_RET() and PT_REGS_FP() work.

Also, introduce PT_REGS_IP() to access the instruction pointer. I have
fixed this to work with x86_64 and arm64, but not s390.

Cc: Alexei Starovoitov <redacted>
Cc: David S. Miller <davem@davemloft.net>
Cc: Ananth N Mavinakayanahalli <redacted>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Naveen N. Rao <redacted>
---
...
+
+#ifdef __powerpc__
+#define BPF_KPROBE_READ_RET_IP(ip, ctx)		{ (ip) = (ctx)->link; }
+#define BPF_KRETPROBE_READ_RET_IP(ip, ctx)	BPF_KPROBE_READ_RET_IP(ip, ctx)
+#else
+#define BPF_KPROBE_READ_RET_IP(ip, ctx)						\
+		bpf_probe_read(&(ip), sizeof(ip), (void *)PT_REGS_RET(ctx))
+#define BPF_KRETPROBE_READ_RET_IP(ip, ctx)					\
+		bpf_probe_read(&(ip), sizeof(ip),				\
+				(void *)(PT_REGS_FP(ctx) + sizeof(ip)))
makes sense, but please use ({ }) gcc extension instead of {} and
open call to make sure that macro body is scoped.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help