Skip to content

Commit

Permalink
arm64: bpf: add 'store immediate' instruction
Browse files Browse the repository at this point in the history
aarch64 doesn't have native store immediate instruction, such operation
has to be implemented by the below instruction sequence:

Load immediate to register
Store register

Signed-off-by: Yang Shi <[email protected]>
CC: Zi Shen Lim <[email protected]>
CC: Xi Wang <[email protected]>
Reviewed-by: Zi Shen Lim <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Yang Shi authored and davem330 committed Dec 3, 2015
1 parent 6bd4f35 commit df849ba
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion arch/arm64/net/bpf_jit_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,25 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx)
case BPF_ST | BPF_MEM | BPF_H:
case BPF_ST | BPF_MEM | BPF_B:
case BPF_ST | BPF_MEM | BPF_DW:
goto notyet;
/* Load imm to a register then store it */
ctx->tmp_used = 1;
emit_a64_mov_i(1, tmp2, off, ctx);
emit_a64_mov_i(1, tmp, imm, ctx);
switch (BPF_SIZE(code)) {
case BPF_W:
emit(A64_STR32(tmp, dst, tmp2), ctx);
break;
case BPF_H:
emit(A64_STRH(tmp, dst, tmp2), ctx);
break;
case BPF_B:
emit(A64_STRB(tmp, dst, tmp2), ctx);
break;
case BPF_DW:
emit(A64_STR64(tmp, dst, tmp2), ctx);
break;
}
break;

/* STX: *(size *)(dst + off) = src */
case BPF_STX | BPF_MEM | BPF_W:
Expand Down

0 comments on commit df849ba

Please sign in to comment.