bpf, mips: Add JIT support for JMP32_JA

The JMP32_JA instruction from the eBPF v4 ISA was not implemented.
This caused programs using the instruction to fall back to the
interpreter.

Implement the JMP32_JA instruction.

Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20260925231932.1063678-3-johan.almbladh@anyfinetworks.com
This commit is contained in:
Johan Almbladh 2026-09-26 01:19:32 +02:00 committed by Alexei Starovoitov
parent 89d8e19811
commit f4f496deca
No known key found for this signature in database
4 changed files with 16 additions and 2 deletions

View File

@ -850,7 +850,7 @@ void emit_jmp_r(struct jit_context *ctx, u8 dst, u8 src, s32 off, u8 op)
}
/* Jump always */
int emit_ja(struct jit_context *ctx, s16 off)
int emit_ja(struct jit_context *ctx, s32 off)
{
int target = get_target(ctx, ctx->bpf_index + off + 1);

View File

@ -204,7 +204,7 @@ void emit_jmp_i(struct jit_context *ctx, u8 dst, s32 imm, s32 off, u8 op);
void emit_jmp_r(struct jit_context *ctx, u8 dst, u8 src, s32 off, u8 op);
/* Jump always */
int emit_ja(struct jit_context *ctx, s16 off);
int emit_ja(struct jit_context *ctx, s32 off);
/* Jump to epilogue */
int emit_exit(struct jit_context *ctx);

View File

@ -1877,6 +1877,13 @@ int build_insn(const struct bpf_insn *insn, struct jit_context *ctx)
if (finish_jmp(ctx, jmp, off) < 0)
goto toofar;
break;
/* PC += imm */
case BPF_JMP32 | BPF_JA:
if (imm == 0)
break;
if (emit_ja(ctx, imm) < 0)
goto toofar;
break;
/* PC += off if dst == src */
/* PC += off if dst != src */
/* PC += off if dst & src */

View File

@ -1041,6 +1041,13 @@ int build_insn(const struct bpf_insn *insn, struct jit_context *ctx)
if (finish_jmp(ctx, jmp, off) < 0)
goto toofar;
break;
/* PC += imm */
case BPF_JMP32 | BPF_JA:
if (imm == 0)
break;
if (emit_ja(ctx, imm) < 0)
goto toofar;
break;
/* PC += off if dst == src */
/* PC += off if dst != src */
/* PC += off if dst & src */