diff options
author | Markos Chandras <markos.chandras@imgtec.com> | 2014-06-25 04:39:38 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-06-26 05:48:22 -0400 |
commit | b6a14a9845259eb21c9d8121330c4c3b22de182e (patch) | |
tree | cc8b63b121c15347027f7a92dcac61fd6ec01ec5 | |
parent | b4fe0ec86dae91abfa9f932cd0e2e9d50e336c8b (diff) |
MIPS: BPF: Use 32 or 64-bit load instruction to load an address to register
When loading a pointer to register we need to use the appropriate
32 or 64bit instruction to preserve the pointers' top 32bits.
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Daniel Borkmann <dborkman@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: netdev@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7180/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/net/bpf_jit.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c index 4505e2e6ab53..6e3963425b64 100644 --- a/arch/mips/net/bpf_jit.c +++ b/arch/mips/net/bpf_jit.c | |||
@@ -453,6 +453,17 @@ static inline void emit_wsbh(unsigned int dst, unsigned int src, | |||
453 | emit_instr(ctx, wsbh, dst, src); | 453 | emit_instr(ctx, wsbh, dst, src); |
454 | } | 454 | } |
455 | 455 | ||
456 | /* load pointer to register */ | ||
457 | static inline void emit_load_ptr(unsigned int dst, unsigned int src, | ||
458 | int imm, struct jit_ctx *ctx) | ||
459 | { | ||
460 | /* src contains the base addr of the 32/64-pointer */ | ||
461 | if (config_enabled(CONFIG_64BIT)) | ||
462 | emit_instr(ctx, ld, dst, imm, src); | ||
463 | else | ||
464 | emit_instr(ctx, lw, dst, imm, src); | ||
465 | } | ||
466 | |||
456 | /* load a function pointer to register */ | 467 | /* load a function pointer to register */ |
457 | static inline void emit_load_func(unsigned int reg, ptr imm, | 468 | static inline void emit_load_func(unsigned int reg, ptr imm, |
458 | struct jit_ctx *ctx) | 469 | struct jit_ctx *ctx) |
@@ -1277,7 +1288,8 @@ jmp_cmp: | |||
1277 | /* A = skb->dev->ifindex */ | 1288 | /* A = skb->dev->ifindex */ |
1278 | ctx->flags |= SEEN_SKB | SEEN_A | SEEN_S0; | 1289 | ctx->flags |= SEEN_SKB | SEEN_A | SEEN_S0; |
1279 | off = offsetof(struct sk_buff, dev); | 1290 | off = offsetof(struct sk_buff, dev); |
1280 | emit_load(r_s0, r_skb, off, ctx); | 1291 | /* Load *dev pointer */ |
1292 | emit_load_ptr(r_s0, r_skb, off, ctx); | ||
1281 | /* error (0) in the delay slot */ | 1293 | /* error (0) in the delay slot */ |
1282 | emit_bcond(MIPS_COND_EQ, r_s0, r_zero, | 1294 | emit_bcond(MIPS_COND_EQ, r_s0, r_zero, |
1283 | b_imm(prog->len, ctx), ctx); | 1295 | b_imm(prog->len, ctx), ctx); |