]> Gentwo Git Trees - linux/.git/commit
LoongArch: BPF: Make trampoline size stable
authorHengqi Chen <hengqi.chen@gmail.com>
Thu, 2 Oct 2025 14:39:52 +0000 (22:39 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Thu, 2 Oct 2025 14:39:52 +0000 (22:39 +0800)
commitea645cfd3d5f74a2bd40a60003f113b3c467975d
tree808189c4c66143a67ab5f181830be7ed586464dd
parenta04731cbee6e981afa4263289a0c0059c8b2e7b9
LoongArch: BPF: Make trampoline size stable

When attach fentry/fexit BPF programs, __arch_prepare_bpf_trampoline()
is called twice with different `struct bpf_tramp_image *im`:

    bpf_trampoline_update()
        -> arch_bpf_trampoline_size()
            -> __arch_prepare_bpf_trampoline()
        -> arch_prepare_bpf_trampoline()
            -> __arch_prepare_bpf_trampoline()

Use move_imm() will emit unstable instruction sequences, so let's use
move_addr() instead to prevent subtle bugs.

(I observed this while debugging other issues with printk.)

Cc: stable@vger.kernel.org
Tested-by: Vincent Li <vincent.mc.li@gmail.com>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/net/bpf_jit.c