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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED 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 172DCC04A6B for ; Mon, 6 May 2019 23:19:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6D92206BF for ; Mon, 6 May 2019 23:19:26 +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="oBrI4gK6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfEFXTZ (ORCPT ); Mon, 6 May 2019 19:19:25 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53855 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfEFXTZ (ORCPT ); Mon, 6 May 2019 19:19:25 -0400 Received: by mail-wm1-f68.google.com with SMTP id 198so12667wme.3 for ; Mon, 06 May 2019 16:19:24 -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=9cZLP6fo4MDd86K+wDwoMo5fbYSVGBhrzMdAO/+1uHs=; b=oBrI4gK6UIKtBxmx1CdcwL0e9gHr5osvz0nUTmr/xgCsGomyCXhhcy78LMoOeEEnQe PW0Q28Y7Ol+SL3DuSurae4TSxzxbSxd869yQQaGbDn36dwtuaOHAMUy61vAAMO499CPX dmAGy/dgEj4vvMFfxdDWbmqtUNIMlJ2O0LoV8FApQFjPypYFw3tZsrywIrDlR2TTLCZA NZ1K6RbDOqugbTcLlIO6tQvgpSPu0WRATCCjSvtHN8720pfl3sHHexEi74w3BxmNdHbR bVeGekTwZO51TNMyHyFlt+L8t2Sh7KMQtraLEzOQf5xsaQGCRPiX64GTHiD2pUmIqvyE s36A== 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=9cZLP6fo4MDd86K+wDwoMo5fbYSVGBhrzMdAO/+1uHs=; b=WehN05S6txOksmRRnkUx5T5YpD8T+0Qc0s+Dkxs07oq5XKBSQOauRUsiuunzJVZ4p4 +6KEwBl2cWJLxRLZbP2kp/mBjdGO5R1ipHLnJxUn/ONcxBjKd926DMpeFji9r+LirPEA GrFm+87UtmKqIjg2Y/Yr+q0NdGNTIlZWk2wt3XUv/u12zH71jZFcfEuZ6n8QAWZEuhTN oGV953JqNEohadmm9kvsrYNxoOg+vqkaA+nCQw4f+3vOLibBQ/fzS2XnFAujJ0sd4kHK 7HTsQSPxohfJ+odMlLcarH+UWx9oiwjrleMDtBe1cqRBtPuQueijyf6Vi4Q+jW18uecT yTgw== X-Gm-Message-State: APjAAAUVNEJ/SvTAD/bDhJC+i+SNxDmpnYYlXOC1Jsv8UkkvvWCZEeSE 7/+2YGeMeGIDRV2lrYk8+sZOTqs3fPY= X-Google-Smtp-Source: APXvYqwaDCm9YWV/gp6Sz1pJ5uRToyWR44Eeyy/DycJ5MGiwj+/iwiT1dPwBQ/82YZjsOmXPlCHBYw== X-Received: by 2002:a1c:6342:: with SMTP id x63mr18564737wmb.58.1557184763777; Mon, 06 May 2019 16:19:23 -0700 (PDT) Received: from LAPTOP-V3S7NLPL (cpc1-cmbg19-2-0-cust104.5-4.cable.virginm.net. [82.27.180.105]) by smtp.gmail.com with ESMTPSA id f2sm21506653wmh.3.2019.05.06.16.19.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2019 16:19:21 -0700 (PDT) References: <1556880164-10689-1-git-send-email-jiong.wang@netronome.com> <1556880164-10689-5-git-send-email-jiong.wang@netronome.com> <20190506155704.4t7xy3mqer4eps3y@ast-mbp> User-agent: mu4e 0.9.18; emacs 25.2.2 From: Jiong Wang To: Alexei Starovoitov Cc: Jiong Wang , 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 In-reply-to: <20190506155704.4t7xy3mqer4eps3y@ast-mbp> Date: Tue, 07 May 2019 00:19:19 +0100 Message-ID: <87imunuq6g.fsf@netronome.com> MIME-Version: 1.0 Content-Type: text/plain Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Alexei Starovoitov writes: > 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 Hmm, I am silly, in v6, patched insn will be conservatively marked as always needing zext, so looks like no problem to just insert mov32 as zext. But some backends needs minor opt, because this will be special mov, with the same src and dst, just need to clear high 32-bit, no need of mov. Regards, Jiong