提交 2e46477a 编写于 作者: D Denis Kirjanov 提交者: David S. Miller

mips: bpf: Fix broken BPF_MOD

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: NDenis Kirjanov <kda@linux-powerpc.org>
Reviewed-by: NMarkos Chandras <markos.chandras@imgtec.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 f2a01517
...@@ -426,7 +426,7 @@ static inline void emit_mod(unsigned int dst, unsigned int src, ...@@ -426,7 +426,7 @@ static inline void emit_mod(unsigned int dst, unsigned int src,
u32 *p = &ctx->target[ctx->idx]; u32 *p = &ctx->target[ctx->idx];
uasm_i_divu(&p, dst, src); uasm_i_divu(&p, dst, src);
p = &ctx->target[ctx->idx + 1]; p = &ctx->target[ctx->idx + 1];
uasm_i_mflo(&p, dst); uasm_i_mfhi(&p, dst);
} }
ctx->idx += 2; /* 2 insts */ ctx->idx += 2; /* 2 insts */
} }
...@@ -971,7 +971,7 @@ static int build_body(struct jit_ctx *ctx) ...@@ -971,7 +971,7 @@ static int build_body(struct jit_ctx *ctx)
break; break;
case BPF_ALU | BPF_MOD | BPF_K: case BPF_ALU | BPF_MOD | BPF_K:
/* A %= k */ /* A %= k */
if (k == 1 || optimize_div(&k)) { if (k == 1) {
ctx->flags |= SEEN_A; ctx->flags |= SEEN_A;
emit_jit_reg_move(r_A, r_zero, ctx); emit_jit_reg_move(r_A, r_zero, ctx);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册