Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4164235imm; Mon, 17 Sep 2018 09:09:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbE7f54YJjWVKEY0YSypbyG0g5yvKu6CDXGODj5EROiTlKdaqhGEfTKcI322SnM1WBYO/KP X-Received: by 2002:a62:e511:: with SMTP id n17-v6mr26423751pff.210.1537200595642; Mon, 17 Sep 2018 09:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537200595; cv=none; d=google.com; s=arc-20160816; b=FUfjbSmdKQV4TGXzTdw5UFSFzNhwtI9w3TlprNC69I584bVVSTiGZN7dTyQXlv1qv/ fnLRGGmV6MD3tXlmpdNx7tmK84attImsy1SxIhXEXOm7QlFuSRXXesaga6yE6+wm2h0A jZuLP/kKjqORmr2Sp5pZowK50geqN6fVdrNicog4WkNjcB5R6WCXCAAuSXS+r4ntBf9r l5HyBMo5Mc2ketkFQU9KbAKkWJ4ARL3wHnONHmaDNoQUOn4O9lWLGJ8Wdn/q1SIgT5zu E5UztW6Fg073T6DWLRjuVV6Rm2mMtHq7nQhJKpibERuIR+Namp78M60o0/UdV2zP32Gi MN8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pNqwqQnz4EGOq1/TTURRKnrXuhvIAHkMglQNn8uJk4Q=; b=uds6DMs4mHc0wu6Lv+JLFX+3ISu+Ar06Cami3n4uKrwLQl3gjwZU8USjvsvKHKAM9x V+X13ZyOA2FV0zhvGAx7NDROLaYB71CdzOUHJHBDFc21LO5hKb9rKTB5s34ArBtfJHNC X3/W0KTZsUvLLp2BTygJQm+QqXvE9Z7a0Zq/b5oyMNwvXjVAu4L+ap85r7RFlydngDHw NeAZp1lIlw3WT99d0boGfVrZmXP3rU9e49XOo9LzXjkBHDlR0WGuklzF1k98mgHeU7ma uvpoxNI5bKplkwod0qSWei+AHuikEJwqlc6M2aXMe6IUGzICem+8pBV/vlkSFXETEWkm Jq+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=Xiw0QJUl; 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 z11-v6si13580814pgv.138.2018.09.17.09.09.40; Mon, 17 Sep 2018 09:09:55 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=Xiw0QJUl; 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 S1728549AbeIQVf6 (ORCPT + 99 others); Mon, 17 Sep 2018 17:35:58 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39684 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728536AbeIQVf6 (ORCPT ); Mon, 17 Sep 2018 17:35:58 -0400 Received: by mail-wm1-f65.google.com with SMTP id q8-v6so10323943wmq.4 for ; Mon, 17 Sep 2018 09:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pNqwqQnz4EGOq1/TTURRKnrXuhvIAHkMglQNn8uJk4Q=; b=Xiw0QJUl/GH0zoQiQmk4+RLnDjSa5++CnMI3To4SxZS1YdappA99SOW6lJLt5iXell srS4itb23rrv/S9UI4e/XprFjWG6R4yhhuqASv9o7Mjqcgl1GeVmLFmvW7lvE5prs4f9 JpwR/mMta4iIXxV2QzWqF5EDuCikG2hELHLzqRuUjku5kD49G01QRwRrcVTEPGmjNcdR 5OrZ5e5cdgm5lJftkpzRq6t6FYG9i+prcUvoCMAYBjeyE6WLqLrxmwuYE9+rI9e7n1kT F+4766xrreDvGOUDfEA0yb2OIQO3nPXCaD4DZsUEWkqWxdf7qcttCndJdAFkvPEYEwPl z7Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pNqwqQnz4EGOq1/TTURRKnrXuhvIAHkMglQNn8uJk4Q=; b=UUXA3xipgjX0KfkwaqVW2kqE/HH8XL41z70DyT3HmH1DlX83I7y9HXuH4tUyDfJKf4 E7y5dn9XJGJy374CwDbphht+qSEQuMskeuxWSwqhuadXFjVyNw0zrbh5IIsleU9i4fIg 7exu/SsQIOnkZ0thUsKGHteHwcL/6icIFd5hoOqPlEeTGW7QE4JrOTRG54ami7rA4d10 aH6gZ6ytEBYjxioxPLX88Az/Sl9KR0IOYnhvT7/NKa9cqmTJs8Gm47LzIP1X3MvX0Krx SzRHz0cGTueIxat5ZSYk4Q33URSM0HQ3zEKpIl7NZprA8RFTqas83uKpFD1U3PhxtaAo EEvQ== X-Gm-Message-State: APzg51D9P6Cpkipjekfz7Yd9pQYV2hIxYNklFNk5hE+qUivnU65Bvn5y Z9cFKwEF+TmODsRXyHZVnfhD3QQHUzQGU4P+JXTIQw== X-Received: by 2002:a1c:cbc1:: with SMTP id b184-v6mr12281012wmg.149.1537200476040; Mon, 17 Sep 2018 09:07:56 -0700 (PDT) MIME-Version: 1.0 References: <20180911214737.GA81235@gmail.com> <20180911233015.GD11474@lunn.ch> <20180911.165739.2032677219588723041.davem@davemloft.net> <35BC21D7-01F4-4F91-A7E9-8D15DE5B95D6@amacapital.net> In-Reply-To: From: Andy Lutomirski Date: Mon, 17 Sep 2018 09:07:43 -0700 Message-ID: Subject: Re: [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library To: "Jason A. Donenfeld" Cc: Ard Biesheuvel , Andrew Lutomirski , "David S. Miller" , andrew@lunn.ch, Eric Biggers , Greg KH , LKML , Network Development , Samuel Neves , Jean-Philippe Aumasson , Linux Crypto Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 17, 2018 at 8:32 AM Jason A. Donenfeld wrote: > > On Mon, Sep 17, 2018 at 4:52 PM Andy Lutomirski wrote: > > I think the module organization needs to change. It needs to be possible to have chacha20 built in but AES or whatever as a module. > > Okay, I'll do that for v5. > > > I might have agreed before Spectre :(. Unfortunately, unless we do some magic, I think the code would look something like: > > > > if (static_branch_likely(have_simd)) arch_chacha20(); > > > > ...where arch_chacha20 is a *pointer*. And that will generate a retpoline and run very, very slowly. (I just rewrote some of the x86 entry code to eliminate one retpoline. I got a 5% speedup on some tests according to the kbuild bot.) > > Actually, the way it works now benefits from the compilers inliner and > the branch predictor. I benchmarked this without any retpoline > slowdowns, and the branch predictor becomes correct pretty much all > the time. We can tinker with this after the initial merge, if you > really want, but avoiding function pointers and instead using ordinary > branches really winds up being quite fast. Indeed. What I'm saying is that you shouldn't refactor it this way because it will be slow. I agree it would be conceptually nice to be able to blacklist a chacha20_x86_64 module to disable the asm, but I think it would be very hard to get good performance. --Andy