]> git.baikalelectronics.ru Git - kernel.git/commit
LoongArch, bpf: Use 4 instructions for function address in JIT
authorHengqi Chen <hengqi.chen@gmail.com>
Tue, 14 Feb 2023 15:26:33 +0000 (15:26 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:06 +0000 (09:33 +0100)
commitc341b1a9d9202f3634f35fd33273526a3b440895
treea780a9471107288a0e581dfe8398f80273dce5fd
parent90db647440ac385a640afff8df8006a0a83439dd
LoongArch, bpf: Use 4 instructions for function address in JIT

[ Upstream commit fa18a559942c5445e368aeafc7e15f55b0ce6368 ]

This patch fixes the following issue of function calls in JIT, like:

  [   29.346981] multi-func JIT bug 105 != 103

The issus can be reproduced by running the "inline simple bpf_loop call"
verifier test.

This is because we are emiting 2-4 instructions for 64-bit immediate moves.
During the first pass of JIT, the placeholder address is zero, emiting two
instructions for it. In the extra pass, the function address is in XKVRANGE,
emiting four instructions for it. This change the instruction index in
JIT context. Let's always use 4 instructions for function address in JIT.
So that the instruction sequences don't change between the first pass and
the extra pass for function calls.

Fixes: 28bc1c304253 ("LoongArch: Add BPF JIT support")
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Link: https://lore.kernel.org/bpf/20230214152633.2265699-1-hengqi.chen@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/loongarch/net/bpf_jit.c
arch/loongarch/net/bpf_jit.h