Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp767530imm; Wed, 26 Sep 2018 06:33:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV61hQXqJLI7dPht8ou9NW5Ius6+J8YMVHfQANSEF6ln3ox1dzck9Vh8uZ0TSoA3OFo/MnoAw X-Received: by 2002:a63:2acc:: with SMTP id q195-v6mr5719354pgq.291.1537968804308; Wed, 26 Sep 2018 06:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537968804; cv=none; d=google.com; s=arc-20160816; b=epCJbqz9qXWZuuPIOAZrZcLFr5g5blez/mNRWtq9TgXfnnRumZScaI35J3FBt7NCu/ trEsa2R6JUDxGUByttUCNoGWUNDMIYumKVIlLsrXTJLzuZBQFnHEnrXUOnJ+yObBXdMm rvlggppXumOTWrpQnVzLyUyXxGbjEbtJn9dTiTBcQ7dMZUZlDOeykPpDj8LlFylWAhzZ MZfhq3Lk5pvrfPPlm2WQVLvbfRLPcujznKDS8L6j7owwhYhC9nLVj2IhPKHgNlfofjBb cHokA+PVsXdqQBruQVKahj6Dg2RobupPMQ9mTsEIZ0yX44n5QOx4clYantWy5iCwpjM6 8c0g== 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=Q8cRdflwdT/x03QEdK67GwqeScP0rWvLE6bMfcOVCd0=; b=OPbgUuOqbo5rWaKCVgAXIxHln5IBMPnYMLPYHpewRiUDo/0ukDbu4+Vt4yhCBG+oLU ZsXk90yhv/5xTNgieHwAu1dY60Jd2ldSURM3PHoTUWM1lw7GxSYdKaPe3UHVe28XBzYI tBYJkkNXBdIspafJPIlo7ZkVyJoj0BuLWe1SP7f9We0ocJcCimGVOwLHZYIaLmpQEvP+ pXp+qO9WcW4H0ZI+Ai9a3fXSHRyZV2IzNYmtakGybKb0/0NwThC824d7JEjgDAc+hecy tLAlwhJ+Qm4X7nxvhuxdJkdwbVpfix0csu1VoMJE7XKz7WJ/MuLAYaMPEeIpGwiaLyrD TKPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=utGnx948; 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 v126-v6si5236719pgv.10.2018.09.26.06.33.08; Wed, 26 Sep 2018 06:33:24 -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=utGnx948; 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 S1728214AbeIZTqA (ORCPT + 99 others); Wed, 26 Sep 2018 15:46:00 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:46257 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbeIZTqA (ORCPT ); Wed, 26 Sep 2018 15:46:00 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 9948c1c3; Wed, 26 Sep 2018 13:14:26 +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=5Th5xSwiiN40zyROLwYuOEGbjJM=; b=utGnx9 48QzcpKubNEdRRSWyLajdWH9y9yyRZXE/721WXUAa+Ztdvm9kMet0PayzRmucxya OJsm33kgTmQOwn8FQ4EbeK+yZ94G7xKaUfZoEN1d0UT2DkmnSgb6nnNHOhtTl+kh TaKMesWMSC6Ytj2uykvfCJVlrl7mT0UeNmsmKzHXT9tX/fjh//IxClYjBexEtxiQ YLHEhe9nItl5nGSP43JAOLfeRY+vDTYsXHNKT2ElkcJjPJZxZXYhVumydCgh6MKq v0d0rqrNWJoTOhkVL5/Atv6y4jev7LWv4YC6bjMmEkHR2X7AHLBMYua7mhmnoFj3 GcEloRKK4NrNlViQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2a1aa20c (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Wed, 26 Sep 2018 13:14:24 +0000 (UTC) Received: by mail-ot1-f48.google.com with SMTP id m23-v6so10566949otf.0; Wed, 26 Sep 2018 06:32:57 -0700 (PDT) X-Gm-Message-State: ABuFfoiL6C1sCw7x1xaoOGFYMRh4jJXqulwvqmz5FSax28R9oQnMF0lC 6icTi6LoSf8vWWRohHuCgVJ7PC5OX0+UWAhabvo= X-Received: by 2002:a9d:522d:: with SMTP id e45-v6mr3977455oth.250.1537968776249; Wed, 26 Sep 2018 06:32:56 -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: Wed, 26 Sep 2018 15:32:45 +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: 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 Hi Ard, On Wed, Sep 26, 2018 at 10:59 AM Ard Biesheuvel wrote: > > +static inline bool chacha20_arch(struct chacha20_ctx *state, u8 *dst, > > + const u8 *src, size_t len, > > + simd_context_t *simd_context) > > +{ > > +#if defined(CONFIG_KERNEL_MODE_NEON) > > + if (chacha20_use_neon && len >= CHACHA20_BLOCK_SIZE * 3 && > > + simd_use(simd_context)) > > + chacha20_neon(dst, src, len, state->key, state->counter); > > + else > > +#endif > > Better to use IS_ENABLED() here: > > > + if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON)) && > > + chacha20_use_neon && len >= CHACHA20_BLOCK_SIZE * 3 && > > + simd_use(simd_context)) Good idea. I'll fix that up. > > Also, this still has unbounded worst case scheduling latency, given > that the outer library function passes its entire input straight into > the NEON routine. The vast majority of crypto routines in arch/*/crypto/ follow this same exact pattern, actually. I realize a few don't -- probably the ones you had a hand in :) -- but I think this is up to the caller to handle. I made a change so that in chacha20poly1305.c, it calls simd_relax after handling each scatter-gather element, so a "construction" will handle this gracefully. But I believe it's up to the caller to decide on what sizes of information it wants to pass to primitives. Put differently, this also hasn't ever been an issue before -- the existing state of the tree indicates this -- and so I don't anticipate this will be a real issue now. And if it becomes one, this is something we can address *later*, but certainly there's no use of adding additional complexity to the initial patchset to do this now. Jason