Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1375717imm; Wed, 26 Sep 2018 17:05:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV628Oj+i5UENRjtAsY6Gp+EnnDNS3ht0DMoXDWGZsM56UhvbStFo2q0abDdndtgovLC2iR7x X-Received: by 2002:a17:902:d715:: with SMTP id w21-v6mr7980641ply.143.1538006734601; Wed, 26 Sep 2018 17:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538006734; cv=none; d=google.com; s=arc-20160816; b=Jv7Xfyt26w9GfwAWyrQejarulWh+INdnAOHMCaUpT11IfG4xFcfAHEdAtdHOq4w2/2 w+mr0Bz+SwL/YAGYm4K9ytZnfdzCdibdtnOTMGmsJsf/PraiUW4WPyvUo5fF3ARhraG+ O5iwg4bwaGgrLUIMKZ9Axy1oo441MxuYGv1DDh35RbBPrOEd4SoHR+b5Nl9E2J3H2Hvp rW2g2BP3iVh2NevgHSkQQxi8M9YXGU6UnLoGP0cDV4bCzzGtpEHHj9tZwlzzwZGq9HB0 sAZwSQYsLdWiio3AJemvutwH3X98BBJ1DSBv2T8QUkBr5Kkr2N3zGq28vv5/JVbgj1fm ypfA== 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=9PZZT/PI9ETXPLfx1BzCT10MBZpalyl5LMNKlpD5OFY=; b=zcAlHlkHpGwqTCenA0YKBBnqk8zQMXUmfRCjfA+V73SkCposxJ8DGP6ezUvCwXRVAC mejWljM94T/6+tXPC8lwh11VWHLi+lnrwkFl+sJ/R3FqY1Tk1dT117carrJeZART7s8g JHi7bUlq/Fj6POFjnN8aPmAZ7tT5t23lHl9xXltYCdCdTFlqVjoAC59/WKfHT9BnUai6 rlnQmBJmLOTtqe5/reh3QQqdfAqGk37+Gk0+f0/fal3NXL+pxOs2mM7G89ERPtidFTgM yEzkhI8fw4yExm5sc2WnTgy2iew9pUgyBsyjOOmO8WPXon5cbvBnOXd/ReNwxn8iQq+c SR3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=2nlfqJ8+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68-v6si389655pga.113.2018.09.26.17.05.18; Wed, 26 Sep 2018 17:05:34 -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=@zx2c4.com header.s=mail header.b=2nlfqJ8+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbeI0GUk (ORCPT + 99 others); Thu, 27 Sep 2018 02:20:40 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:54387 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbeI0GUk (ORCPT ); Thu, 27 Sep 2018 02:20:40 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id deb6a864; Wed, 26 Sep 2018 23:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=VZFuzMLyQfFoH4kc9GFS8iHNBEM=; b=2nlfqJ 8+7qLOs/0tuvZouJQYU9eqDyVnPShKIH1L9huWgDAUyHGpTn3AIKwBRxDB7TPhPW tGEBylAFWLI2A5bznzEc6z0JXV4Su/4KgqcBzlLAScGZTWVhuWrhpsSVcQcEaX/i vAKEuBKntsEXyqC6Y4kQfOtvzMfADA5nalaCpgXxVusU0WdF9PXPIPiRkrTjtDMJ lNVlRO/E88P5tmgkHYXjT1umPVrIQlWCK0AVki6CkVeMTIiXXEAx0SSLIG63FXPo 3rKqqswNFo+JHVoGLcBZPbQ21mcX/3Mh7NICcPpG46RfFCqwWTM6mS1o2EYfaX4y bqoYJ/GwFOrL1Rlg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 8d75b9dc (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Wed, 26 Sep 2018 23:46:33 +0000 (UTC) Received: by mail-ot1-f53.google.com with SMTP id c12-v6so795865otl.6; Wed, 26 Sep 2018 17:05:09 -0700 (PDT) X-Gm-Message-State: ABuFfohcCYlHqsVloPtoKkZK8tU5Y/bw7z5hszrKpFVWFgJbiv6O9Ip9 Tw+jfS0kdhIb2w97YEfflmxbGo3RERNYOfschw4= X-Received: by 2002:a9d:2dc8:: with SMTP id g66-v6mr5490042otb.311.1538006708060; Wed, 26 Sep 2018 17:05:08 -0700 (PDT) MIME-Version: 1.0 References: <20180925145622.29959-1-Jason@zx2c4.com> <20180925145622.29959-8-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Thu, 27 Sep 2018 02:04:56 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH net-next v6 07/23] zinc: ChaCha20 ARM and ARM64 implementations To: Ard Biesheuvel Cc: Herbert Xu , Thomas Gleixner , LKML , Netdev , Linux Crypto Mailing List , David Miller , Greg Kroah-Hartman , Samuel Neves , Andrew Lutomirski , Jean-Philippe Aumasson , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org 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 Wed, Sep 26, 2018 at 5:52 PM Ard Biesheuvel wrote: > > On Wed, 26 Sep 2018 at 17:50, Jason A. Donenfeld wrote: > > > > On Wed, Sep 26, 2018 at 5:45 PM Jason A. Donenfeld wrote: > > > So what you have in mind is something like calling simd_relax() every > > > 4096 bytes or so? > > > > That was actually pretty easy, putting together both of your suggestions: > > > > static inline bool chacha20_arch(struct chacha20_ctx *state, u8 *dst, > > u8 *src, size_t len, > > simd_context_t *simd_context) > > { > > while (len > PAGE_SIZE) { > > chacha20_arch(state, dst, src, PAGE_SIZE, simd_context); > > len -= PAGE_SIZE; > > src += PAGE_SIZE; > > dst += PAGE_SIZE; > > simd_relax(simd_context); > > } > > if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && chacha20_use_neon && > > len >= CHACHA20_BLOCK_SIZE * 3 && simd_use(simd_context)) > > chacha20_neon(dst, src, len, state->key, state->counter); > > else > > chacha20_arm(dst, src, len, state->key, state->counter); > > > > state->counter[0] += (len + 63) / 64; > > return true; > > } > > Nice one :-) > > This works for me (but perhaps add a comment as well) As elegant as my quick recursive solution was, gcc produced kind of bad code from it, as you might expect. So I've implemented this using a boring old loop that works the way it's supposed to. This is marked for v7.