Skip to content

Commit af68585

Browse files
Hou Taogregkh
authored andcommitted
bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC
[ Upstream commit e4a41c2 ] The following error is reported when running "./test_progs -t for_each" under arm64: bpf_jit: multi-func JIT bug 58 != 56 [...] JIT doesn't support bpf-to-bpf calls The root cause is the size of BPF_PSEUDO_FUNC instruction increases from 2 to 3 after the address of called bpf-function is settled and there are two bpf-to-bpf calls in test_pkt_access. The generated instructions are shown below: 0x48: 21 00 C0 D2 movz x1, #0x1, lsl #32 0x4c: 21 00 80 F2 movk x1, #0x1 0x48: E1 3F C0 92 movn x1, #0x1ff, lsl #32 0x4c: 41 FE A2 F2 movk x1, #0x17f2, lsl #16 0x50: 81 70 9F F2 movk x1, #0xfb84 Fixing it by using emit_addr_mov_i64() for BPF_PSEUDO_FUNC, so the size of jited image will not change. Fixes: 69c087b ("bpf: Add bpf_for_each_map_elem() helper") Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 26543e3 commit af68585

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/arm64/net/bpf_jit_comp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,10 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
791791
u64 imm64;
792792

793793
imm64 = (u64)insn1.imm << 32 | (u32)imm;
794-
emit_a64_mov_i64(dst, imm64, ctx);
794+
if (bpf_pseudo_func(insn))
795+
emit_addr_mov_i64(dst, imm64, ctx);
796+
else
797+
emit_a64_mov_i64(dst, imm64, ctx);
795798

796799
return 1;
797800
}

0 commit comments

Comments
 (0)