From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3464C48BD6 for ; Thu, 27 Jun 2019 12:18:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5A4B2085A for ; Thu, 27 Jun 2019 12:18:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="k8ywuutI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbfF0MSj (ORCPT ); Thu, 27 Jun 2019 08:18:39 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53820 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726725AbfF0MSj (ORCPT ); Thu, 27 Jun 2019 08:18:39 -0400 Received: by mail-wm1-f66.google.com with SMTP id x15so5519817wmj.3 for ; Thu, 27 Jun 2019 05:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=Zdd4Pp3dYlawoEQsjCTjL1Bm9eBCVbOZ/q37LUapnaQ=; b=k8ywuutI5JJ1zOZBUSRsiA6wF2HW/8zzohHwXhnHqAE4EOXoGZ6iion4AWL7kpTwR6 qAY+CpaQo3wjcaUtdet5Ew+axkm4VjOnlrKl9HBABghASKurGPUynYSpaOP4PU+6mece z7xORIC5BZJAMxRKJwKl4WQ6E0fiVnWmR9t39mGB2/DytymcTWatNM/SRNdT8DoCixeQ eudI3hm86XZDcojtmkzCOfoFGiokZRxpQQutxIzHUgMQAA339QF1UW1S2h7QIsQlNetS 1vsloMKS2mL8TAN9kbK+Zjz8hEQZ7WBEOJKvJIoBDSTqwV5KXBqHBppJN9/PdbPQ+IiX mvDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=Zdd4Pp3dYlawoEQsjCTjL1Bm9eBCVbOZ/q37LUapnaQ=; b=uiwvCqHy2zineo01Xqmv8/Jnys1AjVyXG6Y0NB64fboiuHzjS6U0AA1wPn55FClfoM mKV2rLShIh7Rm5dRLTf7ksuFCK82Apq7lOujfrhCYX/yEyR/u9umuPJJERoaA+/C9r1s 43X7gmZjrMbvZMg8GDyKWhbsk35ZV05Dc21CKYXoROEznm11jvpd0XmH5PaegoCUHCLW 2tbEua5ZbM1iTF6cLenelgpS+7O3Zd1lYN8b0WM1wy7KSbXAtgQ6D3cNI8oid3/KAAsg SeJDKyINkF4W/sqql5qowLILy7S4UEA9d+OAqTjM2uQiyvhoao+v3tt4F503rxDIj1Mp u06g== X-Gm-Message-State: APjAAAV3tiHXWjiu/xP2Epio6+nmGF9hT71hXK1xLPeUnz6BZpiVu0ED 9Bjp/JZoO40FF8wT9Y3w5qao8bMoQiA= X-Google-Smtp-Source: APXvYqwP5/KqbmGqmRh+sNx5VCR+6gZxpNd+GAZ3G0BUulrp4g0b6pfWHwk+3cirqW7BcslJWBkoWg== X-Received: by 2002:a1c:7a01:: with SMTP id v1mr3202693wmc.10.1561637917201; Thu, 27 Jun 2019 05:18:37 -0700 (PDT) Received: from LAPTOP-V3S7NLPL ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id l19sm3291337wmj.33.2019.06.27.05.18.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2019 05:18:36 -0700 (PDT) References: <20190626231257.14495-1-lukenels@cs.washington.edu> User-agent: mu4e 0.9.18; emacs 25.2.2 From: Jiong Wang To: Luke Nelson Cc: linux-kernel@vger.kernel.org, Luke Nelson , Xi Wang , Palmer Dabbelt , Albert Ou , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , =?utf-8?B?QmrDtnJu?= =?utf-8?B?IFTDtnBlbA==?= , linux-riscv@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v2 bpf-next] RV32G eBPF JIT In-reply-to: <20190626231257.14495-1-lukenels@cs.washington.edu> Date: Thu, 27 Jun 2019 13:18:35 +0100 Message-ID: <87y31nuspw.fsf@netronome.com> MIME-Version: 1.0 Content-Type: text/plain Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Luke Nelson writes: > + > +static int emit_insn(const struct bpf_insn *insn, > + struct rv_jit_context *ctx, > + bool extra_pass) > +{ > + int rvoff, i = insn - ctx->prog->insnsi; > + u8 code = insn->code; > + s16 off = insn->off; > + s32 imm = insn->imm; > + > + const s8 *dst = bpf2rv32[insn->dst_reg]; > + const s8 *src = bpf2rv32[insn->src_reg]; > + const s8 *tmp1 = bpf2rv32[TMP_REG_1]; > + const s8 *tmp2 = bpf2rv32[TMP_REG_2]; > + > + switch (code) { > + case BPF_ALU64 | BPF_MOV | BPF_X: > + if (imm == 1) { > + /* Special mov32 for zext */ > + emit_rv32_zext64(dst, ctx); > + break; > + } Thanks for adding the 32-bit opt! Just want to mention ZEXT is a special mov32, see include/linux/filter.h: #define BPF_ZEXT_REG(DST) ((struct bpf_insn) { .code = BPF_ALU | BPF_MOV | BPF_X So it can't be BPF_ALU64. It is safe to remove this chunk of code. For backend like arm, riscv etc, they are grouping several CASE label together and are sharing code. imm == 1 check is done inside the shared code to avoid moving code around given imm == 1 can't be true for ALU64 as if there is such insn (register format using imm) it should have been rejected by verifier. While mov32 variant is inserted by verifier at very late stage after main verification finished. Regards, Jiong From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1498AC48BD6 for ; Thu, 27 Jun 2019 12:18:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC96C2086D for ; Thu, 27 Jun 2019 12:18:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VpnbG6u8"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="k8ywuutI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC96C2086D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=netronome.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date: In-reply-to:Subject:To:From:References:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fa/pe0zd4ddmPErGWGqk/OzUCH794sSRuz/J8tK2D4o=; b=VpnbG6u8MMVxgEYt6K/ITYF+GD 0+BJZOr50gYn5LPBctJVwturbphugKVj0VyLJkm0SxdxHv5/yFBrDYWKNMPBqJlC6JS4mP8GnlRaq 2xdarIru+Z0asmSMnLRUO8rWSy5SqJvBqeLj+tZnE4tNXfrO3rZPTTPj1T+9OfOgk+BStVbexMnaT yL+7OduGf1iPIGa9875qLbduSJZu2fjwFhy7lkZVQCG0U5j16AvYngRg+fAbP8/FcwiKavK+ag034 1YTazv9QD+4bL50fcVZsE+CBmsWMqhs5zhG858cQlkLai0BH8+SI9RAt+6otg2ctiqH7u7CZZSb2M q6PKyTCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgTMP-0005kF-Po; Thu, 27 Jun 2019 12:18:41 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hgTMN-0005jp-4F for linux-riscv@lists.infradead.org; Thu, 27 Jun 2019 12:18:40 +0000 Received: by mail-wm1-x343.google.com with SMTP id z23so5460125wma.4 for ; Thu, 27 Jun 2019 05:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=Zdd4Pp3dYlawoEQsjCTjL1Bm9eBCVbOZ/q37LUapnaQ=; b=k8ywuutI5JJ1zOZBUSRsiA6wF2HW/8zzohHwXhnHqAE4EOXoGZ6iion4AWL7kpTwR6 qAY+CpaQo3wjcaUtdet5Ew+axkm4VjOnlrKl9HBABghASKurGPUynYSpaOP4PU+6mece z7xORIC5BZJAMxRKJwKl4WQ6E0fiVnWmR9t39mGB2/DytymcTWatNM/SRNdT8DoCixeQ eudI3hm86XZDcojtmkzCOfoFGiokZRxpQQutxIzHUgMQAA339QF1UW1S2h7QIsQlNetS 1vsloMKS2mL8TAN9kbK+Zjz8hEQZ7WBEOJKvJIoBDSTqwV5KXBqHBppJN9/PdbPQ+IiX mvDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=Zdd4Pp3dYlawoEQsjCTjL1Bm9eBCVbOZ/q37LUapnaQ=; b=QuN5GtYFX4FrXLmryFVKHq6PhR3e+75svIF2kPAzpeqUx+ghPXHcC7vIG3P0grUYDY PMcLShxgKVNc4qI9fXtO/UUmnL8QHmZ0uabLEkFJxiLskia/DERaVZilfypDSbagtISD L2MLfzk6beM+uOTHVKLAAPyiC/2Vj0HiiBjNGmm91c9SMXHblAQC5s/aNSEmI/m76mie rT/3v5/sOuklKMD3Vn/WUzSoJkGCQPG5SnFa3A3PFvFB8TroRGBMf0PYXJQFGdUZN8pN eDwbqt3nK/0GIyN/7555SUieoy97CI8CKWwbZfZDqLpmRiVjHM3wSxo4uJhS2+uXMGKK ilPw== X-Gm-Message-State: APjAAAVLxUhQCimJMx0AwkbnlLKnppip7LQN82lM1EPzaKiCTCUNbsmJ XPNdupv6AIkLp12PgOszfftN9Q== X-Google-Smtp-Source: APXvYqwP5/KqbmGqmRh+sNx5VCR+6gZxpNd+GAZ3G0BUulrp4g0b6pfWHwk+3cirqW7BcslJWBkoWg== X-Received: by 2002:a1c:7a01:: with SMTP id v1mr3202693wmc.10.1561637917201; Thu, 27 Jun 2019 05:18:37 -0700 (PDT) Received: from LAPTOP-V3S7NLPL ([217.38.71.146]) by smtp.gmail.com with ESMTPSA id l19sm3291337wmj.33.2019.06.27.05.18.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2019 05:18:36 -0700 (PDT) References: <20190626231257.14495-1-lukenels@cs.washington.edu> User-agent: mu4e 0.9.18; emacs 25.2.2 From: Jiong Wang To: Luke Nelson Subject: Re: [PATCH v2 bpf-next] RV32G eBPF JIT In-reply-to: <20190626231257.14495-1-lukenels@cs.washington.edu> Date: Thu, 27 Jun 2019 13:18:35 +0100 Message-ID: <87y31nuspw.fsf@netronome.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190627_051839_232671_75A64D0B X-CRM114-Status: UNSURE ( 7.55 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , Albert Ou , bpf@vger.kernel.org, Daniel Borkmann , Luke Nelson , =?utf-8?B?QmrDtnJu?= =?utf-8?B?IFTDtnBlbA==?= , Palmer Dabbelt , Alexei Starovoitov , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Yonghong Song , linux-riscv@lists.infradead.org, Martin KaFai Lau , Xi Wang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org Luke Nelson writes: > + > +static int emit_insn(const struct bpf_insn *insn, > + struct rv_jit_context *ctx, > + bool extra_pass) > +{ > + int rvoff, i = insn - ctx->prog->insnsi; > + u8 code = insn->code; > + s16 off = insn->off; > + s32 imm = insn->imm; > + > + const s8 *dst = bpf2rv32[insn->dst_reg]; > + const s8 *src = bpf2rv32[insn->src_reg]; > + const s8 *tmp1 = bpf2rv32[TMP_REG_1]; > + const s8 *tmp2 = bpf2rv32[TMP_REG_2]; > + > + switch (code) { > + case BPF_ALU64 | BPF_MOV | BPF_X: > + if (imm == 1) { > + /* Special mov32 for zext */ > + emit_rv32_zext64(dst, ctx); > + break; > + } Thanks for adding the 32-bit opt! Just want to mention ZEXT is a special mov32, see include/linux/filter.h: #define BPF_ZEXT_REG(DST) ((struct bpf_insn) { .code = BPF_ALU | BPF_MOV | BPF_X So it can't be BPF_ALU64. It is safe to remove this chunk of code. For backend like arm, riscv etc, they are grouping several CASE label together and are sharing code. imm == 1 check is done inside the shared code to avoid moving code around given imm == 1 can't be true for ALU64 as if there is such insn (register format using imm) it should have been rejected by verifier. While mov32 variant is inserted by verifier at very late stage after main verification finished. Regards, Jiong _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv