]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: BPF: Adjust the jump offset of tail calls
authorChenghao Duan <duanchenghao@kylinos.cn>
Wed, 31 Dec 2025 07:19:21 +0000 (15:19 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 31 Dec 2025 07:19:21 +0000 (15:19 +0800)
Call the next bpf prog and skip the first instruction of TCC
initialization.

A total of 7 instructions are skipped:
'move t0, ra' 1 inst
'move_imm + jirl' 5 inst
'addid REG_TCC, zero, 0' 1 inst

Relevant test cases: the tailcalls test item in selftests/bpf.

Cc: stable@vger.kernel.org
Fixes: 677e6123e3d2 ("LoongArch: BPF: Disable trampoline for kernel module function trace")
Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/net/bpf_jit.c

index 9729c0ff7bfcc7b2e79c2504b5664364a617187d..e6aeaec46969d0984ab192f969fb450d4ed85916 100644 (file)
@@ -239,7 +239,7 @@ static void __build_epilogue(struct jit_ctx *ctx, bool is_tail_call)
                 * Call the next bpf prog and skip the first instruction
                 * of TCC initialization.
                 */
-               emit_insn(ctx, jirl, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_T3, 6);
+               emit_insn(ctx, jirl, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_T3, 7);
        }
 }