Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 9ddd2b8

Browse files
chenhengqichenhuacai
authored andcommitted
LoongArch: BPF: Support 32-bit offset jmp instructions
Add support for 32-bit offset jmp instruction. Currently, we use b instruction which supports range within ±128MB for such jumps. This should be large enough for BPF progs. Signed-off-by: Hengqi Chen <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 4ebf921 commit 9ddd2b8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/loongarch/net/bpf_jit.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,11 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
848848

849849
/* PC += off */
850850
case BPF_JMP | BPF_JA:
851-
jmp_offset = bpf2la_offset(i, off, ctx);
851+
case BPF_JMP32 | BPF_JA:
852+
if (BPF_CLASS(code) == BPF_JMP)
853+
jmp_offset = bpf2la_offset(i, off, ctx);
854+
else
855+
jmp_offset = bpf2la_offset(i, imm, ctx);
852856
if (emit_uncond_jmp(ctx, jmp_offset) < 0)
853857
goto toofar;
854858
break;

0 commit comments

Comments
 (0)