Commit d314e1f4 authored by Chenghao Duan's avatar Chenghao Duan Committed by Huacai Chen
Browse files

LoongArch: BPF: Save return address register ra to t0 before trampoline



Modify the build_prologue() function to ensure the return address
register ra is saved to t0 before entering trampoline operations.
This change ensures the accurate return address handling when a BPF
program calls another BPF program, preventing errors in the BPF-to-BPF
call chain.

Cc: stable@vger.kernel.org
Fixes: 677e6123 ("LoongArch: BPF: Disable trampoline for kernel module function trace")
Signed-off-by: default avatarChenghao Duan <duanchenghao@kylinos.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent eb71f5c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ static void build_prologue(struct jit_ctx *ctx)
	stack_adjust = round_up(stack_adjust, 16);
	stack_adjust += bpf_stack_adjust;

	move_reg(ctx, LOONGARCH_GPR_T0, LOONGARCH_GPR_RA);
	/* Reserve space for the move_imm + jirl instruction */
	for (i = 0; i < LOONGARCH_LONG_JUMP_NINSNS; i++)
		emit_insn(ctx, nop);