arm64: bpf: add 'shift by register' instructions

Commit 72b603ee8cfc ("bpf: x86: add missing 'shift by register'
instructions to x64 eBPF JIT") noted support for 'shift by register'
in eBPF and added support for it for x64. Let's enable this for arm64
as well.

The arm64 eBPF JIT compiler now passes the new 'shift by register'
test case introduced in the same commit 72b603ee8cfc.

Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by Zi Shen Lim and committed by Catalin Marinas d65a634a b569c1c6

+18 -2
+6 -2
arch/arm64/net/bpf_jit.h
··· 144 145 /* Data-processing (2 source) */ 146 /* Rd = Rn OP Rm */ 147 - #define A64_UDIV(sf, Rd, Rn, Rm) aarch64_insn_gen_data2(Rd, Rn, Rm, \ 148 - A64_VARIANT(sf), AARCH64_INSN_DATA2_UDIV) 149 150 /* Data-processing (3 source) */ 151 /* Rd = Ra + Rn * Rm */
··· 144 145 /* Data-processing (2 source) */ 146 /* Rd = Rn OP Rm */ 147 + #define A64_DATA2(sf, Rd, Rn, Rm, type) aarch64_insn_gen_data2(Rd, Rn, Rm, \ 148 + A64_VARIANT(sf), AARCH64_INSN_DATA2_##type) 149 + #define A64_UDIV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, UDIV) 150 + #define A64_LSLV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSLV) 151 + #define A64_LSRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSRV) 152 + #define A64_ASRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, ASRV) 153 154 /* Data-processing (3 source) */ 155 /* Rd = Ra + Rn * Rm */
+12
arch/arm64/net/bpf_jit_comp.c
··· 261 emit(A64_MUL(is64, tmp, tmp, src), ctx); 262 emit(A64_SUB(is64, dst, dst, tmp), ctx); 263 break; 264 /* dst = -dst */ 265 case BPF_ALU | BPF_NEG: 266 case BPF_ALU64 | BPF_NEG:
··· 261 emit(A64_MUL(is64, tmp, tmp, src), ctx); 262 emit(A64_SUB(is64, dst, dst, tmp), ctx); 263 break; 264 + case BPF_ALU | BPF_LSH | BPF_X: 265 + case BPF_ALU64 | BPF_LSH | BPF_X: 266 + emit(A64_LSLV(is64, dst, dst, src), ctx); 267 + break; 268 + case BPF_ALU | BPF_RSH | BPF_X: 269 + case BPF_ALU64 | BPF_RSH | BPF_X: 270 + emit(A64_LSRV(is64, dst, dst, src), ctx); 271 + break; 272 + case BPF_ALU | BPF_ARSH | BPF_X: 273 + case BPF_ALU64 | BPF_ARSH | BPF_X: 274 + emit(A64_ASRV(is64, dst, dst, src), ctx); 275 + break; 276 /* dst = -dst */ 277 case BPF_ALU | BPF_NEG: 278 case BPF_ALU64 | BPF_NEG: