New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jit BPF_CALL to direct call when possible #3623
Conversation
Master branch: af515a5 |
Master branch: 0b20a13 |
5003651
to
93b0121
Compare
Master branch: 274052a |
93b0121
to
70785d1
Compare
Master branch: 2786bcf |
70785d1
to
5dd6be1
Compare
Master branch: 1e660f7 |
Currently BPF_CALL is always jited to indirect call, but when target is in the range of direct call, a BPF_CALL can be jited to direct call. For example, the following BPF_CALL call __htab_map_lookup_elem is always jited to an indirect call: mov x10, #0xffffffffffff18f4 movk x10, #0x821, lsl #16 movk x10, #0x8000, lsl #32 blr x10 When the target is in the range of a direct call, it can be jited to: bl 0xfffffffffd33bc98 This patch does such jit when possible. 1. Before allocating jit image memory, jit all BPF_CALL to indirect call, so we could get the maximum image size at the end. 2. Allocate jit image memory with the maximum image size. 3. Since we have now allocated jit image memory, every jited instruction address is determined, so the distance to call target is determined, so whether a BPF_CALL can be jited to direct call is determined. 4. Since step 3 may adjust the position of jited instructions, update the offset of jump instructions whose target is within the jit image. Tested with test_bpf.ko and some arm64 working selftests, nothing failed. Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
With jiting BPF_CALL to indirect call or direct call based on the jump distance, the bpf trampoline size calculated with NULL image address may be larger than the actual size needed, resulting in a fake -EFBIG error. So remove the estimate of the bpf trampoline size based on NULL image address, and check if there is enough space when emitting instructions. Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
5dd6be1
to
24b5314
Compare
Master branch: 028a964 Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/netdevbpf/list/?series=673664
conflict:
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=673664 irrelevant now for [{'archived': False, 'project': 399, 'delegate': 121173}] |
Pull request for series with
subject: Jit BPF_CALL to direct call when possible
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=673664