OSDN Git Service

bpf: s390: add JIT support for multi-function programs
authorYauheni Kaliuta <yauheni.kaliuta@redhat.com>
Wed, 28 Aug 2019 18:28:46 +0000 (21:28 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 30 Aug 2019 22:35:50 +0000 (00:35 +0200)
commit1c8f9b91c456f5b47a377a0c8c5d4130fc39433a
treea19372aee851b8c3d2190dc3ac65bbcd99996c4d
parent47ee6e86e0a3e3a15fbdd6d94aab39e46013c961
bpf: s390: add JIT support for multi-function programs

This adds support for bpf-to-bpf function calls in the s390 JIT
compiler. The JIT compiler converts the bpf call instructions to
native branch instructions. After a round of the usual passes, the
start addresses of the JITed images for the callee functions are
known. Finally, to fixup the branch target addresses, we need to
perform an extra pass.

Because of the address range in which JITed images are allocated on
s390, the offsets of the start addresses of these images from
__bpf_call_base are as large as 64 bits. So, for a function call,
the imm field of the instruction cannot be used to determine the
callee's address. Use bpf_jit_get_func_addr() helper instead.

The patch borrows a lot from:

commit 8c11ea5ce13d ("bpf, arm64: fix getting subprog addr from aux
for calls")

commit e2c95a61656d ("bpf, ppc64: generalize fetching subprog into
bpf_jit_get_func_addr")

commit 8484ce8306f9 ("bpf: powerpc64: add JIT support for
multi-function programs")

(including the commit message).

test_verifier (5.3-rc6 with CONFIG_BPF_JIT_ALWAYS_ON=y):

without patch:
Summary: 1501 PASSED, 0 SKIPPED, 47 FAILED

with patch:
Summary: 1540 PASSED, 0 SKIPPED, 8 FAILED

Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
arch/s390/net/bpf_jit_comp.c