]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mips: bpf: Fix broken BPF_MOD
authorDenis Kirjanov <kda@linux-powerpc.org>
Mon, 1 Dec 2014 09:57:02 +0000 (12:57 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Dec 2014 17:39:05 +0000 (09:39 -0800)
[ Upstream commit 2e46477a12f6fd273e31a220b155d66e8352198c ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/mips/net/bpf_jit.c

index 9b55143d19dbad39ad8b7cd7f1b9ced90e8ab2cb..9fd6834a2172ac3cd77115d604a2f07ac8370bc2 100644 (file)
@@ -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 */
 }
@@ -971,7 +971,7 @@ load_ind:
                        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 {