Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2606546ybn; Thu, 26 Sep 2019 14:41:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqVvM1x2cgSzDBD0+gAqel5bOwPWA2bPhEAMSlCcNIOs0u6IlyuFk/IKbvnBbMRwxmBwEq X-Received: by 2002:a50:f19c:: with SMTP id x28mr1110061edl.42.1569534094578; Thu, 26 Sep 2019 14:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569534094; cv=none; d=google.com; s=arc-20160816; b=ROUxavoc+llZbosJIqPUe9+9r+aGXV5kvUTesh0CL+qbWdzMhljM6My3QYslOaNXd/ /XSN44WvJ17vpYPHXOCRlhnGFEs4NF4R9aM6HASn5MR4YeQVjZ/DPLkD9MYGnfug1ksH yspoW6opCzhgAi5Z4HgyV3EXDCRxdYb+k+EqiAyUcc5O1zdAs8f+HiEL/GM7Vcc3Kubm 0DDhNd9PP3VMRyVOgkLkh14o6tD3X6sL3ZKRdEBOrXmIMzEhCWMUIHHZIUitbGSvvXd0 +PbBJ1yHzMLB/6Z22Fv6KW7HQoqTV5zDwCFXYxp/C1bJX5X7nyEtNjaoFs3srhGg6LGi IZtw== 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=Md2GQkEGCU8aBh5XIsuYz4tlfy5jq/gHElxr45FqV9s=; b=fszEvqvdQBT+AmmM5y8231jESepu691dtTimRvlbMeHQdG8y9BdIje85oSaIKF18ff /HY6NDrQKuv9EMSU/MSsXVeT5Kt+fukPGLq+2awXc4JzTBnvgwQxYA0/83n4WuRPq7ZY 3xMYTNL2HudrUFQbg4VkIY5Rg/UDLziL4HaMHjPGwBWHGI/wxyxls0aRhCi4MZlAKiRT M0tLrpQBmK1yRP8lLRdh+WZfdosmC4+abhMU2CxMqzh8JLz/giPBGk75zNfTWIy83Huz 8MG9aR+CxuBRMCsmLavdu3s+BKd94qXLjf9DD6pODNVTJVnLlmH0tdDlGgE3HsJ6SKCo m0wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kGEOUXDO; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si275860edq.228.2019.09.26.14.41.03; Thu, 26 Sep 2019 14:41:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@kernel.org header.s=default header.b=kGEOUXDO; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbfIZVg7 (ORCPT + 99 others); Thu, 26 Sep 2019 17:36:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:57228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbfIZVg7 (ORCPT ); Thu, 26 Sep 2019 17:36:59 -0400 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51E9D2245B for ; Thu, 26 Sep 2019 21:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569533818; bh=OyZSdjbLBMhgPOUk+Mr6qz+tKzwnie60KWYmwf3kT3g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kGEOUXDO6eeyHW1Xmw7tTs3P94vmlGnuWYD1Q1UDfmQKO/DhLPvkWkC4NDxHOWRag RgGpPieSue/d8FN0Ds4rk1iWlcMNBeFhdZlAoK81J3SN1S/I7brj1kgVJL5ixnlvKO RfLM0pBg0iCZAsRkzSoauN4SUw9bNOAfQiqWQOCU= Received: by mail-wr1-f43.google.com with SMTP id i1so411925wro.4 for ; Thu, 26 Sep 2019 14:36:58 -0700 (PDT) X-Gm-Message-State: APjAAAWjDNeHM7cxkFZLihE+Mi3CMkQa6IGjRXHWDn9qtpVYbTNea5Zd xBvLOenkLNCG8Ph0TL0F5xjBfOMsGj0d2koBlbUeng== X-Received: by 2002:adf:cc0a:: with SMTP id x10mr348170wrh.195.1569533816729; Thu, 26 Sep 2019 14:36:56 -0700 (PDT) MIME-Version: 1.0 References: <20190925161255.1871-1-ard.biesheuvel@linaro.org> In-Reply-To: From: Andy Lutomirski Date: Thu, 26 Sep 2019 14:36:45 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 00/18] crypto: wireguard using the existing crypto API To: "Jason A. Donenfeld" Cc: Ard Biesheuvel , Linux Crypto Mailing List , linux-arm-kernel , Herbert Xu , David Miller , Greg KH , Linus Torvalds , Samuel Neves , Dan Carpenter , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Will Deacon , Marc Zyngier , Catalin Marinas Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Sep 26, 2019 at 1:52 PM Jason A. Donenfeld wrote: > > Hi Ard, > > > Our goals are that chacha20_arch() from each of these arch glues gets > included in the lib/crypto/chacha20.c compilation unit. The reason why > we want it in its own unit is so that the inliner can get rid of > unreached code and more tightly integrate the branches. For the MIPS > case, the advantage is clear. IMO this needs numbers. My suggestion from way back, which is at least a good deal of the way toward being doable, is to do static calls. This means that the common code will call out to the arch code via a regular CALL instruction and will *not* inline the arch code. This means that the arch code could live in its own module, it can be selected at boot time, etc. For x86, inlining seems a but nuts to avoid a whole mess of: if (use avx2) do_avx2_thing(); else if (use avx1) do_avx1_thing(); else etc; On x86, direct calls are pretty cheap. Certainly for operations like curve25519, I doubt you will ever see a real-world effect from inlining. I'd be surprised for chacha20. If you really want inlining to dictate the overall design, I think you need some real numbers for why it's necessary. There also needs to be a clear story for how exactly making everything inline plays with the actual decision of which implementation to use. I think it's also worth noting that LTO is coming. --Andy