[PATCH bpf-next 2/2] bpf, mips: Add JIT support for JMP32_JA
From: Johan Almbladh
Date: Fri Sep 25 2026 - 19:21:59 EST
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@xxxxxxxxxxxxxxxxx>
---
arch/mips/net/bpf_jit_comp.c | 2 +-
arch/mips/net/bpf_jit_comp.h | 2 +-
arch/mips/net/bpf_jit_comp32.c | 7 +++++++
arch/mips/net/bpf_jit_comp64.c | 7 +++++++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arch/mips/net/bpf_jit_comp.c b/arch/mips/net/bpf_jit_comp.c
index f14de6d73122..4682dbb3a059 100644
--- a/arch/mips/net/bpf_jit_comp.c
+++ b/arch/mips/net/bpf_jit_comp.c
@@ -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);
diff --git a/arch/mips/net/bpf_jit_comp.h b/arch/mips/net/bpf_jit_comp.h
index 0ddedb733dd1..d0ab5c9a0c46 100644
--- a/arch/mips/net/bpf_jit_comp.h
+++ b/arch/mips/net/bpf_jit_comp.h
@@ -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);
diff --git a/arch/mips/net/bpf_jit_comp32.c b/arch/mips/net/bpf_jit_comp32.c
index 158e69718c09..84d9c7036e4f 100644
--- a/arch/mips/net/bpf_jit_comp32.c
+++ b/arch/mips/net/bpf_jit_comp32.c
@@ -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 */
diff --git a/arch/mips/net/bpf_jit_comp64.c b/arch/mips/net/bpf_jit_comp64.c
index 8359ad3f6992..994589c3de46 100644
--- a/arch/mips/net/bpf_jit_comp64.c
+++ b/arch/mips/net/bpf_jit_comp64.c
@@ -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 */
--
2.43.0