From patchwork Sat Jan 26 17:26:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiong Wang X-Patchwork-Id: 1031486 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="SvV/GtDa"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43n2rC0tNFz9s7h for ; Sun, 27 Jan 2019 04:26:51 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726453AbfAZR0p (ORCPT ); Sat, 26 Jan 2019 12:26:45 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33774 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbfAZR0c (ORCPT ); Sat, 26 Jan 2019 12:26:32 -0500 Received: by mail-wr1-f68.google.com with SMTP id p7so13486747wru.0 for ; Sat, 26 Jan 2019 09:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v9MyCkZWj+L/Jok6mfhN+dWDp/cT5qxxTiU3XYAYAd0=; b=SvV/GtDaSOxjC+zC/+1LyPW1Vzx/3VhgtbP+hTZGjjtNtYWzdaCxQtcW4VgPjZER5M qAYjt53/YYX/qsJUmmoPWjOEiACKgAOCCBxeQNfvFlS4Jv1Xwuhlyrp+Cbv3dtkIQBD5 964o1xplSnBBfHyPIPPTIPpr/QAFFOlgqR2VAAUkZg5R+SEjtGCzs/eJAi/QopeccTPr fiXHcOnlx8hOQeZcsKKFlkcsarT21qq92oxkafl3RIZUu/yk3Zdf/rg+gpN7nLVG8myf szVzgObaZt5pbA4iuCbwGXzEnRA5+LsRr8GxPC7VQUhl9SBCdK5nvUHMXYQMgaUzV81P aEUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v9MyCkZWj+L/Jok6mfhN+dWDp/cT5qxxTiU3XYAYAd0=; b=KP09kjXu2Ayca/iP1v5BmfdhtAB9uqgap1WvVDIcOfy9I5eKdJsEAqcUz7zlXa19L2 RI8UkhglNJ2WBIv2FM07bG4EQ08unKfrRgQjr+SFOItngA+eD+Pio1u+jIt6MNBPxVQY 3+IBoR4RWShKKNc36Oox/us4M5ugXyrQD9C+5UZpt/3P7CYUVF3LYTB5HqfcuLxxDZt5 D+alCGKvhj0EM4pP1x2hF9SccfJRNZOXyJrL9HJwD9bJL8aTmaoul2X5uu/Bh4KCu3+I +mZqXhpc3XEaMgZc3mrtqJbQc4RIrNGQmGfxhyIIrPYsE0guwFoPIZyI4pUnaRovvVeR lNfg== X-Gm-Message-State: AJcUukfpMokuRMpCANDuf8i0rHNNLoiu2fLECDrfOnbDjHHY8+hFwQPL R/LYnf/y0G2ZSKr0W58Pt07vXg== X-Google-Smtp-Source: ALg8bN4hWDDgK8oy18f/0FKiv1ZcJUMhb8ivcCjzrHI4+XpLd+ceYZ9kiMeczPDkDtKBGX2DFTG1Yg== X-Received: by 2002:adf:b190:: with SMTP id q16mr15706788wra.95.1548523590620; Sat, 26 Jan 2019 09:26:30 -0800 (PST) Received: from cbtest28.netronome.com ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id g188sm84426444wmf.32.2019.01.26.09.26.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Jan 2019 09:26:29 -0800 (PST) From: Jiong Wang To: ast@kernel.org, daniel@iogearbox.net Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Jiong Wang , Zi Shen Lim Subject: [PATCH bpf-next v4 10/16] arm64: bpf: implement jitting of JMP32 Date: Sat, 26 Jan 2019 12:26:08 -0500 Message-Id: <1548523574-18316-11-git-send-email-jiong.wang@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548523574-18316-1-git-send-email-jiong.wang@netronome.com> References: <1548523574-18316-1-git-send-email-jiong.wang@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch implements code-gen for new JMP32 instructions on arm64. Cc: Daniel Borkmann Cc: Alexei Starovoitov Cc: Zi Shen Lim Signed-off-by: Jiong Wang --- arch/arm64/net/bpf_jit_comp.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 1542df0..aaddc02 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -362,7 +362,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, const s16 off = insn->off; const s32 imm = insn->imm; const int i = insn - ctx->prog->insnsi; - const bool is64 = BPF_CLASS(code) == BPF_ALU64; + const bool is64 = BPF_CLASS(code) == BPF_ALU64 || + BPF_CLASS(code) == BPF_JMP; const bool isdw = BPF_SIZE(code) == BPF_DW; u8 jmp_cond; s32 jmp_offset; @@ -559,7 +560,17 @@ 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); + case BPF_JMP32 | BPF_JEQ | BPF_X: + case BPF_JMP32 | BPF_JGT | BPF_X: + case BPF_JMP32 | BPF_JLT | BPF_X: + case BPF_JMP32 | BPF_JGE | BPF_X: + case BPF_JMP32 | BPF_JLE | BPF_X: + case BPF_JMP32 | BPF_JNE | BPF_X: + case BPF_JMP32 | BPF_JSGT | BPF_X: + case BPF_JMP32 | BPF_JSLT | BPF_X: + case BPF_JMP32 | BPF_JSGE | BPF_X: + case BPF_JMP32 | BPF_JSLE | BPF_X: + emit(A64_CMP(is64, dst, src), ctx); emit_cond_jmp: jmp_offset = bpf2a64_offset(i + off, i, ctx); check_imm19(jmp_offset); @@ -601,7 +612,8 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, emit(A64_B_(jmp_cond, jmp_offset), ctx); break; case BPF_JMP | BPF_JSET | BPF_X: - emit(A64_TST(1, dst, src), ctx); + case BPF_JMP32 | BPF_JSET | BPF_X: + emit(A64_TST(is64, dst, src), ctx); goto emit_cond_jmp; /* IF (dst COND imm) JUMP off */ case BPF_JMP | BPF_JEQ | BPF_K: @@ -614,12 +626,23 @@ 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); + case BPF_JMP32 | BPF_JEQ | BPF_K: + case BPF_JMP32 | BPF_JGT | BPF_K: + case BPF_JMP32 | BPF_JLT | BPF_K: + case BPF_JMP32 | BPF_JGE | BPF_K: + case BPF_JMP32 | BPF_JLE | BPF_K: + case BPF_JMP32 | BPF_JNE | BPF_K: + case BPF_JMP32 | BPF_JSGT | BPF_K: + case BPF_JMP32 | BPF_JSLT | BPF_K: + case BPF_JMP32 | BPF_JSGE | BPF_K: + case BPF_JMP32 | BPF_JSLE | BPF_K: + emit_a64_mov_i(is64, tmp, imm, ctx); + emit(A64_CMP(is64, 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); + case BPF_JMP32 | BPF_JSET | BPF_K: + emit_a64_mov_i(is64, tmp, imm, ctx); + emit(A64_TST(is64, dst, tmp), ctx); goto emit_cond_jmp; /* function call */ case BPF_JMP | BPF_CALL: