bpf, arm64: fix getting subprog addr from aux for calls
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 26 Nov 2018 13:05:39 +0000 (14:05 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 27 Nov 2018 01:34:24 +0000 (17:34 -0800)
commit8c11ea5ce13da0252fc92f91e90b0cb0c8fe5619
treeeaa5f5849390692a575aa95280313f41b5475ebe
parente2c95a61656d29ceaac97b6a975c8a1f26e26f15
bpf, arm64: fix getting subprog addr from aux for calls

The arm64 JIT has the same issue as ppc64 JIT in that the relative BPF
to BPF call offset can be too far away from core kernel in that relative
encoding into imm is not sufficient and could potentially be truncated,
see also fd045f6cd98e ("arm64: add support for module PLTs") which adds
spill-over space for module_alloc() and therefore bpf_jit_binary_alloc().
Therefore, use the recently added bpf_jit_get_func_addr() helper for
properly fetching the address through prog->aux->func[off]->bpf_func
instead. This also has the benefit to optimize normal helper calls since
their address can use the optimized emission. Tested on Cavium ThunderX
CN8890.

Fixes: db496944fdaa ("bpf: arm64: add JIT support for multi-function programs")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm64/net/bpf_jit_comp.c