[PATCH v1 3/4] LoongArch: BPF: Add support for indirect jumps

From: Tiezhu Yang

Date: Sun Nov 22 2026 - 23:39:30 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 dst 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 | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index 415b945bf818..52da39dce4f6 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -1184,6 +1184,11 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
goto toofar;
break;

+ /* PC = dst */
+ case BPF_JMP | BPF_JA | BPF_X:
+ emit_insn(ctx, jirl, LOONGARCH_GPR_ZERO, dst, 0);
+ break;
+
/* PC += off */
case BPF_JMP | BPF_JA:
jmp_offset = bpf2la_offset(i, off, ctx);
--
2.42.0