mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-17 02:15:57 +00:00
bpf, arm64: Support signed div/mod instructions
Add JIT for signed div/mod instructions. Signed-off-by: Xu Kuohai <xukuohai@huawei.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Tested-by: Florent Revest <revest@chromium.org> Acked-by: Florent Revest <revest@chromium.org> Link: https://lore.kernel.org/bpf/20230815154158.717901-7-xukuohai@huaweicloud.com
This commit is contained in:
parent
c32b6ee514
commit
68b18191fe
@ -234,6 +234,7 @@
|
|||||||
#define A64_DATA2(sf, Rd, Rn, Rm, type) aarch64_insn_gen_data2(Rd, Rn, Rm, \
|
#define A64_DATA2(sf, Rd, Rn, Rm, type) aarch64_insn_gen_data2(Rd, Rn, Rm, \
|
||||||
A64_VARIANT(sf), AARCH64_INSN_DATA2_##type)
|
A64_VARIANT(sf), AARCH64_INSN_DATA2_##type)
|
||||||
#define A64_UDIV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, UDIV)
|
#define A64_UDIV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, UDIV)
|
||||||
|
#define A64_SDIV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, SDIV)
|
||||||
#define A64_LSLV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSLV)
|
#define A64_LSLV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSLV)
|
||||||
#define A64_LSRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSRV)
|
#define A64_LSRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSRV)
|
||||||
#define A64_ASRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, ASRV)
|
#define A64_ASRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, ASRV)
|
||||||
|
@ -828,11 +828,17 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx,
|
|||||||
break;
|
break;
|
||||||
case BPF_ALU | BPF_DIV | BPF_X:
|
case BPF_ALU | BPF_DIV | BPF_X:
|
||||||
case BPF_ALU64 | BPF_DIV | BPF_X:
|
case BPF_ALU64 | BPF_DIV | BPF_X:
|
||||||
emit(A64_UDIV(is64, dst, dst, src), ctx);
|
if (!off)
|
||||||
|
emit(A64_UDIV(is64, dst, dst, src), ctx);
|
||||||
|
else
|
||||||
|
emit(A64_SDIV(is64, dst, dst, src), ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_ALU | BPF_MOD | BPF_X:
|
case BPF_ALU | BPF_MOD | BPF_X:
|
||||||
case BPF_ALU64 | BPF_MOD | BPF_X:
|
case BPF_ALU64 | BPF_MOD | BPF_X:
|
||||||
emit(A64_UDIV(is64, tmp, dst, src), ctx);
|
if (!off)
|
||||||
|
emit(A64_UDIV(is64, tmp, dst, src), ctx);
|
||||||
|
else
|
||||||
|
emit(A64_SDIV(is64, tmp, dst, src), ctx);
|
||||||
emit(A64_MSUB(is64, dst, dst, tmp, src), ctx);
|
emit(A64_MSUB(is64, dst, dst, tmp, src), ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_ALU | BPF_LSH | BPF_X:
|
case BPF_ALU | BPF_LSH | BPF_X:
|
||||||
@ -959,12 +965,18 @@ emit_bswap_uxt:
|
|||||||
case BPF_ALU | BPF_DIV | BPF_K:
|
case BPF_ALU | BPF_DIV | BPF_K:
|
||||||
case BPF_ALU64 | BPF_DIV | BPF_K:
|
case BPF_ALU64 | BPF_DIV | BPF_K:
|
||||||
emit_a64_mov_i(is64, tmp, imm, ctx);
|
emit_a64_mov_i(is64, tmp, imm, ctx);
|
||||||
emit(A64_UDIV(is64, dst, dst, tmp), ctx);
|
if (!off)
|
||||||
|
emit(A64_UDIV(is64, dst, dst, tmp), ctx);
|
||||||
|
else
|
||||||
|
emit(A64_SDIV(is64, dst, dst, tmp), ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_ALU | BPF_MOD | BPF_K:
|
case BPF_ALU | BPF_MOD | BPF_K:
|
||||||
case BPF_ALU64 | BPF_MOD | BPF_K:
|
case BPF_ALU64 | BPF_MOD | BPF_K:
|
||||||
emit_a64_mov_i(is64, tmp2, imm, ctx);
|
emit_a64_mov_i(is64, tmp2, imm, ctx);
|
||||||
emit(A64_UDIV(is64, tmp, dst, tmp2), ctx);
|
if (!off)
|
||||||
|
emit(A64_UDIV(is64, tmp, dst, tmp2), ctx);
|
||||||
|
else
|
||||||
|
emit(A64_SDIV(is64, tmp, dst, tmp2), ctx);
|
||||||
emit(A64_MSUB(is64, dst, dst, tmp, tmp2), ctx);
|
emit(A64_MSUB(is64, dst, dst, tmp, tmp2), ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_ALU | BPF_LSH | BPF_K:
|
case BPF_ALU | BPF_LSH | BPF_K:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user