summaryrefslogtreecommitdiffstats
path: root/arch/arm/net/bpf_jit_32.h
diff options
context:
space:
mode:
authorLuke Nelson <lukenels@cs.washington.edu>2020-04-30 19:02:10 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2020-05-04 17:04:42 +0200
commitc648c9c7429e979ca081359f39b6902aed92d490 (patch)
tree86f5d9bfc42c012d4553fdfe6a79aebb228c6584 /arch/arm/net/bpf_jit_32.h
parentcf48db69bdfad2930b95fd51d64444e5a7b469ae (diff)
downloadlinux-c648c9c7429e979ca081359f39b6902aed92d490.tar.bz2
bpf, arm: Optimize ALU ARSH K using asr immediate instruction
This patch adds an optimization that uses the asr immediate instruction for BPF_ALU BPF_ARSH BPF_K, rather than loading the immediate to a temporary register. This is similar to existing code for handling BPF_ALU BPF_{LSH,RSH} BPF_K. This optimization saves two instructions and is more consistent with LSH and RSH. Example of the code generated for BPF_ALU32_IMM(BPF_ARSH, BPF_REG_0, 5) before the optimization: 2c: mov r8, #5 30: mov r9, #0 34: asr r0, r0, r8 and after optimization: 2c: asr r0, r0, #5 Tested on QEMU using lib/test_bpf and test_verifier. 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> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20200501020210.32294-3-luke.r.nels@gmail.com
Diffstat (limited to 'arch/arm/net/bpf_jit_32.h')
-rw-r--r--arch/arm/net/bpf_jit_32.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm/net/bpf_jit_32.h b/arch/arm/net/bpf_jit_32.h
index fb67cbc589e0..e0b593a1498d 100644
--- a/arch/arm/net/bpf_jit_32.h
+++ b/arch/arm/net/bpf_jit_32.h
@@ -94,6 +94,9 @@
#define ARM_INST_LSR_I 0x01a00020
#define ARM_INST_LSR_R 0x01a00030
+#define ARM_INST_ASR_I 0x01a00040
+#define ARM_INST_ASR_R 0x01a00050
+
#define ARM_INST_MOV_R 0x01a00000
#define ARM_INST_MOVS_R 0x01b00000
#define ARM_INST_MOV_I 0x03a00000