aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/net/bpf_jit_comp.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm64/net/bpf_jit_comp.c')
-rw-r--r--arch/arm64/net/bpf_jit_comp.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 9ae6f2373a6d..6217f80702d2 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -269,6 +269,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
269 break; 269 break;
270 case BPF_ALU | BPF_DIV | BPF_X: 270 case BPF_ALU | BPF_DIV | BPF_X:
271 case BPF_ALU64 | BPF_DIV | BPF_X: 271 case BPF_ALU64 | BPF_DIV | BPF_X:
272 case BPF_ALU | BPF_MOD | BPF_X:
273 case BPF_ALU64 | BPF_MOD | BPF_X:
272 { 274 {
273 const u8 r0 = bpf2a64[BPF_REG_0]; 275 const u8 r0 = bpf2a64[BPF_REG_0];
274 276
@@ -281,16 +283,19 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
281 check_imm26(jmp_offset); 283 check_imm26(jmp_offset);
282 emit(A64_B(jmp_offset), ctx); 284 emit(A64_B(jmp_offset), ctx);
283 /* else */ 285 /* else */
284 emit(A64_UDIV(is64, dst, dst, src), ctx); 286 switch (BPF_OP(code)) {
287 case BPF_DIV:
288 emit(A64_UDIV(is64, dst, dst, src), ctx);
289 break;
290 case BPF_MOD:
291 ctx->tmp_used = 1;
292 emit(A64_UDIV(is64, tmp, dst, src), ctx);
293 emit(A64_MUL(is64, tmp, tmp, src), ctx);
294 emit(A64_SUB(is64, dst, dst, tmp), ctx);
295 break;
296 }
285 break; 297 break;
286 } 298 }
287 case BPF_ALU | BPF_MOD | BPF_X:
288 case BPF_ALU64 | BPF_MOD | BPF_X:
289 ctx->tmp_used = 1;
290 emit(A64_UDIV(is64, tmp, dst, src), ctx);
291 emit(A64_MUL(is64, tmp, tmp, src), ctx);
292 emit(A64_SUB(is64, dst, dst, tmp), ctx);
293 break;
294 case BPF_ALU | BPF_LSH | BPF_X: 299 case BPF_ALU | BPF_LSH | BPF_X:
295 case BPF_ALU64 | BPF_LSH | BPF_X: 300 case BPF_ALU64 | BPF_LSH | BPF_X:
296 emit(A64_LSLV(is64, dst, dst, src), ctx); 301 emit(A64_LSLV(is64, dst, dst, src), ctx);