diff options
author | David S. Miller <davem@davemloft.net> | 2017-04-22 15:31:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-22 16:01:52 -0400 |
commit | b0c47807d31deccdfb78a22a0d04dd9785bdb9d3 (patch) | |
tree | ca692f4934315e65ae4927eca8ccb1e4030c4836 | |
parent | 7a12b5031c6b947cc13918237ae652b536243b76 (diff) |
bpf: Add sparc support to tools and samples.
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | samples/bpf/bpf_helpers.h | 19 | ||||
-rw-r--r-- | tools/build/feature/test-bpf.c | 3 | ||||
-rw-r--r-- | tools/lib/bpf/bpf.c | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h index 52de9d88c021..9a9c95f2c9fb 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) = | |||
146 | #define PT_REGS_SP(x) ((x)->sp) | 146 | #define PT_REGS_SP(x) ((x)->sp) |
147 | #define PT_REGS_IP(x) ((x)->nip) | 147 | #define PT_REGS_IP(x) ((x)->nip) |
148 | 148 | ||
149 | #elif defined(__sparc__) | ||
150 | |||
151 | #define PT_REGS_PARM1(x) ((x)->u_regs[UREG_I0]) | ||
152 | #define PT_REGS_PARM2(x) ((x)->u_regs[UREG_I1]) | ||
153 | #define PT_REGS_PARM3(x) ((x)->u_regs[UREG_I2]) | ||
154 | #define PT_REGS_PARM4(x) ((x)->u_regs[UREG_I3]) | ||
155 | #define PT_REGS_PARM5(x) ((x)->u_regs[UREG_I4]) | ||
156 | #define PT_REGS_RET(x) ((x)->u_regs[UREG_I7]) | ||
157 | #define PT_REGS_RC(x) ((x)->u_regs[UREG_I0]) | ||
158 | #define PT_REGS_SP(x) ((x)->u_regs[UREG_FP]) | ||
159 | #if defined(__arch64__) | ||
160 | #define PT_REGS_IP(x) ((x)->tpc) | ||
161 | #else | ||
162 | #define PT_REGS_IP(x) ((x)->pc) | ||
163 | #endif | ||
164 | |||
149 | #endif | 165 | #endif |
150 | 166 | ||
151 | #ifdef __powerpc__ | 167 | #ifdef __powerpc__ |
152 | #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = (ctx)->link; }) | 168 | #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = (ctx)->link; }) |
153 | #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP | 169 | #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP |
170 | #elif defined(__sparc__) | ||
171 | #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ (ip) = PT_REGS_RET(ctx); }) | ||
172 | #define BPF_KRETPROBE_READ_RET_IP BPF_KPROBE_READ_RET_IP | ||
154 | #else | 173 | #else |
155 | #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ \ | 174 | #define BPF_KPROBE_READ_RET_IP(ip, ctx) ({ \ |
156 | bpf_probe_read(&(ip), sizeof(ip), (void *)PT_REGS_RET(ctx)); }) | 175 | 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 e04ab89a1013..ebc6dceddb58 100644 --- a/tools/build/feature/test-bpf.c +++ b/tools/build/feature/test-bpf.c | |||
@@ -9,6 +9,9 @@ | |||
9 | # define __NR_bpf 321 | 9 | # define __NR_bpf 321 |
10 | # elif defined(__aarch64__) | 10 | # elif defined(__aarch64__) |
11 | # define __NR_bpf 280 | 11 | # define __NR_bpf 280 |
12 | # elif defined(__sparc__) | ||
13 | # define __NR_bpf 349 | ||
14 | # else | ||
12 | # error __NR_bpf not defined. libbpf does not support your arch. | 15 | # error __NR_bpf not defined. libbpf does not support your arch. |
13 | # endif | 16 | # endif |
14 | #endif | 17 | #endif |
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index f84c398c11f4..4fe444b8092e 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -37,6 +37,8 @@ | |||
37 | # define __NR_bpf 321 | 37 | # define __NR_bpf 321 |
38 | # elif defined(__aarch64__) | 38 | # elif defined(__aarch64__) |
39 | # define __NR_bpf 280 | 39 | # define __NR_bpf 280 |
40 | # elif defined(__sparc__) | ||
41 | # define __NR_bpf 349 | ||
40 | # else | 42 | # else |
41 | # error __NR_bpf not defined. libbpf does not support your arch. | 43 | # error __NR_bpf not defined. libbpf does not support your arch. |
42 | # endif | 44 | # endif |