[RFC PATCH 2/3] LoongArch: BPF: Add support for indirect jumps
From: Tiezhu Yang
Date: Wed Nov 11 2026 - 04:54:34 EST
In order to implement JIT support for the indirect jump instruction
(BPF_JMP | BPF_JA | BPF_X), emit a jirl instruction to jump to the
target address held in rd without saving PC+4 into return address.
This is similar to commit f4a66cf1cb14 ("bpf: arm64: Add support for
indirect jumps").
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
arch/loongarch/net/bpf_jit.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index 26904010d9b5..64abebd9c950 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -1184,6 +1184,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
goto toofar;
break;
+ case BPF_JMP | BPF_JA | BPF_X:
+ emit_insn(ctx, jirl, LOONGARCH_GPR_ZERO, rd, 0);
+ break;
+
/* PC += off */
case BPF_JMP | BPF_JA:
jmp_offset = bpf2la_offset(i, off, ctx);
--
2.42.0