Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ab24a4e authored by Markos Chandras's avatar Markos Chandras Committed by Ralf Baechle
Browse files

MIPS: bpf: Fix branch conditional for BPF_J{GT/GE} cases



The sltiu and sltu instructions will set the scratch register
to 1 if A <= X|K so fix the emitted branch conditional to check
for scratch != zero rather than scratch >= zero which would complicate
the resuling branch logic given that MIPS does not have a BGT or BGET
instructions to compare general purpose registers directly.

Signed-off-by: default avatarMarkos 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/7126/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 9eebfe47
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1127,7 +1127,7 @@ static int build_body(struct jit_ctx *ctx)
				}
				}
				/* A < (K|X) ? r_scrach = 1 */
				/* A < (K|X) ? r_scrach = 1 */
				b_off = b_imm(i + inst->jf + 1, ctx);
				b_off = b_imm(i + inst->jf + 1, ctx);
				emit_bcond(MIPS_COND_GT, r_s0, r_zero, b_off,
				emit_bcond(MIPS_COND_NE, r_s0, r_zero, b_off,
					   ctx);
					   ctx);
				emit_nop(ctx);
				emit_nop(ctx);
				/* A > (K|X) ? scratch = 0 */
				/* A > (K|X) ? scratch = 0 */