summaryrefslogtreecommitdiff
path: root/arch/loongarch/net
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2026-08-17 22:07:39 +0800
committerHuacai Chen <chenhuacai@loongson.cn>2026-08-17 22:07:39 +0800
commit9fcdba34230a4bbc5d907b5c48f23f95061ceed1 (patch)
tree97889de5f8b0de5ffd81445263f7b3ede6c4a5dd /arch/loongarch/net
parent252ae40ba91c5da3a792bba7e3dc46b106dec86c (diff)
LoongArch: BPF: Split unconditional branch JA paths statically
In build_insn(), both 32-bit and 64-bit unconditional branch JA paths currently share a single case block. It relies on a runtime condition check to multiplex between the 'off' and 'imm' fields. Since the instruction classes are already resolved at compile-time via distinct switch-case labels, this runtime check is redundant. Split the two paths into individual case blocks to remove the redundant runtime check. Acked-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/net')
-rw-r--r--arch/loongarch/net/bpf_jit.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index a5e902eb646c..48d368ba0529 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -1125,11 +1125,12 @@ 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);
+ if (emit_uncond_jmp(ctx, jmp_offset) < 0)
+ goto toofar;
+ break;
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);
+ jmp_offset = bpf2la_offset(i, imm, ctx);
if (emit_uncond_jmp(ctx, jmp_offset) < 0)
goto toofar;
break;