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=-8.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT autolearn=unavailable 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 673F7C04AAD for ; Mon, 6 May 2019 15:57:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 321312087F for ; Mon, 6 May 2019 15:57:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a93yuSfh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726571AbfEFP5I (ORCPT ); Mon, 6 May 2019 11:57:08 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35448 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726413AbfEFP5I (ORCPT ); Mon, 6 May 2019 11:57:08 -0400 Received: by mail-pl1-f196.google.com with SMTP id w24so6592616plp.2; Mon, 06 May 2019 08:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bBlrHQhW5FuglB+kG3W3afIDPM/nbvUWlv4S88e8oJc=; b=a93yuSfhXaCyZmvdAOrF02fjXI7eaZ/+VB665uI/I4CIka6NCWz9HZSUigTE2Gqcq8 nWNIL29nUn57xruu16pMYDXQ1B7qPQT95kCBE9I1aQ2nem1+6sgXJnT17Lga250Gwyba yNlNfW/vicwK2SceTtthnCV0FRS0wrT9MPoU4eMuy+fsND/nHFPH1tjxUKqjlLDQeiC0 JhBmajDirAxG5ydyTZyCAHATdbB6dkP8rl4SxhnUpXPEO3w873ls6ymBLLcCBufMZIvB vtno2nveMB+XirjlTE4Q72b3DVDbDBMyzA6n1mCeXMtF49n9B+/ACEPrKdOsGhH2dbX1 I9hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bBlrHQhW5FuglB+kG3W3afIDPM/nbvUWlv4S88e8oJc=; b=d9UPtyT2TtiJ5Dr3f5AR4Jl0aBZZfnUBlmO/KZl4xirw7Ub3Wpb2c5duRAOQIiwL/E 7EKUGtX6K4SK4LKosAtSrtzzlBqG5OJwSK6LizuLsAI6IfV3rzvWYnklDUcBtwCtkVmg 3yL18rr+QGJw+eflK/3oiL267fU9PvKOhrhGWU6Aoeldf0tgi2pW5ZKu5hKvknrku+0N P89KtiV9cQMQf3odjSU5E5KZ9+GT+DmLFKTQE4GKHB8yjuudIGj4dj5hPljhsYAVSEgB /5tGddzs412ATLwcc0ubRn4+PNlXHW2uybdg+p1xmGlwPfFSei3VHbzGsdCNpkQFz3Eo H3gg== X-Gm-Message-State: APjAAAUFD4TtbOSYXOAH8gBJfH75nCCW+QAh08bj9lW0aIwaGPWlWr01 MyvI4j+8HXNz/EKKAF6qEM4= X-Google-Smtp-Source: APXvYqxTiwL7O2TBjD3qHxjvxbe0TW5B9oFs1us6wnstI0buQKUPdl9Ijukt9HO0BYWszeDyC5SAuA== X-Received: by 2002:a17:902:521:: with SMTP id 30mr32385674plf.248.1557158227780; Mon, 06 May 2019 08:57:07 -0700 (PDT) Received: from ast-mbp ([2620:10d:c090:200::3:1919]) by smtp.gmail.com with ESMTPSA id d15sm7149299pgf.22.2019.05.06.08.57.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 08:57:06 -0700 (PDT) Date: Mon, 6 May 2019 08:57:06 -0700 From: Alexei Starovoitov To: Jiong Wang Cc: daniel@iogearbox.net, bpf@vger.kernel.org, netdev@vger.kernel.org, oss-drivers@netronome.com Subject: Re: [PATCH v6 bpf-next 04/17] bpf: introduce new alu insn BPF_ZEXT for explicit zero extension Message-ID: <20190506155704.4t7xy3mqer4eps3y@ast-mbp> References: <1556880164-10689-1-git-send-email-jiong.wang@netronome.com> <1556880164-10689-5-git-send-email-jiong.wang@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556880164-10689-5-git-send-email-jiong.wang@netronome.com> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, May 03, 2019 at 11:42:31AM +0100, Jiong Wang wrote: > This patch introduce new alu32 insn BPF_ZEXT, and allocate the unused > opcode 0xe0 to it. > > Compared with the other alu32 insns, zero extension on low 32-bit is the > only semantics for this instruction. It also allows various JIT back-ends > to do optimal zero extension code-gen. > > BPF_ZEXT is supposed to be encoded with BPF_ALU only, and is supposed to be > generated by the latter 32-bit optimization code inside verifier for those > arches that do not support hardware implicit zero extension only. > > It is not supposed to be used in user's program directly at the moment. > Therefore, no need to recognize it inside generic verification code. It > just need to be supported for execution on interpreter or related JIT > back-ends. uapi and the doc define it, but "it is not supposed to be used" ?! > Signed-off-by: Jiong Wang > --- > Documentation/networking/filter.txt | 10 ++++++++++ > include/uapi/linux/bpf.h | 3 +++ > kernel/bpf/core.c | 4 ++++ > tools/include/uapi/linux/bpf.h | 3 +++ > 4 files changed, 20 insertions(+) > > diff --git a/Documentation/networking/filter.txt b/Documentation/networking/filter.txt > index 319e5e0..1cb3e42 100644 > --- a/Documentation/networking/filter.txt > +++ b/Documentation/networking/filter.txt > @@ -903,6 +903,16 @@ If BPF_CLASS(code) == BPF_ALU or BPF_ALU64 [ in eBPF ], BPF_OP(code) is one of: > BPF_MOV 0xb0 /* eBPF only: mov reg to reg */ > BPF_ARSH 0xc0 /* eBPF only: sign extending shift right */ > BPF_END 0xd0 /* eBPF only: endianness conversion */ > + BPF_ZEXT 0xe0 /* eBPF BPF_ALU only: zero-extends low 32-bit */ > + > +Compared with BPF_ALU | BPF_MOV which zero-extends low 32-bit implicitly, > +BPF_ALU | BPF_ZEXT zero-extends low 32-bit explicitly. Such zero extension is wait. that's an excellent observation. alu|mov is exactly it. we do not need another insn. we probably can teach the verifier to recognize <<32, >>32 and replace with mov32