Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp927213ybp; Fri, 4 Oct 2019 07:09:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/kZFfXjrlLEzR0h4ZkIAqjuc42GHfd8h2aw655ds63BhvPklc08AZxkmumCLQQUG9Ho6p X-Received: by 2002:a17:906:b2d4:: with SMTP id cf20mr12374901ejb.152.1570198148704; Fri, 04 Oct 2019 07:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570198148; cv=none; d=google.com; s=arc-20160816; b=aa5TXAMPL+fMXjZ/wXyMLHR+I7I7+T4CeB64+l7FY2VBijMKNaeoKcPftrn20EueMm B7h3YRMST2m0fivdwlRRvEwWO/lOsE8nxQQccTMj9qB9Cdj0j6pJA77iciUesChiiBNv IgiBRaWvWyK50Lk1xLYhsOsXvmFBV2Gh/SaOAJhcdpsUiN7oXRGk3EPp6Pd+uDFMpYKQ 4WNSVXwek8WldmBrptAzkdRo+bn4JTLte0fy545nF9RExoj+4v1aNUsIcaqaYeIs43Ev PjWl8YbpAfpMy9fv1W9SduLhp3VaxVzwesXgxuUZd7wbk2pClE9XWbwiZXw3Lb3yt8Zt reXA== 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=IpvBzPUgYAhrXazs0bJv+8iaRH4w1hOUIGacKnKP0NE=; b=1G+18Ve5n6wQS2dAXw52OvTho4WnSVuQMOrfNAkiglQF4l6Mzh0DnPLHTpSqHt8q/s Gbp4AjaTu+d2REwYb5mUvzh2WeYArcw9c+4S95EyA7WhXX2DIDlOWp8WeJDDph0X8fkE nTjXqj64Yl2mCpNmTvZUPXjxL5EFsf3OBj0MrnUkK2HsLtZBCaM9ug8WIYMDRtYcOrDz q2JUwiN3n+ikm5478/5n4yOeVvrbPxTs9DNeo6LToDtxN9orpK5s+oM2ZECFggI6rYZE S9SXHuZe9XYfa6hyDkFw/Bwy6iF07pCNSOA7PymnYVOB0uysnuMs1D5VHY1WoFuNvYyB v+JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MZarUObc; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si3007497ejr.180.2019.10.04.07.08.42; Fri, 04 Oct 2019 07:09:08 -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=@linaro.org header.s=google header.b=MZarUObc; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388892AbfJDOIH (ORCPT + 99 others); Fri, 4 Oct 2019 10:08:07 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35586 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388376AbfJDOIH (ORCPT ); Fri, 4 Oct 2019 10:08:07 -0400 Received: by mail-wm1-f65.google.com with SMTP id y21so6024315wmi.0 for ; Fri, 04 Oct 2019 07:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IpvBzPUgYAhrXazs0bJv+8iaRH4w1hOUIGacKnKP0NE=; b=MZarUObcVgtLvlaqMaX1d84hh+1MVtCgX9CyLlCGBc/Yb0jtArTae7g+InC7bbkCJz e9b4rke8FkBrNz8SvxuvPNnQ3mPPn/F7cL+qL8ofk8IBd0q+sUUxXQ55CnLup2YXHsxQ Z8BeYDcf/QvFpZDPjl+M/zi/eAZoCf8AKgteITbGpy/ic1+pzNFLLr9BZRFSir2O7zXu hzb2FV7/mP/fRYTtMAdpe3yGxKQGqVZjhkjrSgscV3IEqyjg/01yXmMLgTEtBalM++H7 QgPS09FrTlNN0fEvZXuiESiE6oeQgyS+rdNI5howYZ7xGmwnTprKraTaYRTbdvSO7Ug3 gYiA== 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=IpvBzPUgYAhrXazs0bJv+8iaRH4w1hOUIGacKnKP0NE=; b=B6PTS504HELbPsZ1x3N/eFkGE9Ib8qxLcjCwlfWRFNDqAtIccozlGZXcP5w+3rFB2L 7b62sAwWrEwH5YL/oQ9/demu9I34UpO/6m7IwWKeHRCMG8jHnXLIgv+22dfGnmoL4ZlI +F9ZM9iVgyjmTAhZnyJej3dyx6mPyx8nXtOn8wnGO2KdflycGl0bygmI/BKZcIqude/u QtozXJOgzf4Xpx55rg2361MI9d8gGUwW+NVaXKsZjDkDowKlKNO8opORqjK5MVZhULjy 9+SWggePrrtpw+dEwiQ1EI7gq00jIKdXEqnm9NBJd3cZLWVUcl9StUkyg8NA+0IkYS3V L3GA== X-Gm-Message-State: APjAAAVae62k3AoplMUFHfh5bC19JPF+JDO2AJwIuraF5+ZWiBU8DHna /sC4b8eVxiiAnW5NPc4R7i+/1YKxGt5TXQ6QzLEhgQ== X-Received: by 2002:a1c:e906:: with SMTP id q6mr10396694wmc.136.1570198085062; Fri, 04 Oct 2019 07:08:05 -0700 (PDT) MIME-Version: 1.0 References: <20191002141713.31189-1-ard.biesheuvel@linaro.org> <20191002141713.31189-21-ard.biesheuvel@linaro.org> <20191004140350.GC114360@zx2c4.com> In-Reply-To: <20191004140350.GC114360@zx2c4.com> From: Ard Biesheuvel Date: Fri, 4 Oct 2019 16:07:53 +0200 Message-ID: Subject: Re: [PATCH v2 20/20] crypto: lib/chacha20poly1305 - reimplement crypt_from_sg() routine To: "Jason A. Donenfeld" Cc: "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Herbert Xu , David Miller , Greg KH , Linus Torvalds , Samuel Neves , Dan Carpenter , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Will Deacon , Marc Zyngier , Catalin Marinas , Martin Willi , Peter Zijlstra , Josh Poimboeuf 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 Fri, 4 Oct 2019 at 16:03, Jason A. Donenfeld wrote: > > On Wed, Oct 02, 2019 at 04:17:13PM +0200, Ard Biesheuvel wrote: > > Reimplement the library routines to perform chacha20poly1305 en/decryption > > on scatterlists, without [ab]using the [deprecated] blkcipher interface, > > which is rather heavyweight and does things we don't really need. > > > > Instead, we use the sg_miter API in a novel and clever way, to iterate > > over the scatterlist in-place (i.e., source == destination, which is the > > only way this library is expected to be used). That way, we don't have to > > iterate over two scatterlists in parallel. > > Nice idea. Probably this will result in a real speedup, as I suspect > those extra prior kmaps weren't free. Looking forward to benching it. They weren't only non-free, they were also using kmap_atomic() unconditionally, which means that these routines were running with preemption disabled even with non-SIMD crypto on non-highmem architectures.