aboutsummaryrefslogtreecommitdiffstats
path: root/arch/loongarch
diff options
context:
space:
mode:
authorHengqi Chen <hengqi.chen@gmail.com>2023-11-08 14:12:16 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2023-11-08 14:12:16 +0800
commit9ddd2b8d1a8b566195c196fe4249d04cd75cc73c (patch)
tree47c7650b2683a3de986868e04771572b9df316ce /arch/loongarch
parent4ebf9216e7dff0b38e350007da3b03afb15c816b (diff)
downloadlinux-9ddd2b8d1a8b566195c196fe4249d04cd75cc73c.tar.gz
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 <hengqi.chen@gmail.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch')
-rw-r--r--arch/loongarch/net/bpf_jit.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index a8be6d4b058cd..050fcf233a34a 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -848,7 +848,11 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
/* PC += off */
case BPF_JMP | BPF_JA:
- jmp_offset = bpf2la_offset(i, off, ctx);
+ case BPF_JMP32 | BPF_JA:
+ if (BPF_CLASS(code) == BPF_JMP)
+ jmp_offset = bpf2la_offset(i, off, ctx);
+ else
+ jmp_offset = bpf2la_offset(i, imm, ctx);
if (emit_uncond_jmp(ctx, jmp_offset) < 0)
goto toofar;
break;