Skip to content

Commit

Permalink
mips: bpf: Fix broken BPF_MOD
Browse files Browse the repository at this point in the history
Remove optimize_div() from BPF_MOD | BPF_K case
since we don't know the dividend and fix the
emit_mod() by reading the mod operation result from HI register

Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
Reviewed-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Denis Kirjanov authored and David S. Miller committed Dec 9, 2014
1 parent f2a0151 commit 2e46477
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/mips/net/bpf_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static inline void emit_mod(unsigned int dst, unsigned int src,
u32 *p = &ctx->target[ctx->idx];
uasm_i_divu(&p, dst, src);
p = &ctx->target[ctx->idx + 1];
uasm_i_mflo(&p, dst);
uasm_i_mfhi(&p, dst);
}
ctx->idx += 2; /* 2 insts */
}
Expand Down Expand Up @@ -971,7 +971,7 @@ static int build_body(struct jit_ctx *ctx)
break;
case BPF_ALU | BPF_MOD | BPF_K:
/* A %= k */
if (k == 1 || optimize_div(&k)) {
if (k == 1) {
ctx->flags |= SEEN_A;
emit_jit_reg_move(r_A, r_zero, ctx);
} else {
Expand Down

0 comments on commit 2e46477

Please sign in to comment.