netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: Add sparc support to tools and samples.
@ 2017-04-22 19:38 David Miller
  2017-04-22 19:46 ` Daniel Borkmann
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2017-04-22 19:38 UTC (permalink / raw)
  To: alexei.starovoitov; +Cc: daniel, netdev


Signed-off-by: David S. Miller <davem@davemloft.net>
---
 samples/bpf/bpf_helpers.h      | 19 +++++++++++++++++++
 tools/build/feature/test-bpf.c |  3 +++
 tools/lib/bpf/bpf.c            |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
index 52de9d8..9a9c95f 100644
--- a/samples/bpf/bpf_helpers.h
+++ b/samples/bpf/bpf_helpers.h
@@ -146,11 +146,30 @@ static int (*bpf_skb_change_head)(void *, int len, int flags) =
 #define PT_REGS_SP(x) ((x)->sp)
 #define PT_REGS_IP(x) ((x)->nip)
 
+#elif defined(__sparc__)
+
+#define PT_REGS_PARM1(x) ((x)->u_regs[UREG_I0])
+#define PT_REGS_PARM2(x) ((x)->u_regs[UREG_I1])
+#define PT_REGS_PARM3(x) ((x)->u_regs[UREG_I2])
+#define PT_REGS_PARM4(x) ((x)->u_regs[UREG_I3])
+#define PT_REGS_PARM5(x) ((x)->u_regs[UREG_I4])
+#define PT_REGS_RET(x) ((x)->u_regs[UREG_I7])
+#define PT_REGS_RC(x) ((x)->u_regs[UREG_I0])
+#define PT_REGS_SP(x) ((x)->u_regs[UREG_FP])
+#if defined(__arch64__)
+#define PT_REGS_IP(x) ((x)->tpc)
+#else
+#define PT_REGS_IP(x) ((x)->pc)
+#endif
+
 #endif
 
 #ifdef __powerpc__
 #define BPF_KPROBE_READ_RET_IP(ip, ctx)		({ (ip) = (ctx)->link; })
 #define BPF_KRETPROBE_READ_RET_IP		BPF_KPROBE_READ_RET_IP
+#elif defined(__sparc__)
+#define BPF_KPROBE_READ_RET_IP(ip, ctx)		({ (ip) = PT_REGS_RET(ctx); })
+#define BPF_KRETPROBE_READ_RET_IP		BPF_KPROBE_READ_RET_IP
 #else
 #define BPF_KPROBE_READ_RET_IP(ip, ctx)		({				\
 		bpf_probe_read(&(ip), sizeof(ip), (void *)PT_REGS_RET(ctx)); })
diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c
index e04ab89..ebc6dce 100644
--- a/tools/build/feature/test-bpf.c
+++ b/tools/build/feature/test-bpf.c
@@ -9,6 +9,9 @@
 #  define __NR_bpf 321
 # elif defined(__aarch64__)
 #  define __NR_bpf 280
+# elif defined(__sparc__)
+#  define __NR_bpf 349
+# else
 #  error __NR_bpf not defined. libbpf does not support your arch.
 # endif
 #endif
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index f84c398..4fe444b80 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -37,6 +37,8 @@
 #  define __NR_bpf 321
 # elif defined(__aarch64__)
 #  define __NR_bpf 280
+# elif defined(__sparc__)
+#  define __NR_bpf 349
 # else
 #  error __NR_bpf not defined. libbpf does not support your arch.
 # endif
-- 
2.1.2.532.g19b5d50

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: Add sparc support to tools and samples.
  2017-04-22 19:38 [PATCH] bpf: Add sparc support to tools and samples David Miller
@ 2017-04-22 19:46 ` Daniel Borkmann
  2017-04-22 20:02   ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2017-04-22 19:46 UTC (permalink / raw)
  To: David Miller, alexei.starovoitov; +Cc: netdev

On 04/22/2017 09:38 PM, David Miller wrote:
>
> Signed-off-by: David S. Miller <davem@davemloft.net>

LGTM, thanks!

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: Add sparc support to tools and samples.
  2017-04-22 19:46 ` Daniel Borkmann
@ 2017-04-22 20:02   ` David Miller
  2017-04-22 20:16     ` Daniel Borkmann
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2017-04-22 20:02 UTC (permalink / raw)
  To: daniel; +Cc: alexei.starovoitov, netdev

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Sat, 22 Apr 2017 21:46:46 +0200

> On 04/22/2017 09:38 PM, David Miller wrote:
>>
>> Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> LGTM, thanks!
> 
> Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Great, this and the sparc64 eBPF JIT are now pushed out to net-next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] bpf: Add sparc support to tools and samples.
  2017-04-22 20:02   ` David Miller
@ 2017-04-22 20:16     ` Daniel Borkmann
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2017-04-22 20:16 UTC (permalink / raw)
  To: David Miller; +Cc: alexei.starovoitov, netdev

On 04/22/2017 10:02 PM, David Miller wrote:
> From: Daniel Borkmann <daniel@iogearbox.net>
> Date: Sat, 22 Apr 2017 21:46:46 +0200
>
>> On 04/22/2017 09:38 PM, David Miller wrote:
>>>
>>> Signed-off-by: David S. Miller <davem@davemloft.net>
>>
>> LGTM, thanks!
>>
>> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
>
> Great, this and the sparc64 eBPF JIT are now pushed out to net-next.

Awesome, thanks for all the work!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-22 20:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-22 19:38 [PATCH] bpf: Add sparc support to tools and samples David Miller
2017-04-22 19:46 ` Daniel Borkmann
2017-04-22 20:02   ` David Miller
2017-04-22 20:16     ` Daniel Borkmann

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).