summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHengqi Chen <hengqi.chen@gmail.com>2025-03-30 16:31:09 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-10 14:37:41 +0200
commit7cf8fe2b2bccef6a2be7fa8819cbbdffeabe53ad (patch)
treed7ba0c561236007d6f580f0e1b736f8d970b87f3
parent7df2696256a034405d3c5a71b3a4c54725de4404 (diff)
downloadlinux-7cf8fe2b2bccef6a2be7fa8819cbbdffeabe53ad.tar.gz
linux-7cf8fe2b2bccef6a2be7fa8819cbbdffeabe53ad.tar.bz2
linux-7cf8fe2b2bccef6a2be7fa8819cbbdffeabe53ad.zip
LoongArch: BPF: Use move_addr() for BPF_PSEUDO_FUNC
commit 52266f1015a8b5aabec7d127f83d105f702b388e upstream. Vincent reported that running XDP synproxy program on LoongArch results in the following error: JIT doesn't support bpf-to-bpf calls With dmesg: multi-func JIT bug 1391 != 1390 The root cause is that verifier will refill the imm with the correct addresses of bpf_calls for BPF_PSEUDO_FUNC instructions and then run the last pass of JIT. So we generate different JIT code for the same instruction in two passes (one for placeholder and the other for the real address). Let's use move_addr() instead. See commit 64f50f6575721ef0 ("LoongArch, bpf: Use 4 instructions for function address in JIT") for a similar fix. Cc: stable@vger.kernel.org Fixes: 69c087ba6225 ("bpf: Add bpf_for_each_map_elem() helper") Fixes: bb035ef0cc91 ("LoongArch: BPF: Support mixing bpf2bpf and tailcalls") Reported-by: Vincent Li <vincent.mc.li@gmail.com> Tested-by: Vincent Li <vincent.mc.li@gmail.com> Closes: https://lore.kernel.org/loongarch/CAK3+h2yfM9FTNiXvEQBkvtuoJrvzmN4c_NZsFXqEk4Cj1tsBNA@mail.gmail.com/T/#u Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/loongarch/net/bpf_jit.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/loongarch/net/bpf_jit.c b/arch/loongarch/net/bpf_jit.c
index a06f077673d0..dcb1428b458c 100644
--- a/arch/loongarch/net/bpf_jit.c
+++ b/arch/loongarch/net/bpf_jit.c
@@ -872,7 +872,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
{
const u64 imm64 = (u64)(insn + 1)->imm << 32 | (u32)insn->imm;
- move_imm(ctx, dst, imm64, is32);
+ if (bpf_pseudo_func(insn))
+ move_addr(ctx, dst, imm64);
+ else
+ move_imm(ctx, dst, imm64, is32);
return 1;
}