Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2006771ybd; Thu, 27 Jun 2019 05:19:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzs0HcM3Amrm8XritHmLZiedIkRSwzEz6OJOgDDaiIiHNBGtdy+VlWeTUDCEIbBflfrl6w1 X-Received: by 2002:a63:2b91:: with SMTP id r139mr3576771pgr.309.1561637944153; Thu, 27 Jun 2019 05:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561637944; cv=none; d=google.com; s=arc-20160816; b=Lenf62si040Kl3wbhaB8YyKzH7vCg7a4DhkdQ/XNhCybwcVk/4NOhCgxcEbYifDhc5 p+wpetd/hbgvnDlUhvNLUJW3OokEhT5FiFhR7SuYw7qr7zL4jQxwraoVow+MSDH34JIt cWddtyUNwtF8anRDR0DSrkxncrhz9sJhjxGSjCZIvApmluFgeljlncKZ0x0/PDgaO90H hcpa/Hh09ogoh0fTJv4c95bJgLgA7AxFK7NYs7bEKjDaxlnKch63BgjWkbr1taPHAOlt 48NZsixMpgxSnc1KH+CKJgfnbS0VRL1mHULNnghEhe5xgmTk0BzjasTf+hS0QfsHgwge fBzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references:dkim-signature; bh=Zdd4Pp3dYlawoEQsjCTjL1Bm9eBCVbOZ/q37LUapnaQ=; b=kNV00Gk+lIF2v+fHpL3TOklhm4o/xUdtRBnerZZuiM+2xAlIkc/aqQDeMAV7Tj8ViN VB+CfH51xAd2QHcwie+lzR1uSwT+vc0H7NoTRS1eueNnXrbiocub12yf/DWsuffPoRzL mp0+Cyrtg3G4LS80GugYaeFpoR28uyiMnC//gOo5DvcPsM2qlnF6NEKBehVCeXRNQYEx X6BRoqJ1AYMr03WAEt1r284P7jBlroObgdrAx/bA5N6RmQjrXogMOzx7F42kMaL4fXyu W8gh4ChrB5E6BbhSyY6p93lTsWKzo7UM6TGP57N/jT7c0fLhsrO0rquSwDfgT8lUfIwh Sx9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=k8ywuutI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y84si2576302pfc.33.2019.06.27.05.18.47; Thu, 27 Jun 2019 05:19:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=k8ywuutI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbfF0MSj (ORCPT + 99 others); Thu, 27 Jun 2019 08:18:39 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51611 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbfF0MSj (ORCPT ); Thu, 27 Jun 2019 08:18:39 -0400 Received: by mail-wm1-f66.google.com with SMTP id 207so5514736wma.1 for ; Thu, 27 Jun 2019 05:18:37 -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=tDRieP8bjmmuiJ037tD0G+NZG7fqsZBSH7ZrBo3wF1P+r/IT9iwhL3lQdWJs3aDHAi PYHKdJY2ZlagIhRKyPtuGH/Kvm4ifGxRpLeNFtsa069GQ+V011eYSmO52FPdgSYDmNDa 2Lhl1NJruMV9+v/6OaJ6uaB7XRX5zpk8scbkF8y62pmTWeVnv73O1RgBzrAEKHA6p4J7 OEBSoewUWRpSIo+9p1tRRoj0g9ZZ9xtm7rXV8D1+2+Ij3+ljJcMTBJmWs0kNu1bnVqMg pNpsGKvuzMcZqGSIa8EiW/JVV8GYnbWOZXsMW1pUN+PE7HLNmi6Eu+5ho9SBDpkM+EMo qnBA== X-Gm-Message-State: APjAAAXqD8DWwdY+5xza60qR5dRMyC1Ap1ffLMcPNKT/RX/Kc+GCaRqh GLfSSDEw2KbxDDlDeWWk8454Og== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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