diff options
author | Luke Nelson <lukenels@cs.washington.edu> | 2020-05-08 21:15:46 +0300 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2020-05-11 14:21:39 +0300 |
commit | fd868f14818901821699988fdac680ebd80cd360 (patch) | |
tree | 7cbceb89d9585da12aac300019a938310e42a0aa /Documentation | |
parent | fd49591cb49b72abd1b665222a635ccb17df7923 (diff) | |
download | linux-fd868f14818901821699988fdac680ebd80cd360.tar.xz |
bpf, arm64: Optimize ADD,SUB,JMP BPF_K using arm64 add/sub immediates
The current code for BPF_{ADD,SUB} BPF_K loads the BPF immediate to a
temporary register before performing the addition/subtraction. Similarly,
BPF_JMP BPF_K cases load the immediate to a temporary register before
comparison.
This patch introduces optimizations that use arm64 immediate add, sub,
cmn, or cmp instructions when the BPF immediate fits. If the immediate
does not fit, it falls back to using a temporary register.
Example of generated code for BPF_ALU64_IMM(BPF_ADD, R0, 2):
without optimization:
24: mov x10, #0x2
28: add x7, x7, x10
with optimization:
24: add x7, x7, #0x2
The code could use A64_{ADD,SUB}_I directly and check if it returns
AARCH64_BREAK_FAULT, similar to how logical immediates are handled.
However, aarch64_insn_gen_add_sub_imm from insn.c prints error messages
when the immediate does not fit, and it's simpler to check if the
immediate fits ahead of time.
Co-developed-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Luke Nelson <luke.r.nels@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20200508181547.24783-4-luke.r.nels@gmail.com
Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'Documentation')
0 files changed, 0 insertions, 0 deletions