This patch implements code-gen for new JMP32 instructions on arm64.

Cc: Daniel Borkmann <dan...@iogearbox.net>
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Zi Shen Lim <zlim....@gmail.com>

Signed-off-by: Jiong Wang <jiong.w...@netronome.com>
---
 arch/arm64/net/bpf_jit_comp.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 1542df0..9ed73af 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -559,7 +559,7 @@ static int build_insn(const struct bpf_insn *insn, struct 
jit_ctx *ctx,
        case BPF_JMP | BPF_JSLT | BPF_X:
        case BPF_JMP | BPF_JSGE | BPF_X:
        case BPF_JMP | BPF_JSLE | BPF_X:
-               emit(A64_CMP(1, dst, src), ctx);
+               emit(A64_CMP(!!imm, dst, src), ctx);
 emit_cond_jmp:
                jmp_offset = bpf2a64_offset(i + off, i, ctx);
                check_imm19(jmp_offset);
@@ -614,9 +614,13 @@ static int build_insn(const struct bpf_insn *insn, struct 
jit_ctx *ctx,
        case BPF_JMP | BPF_JSLT | BPF_K:
        case BPF_JMP | BPF_JSGE | BPF_K:
        case BPF_JMP | BPF_JSLE | BPF_K:
-               emit_a64_mov_i(1, tmp, imm, ctx);
-               emit(A64_CMP(1, dst, tmp), ctx);
+       {
+               bool is_jmp32 = !!insn->src_reg;
+
+               emit_a64_mov_i(is_jmp32, tmp, imm, ctx);
+               emit(A64_CMP(is_jmp32, dst, tmp), ctx);
                goto emit_cond_jmp;
+       }
        case BPF_JMP | BPF_JSET | BPF_K:
                emit_a64_mov_i(1, tmp, imm, ctx);
                emit(A64_TST(1, dst, tmp), ctx);
-- 
2.7.4

Reply via email to