Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp938793imm; Fri, 3 Aug 2018 14:30:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeS6jnWnjHoyC2ddgJ4wm9dgegjOE319yHl9gfeZBBIkHUw89E9zqB92BYaX9klGK+fSVSi X-Received: by 2002:a62:4b48:: with SMTP id y69-v6mr6320096pfa.93.1533331827141; Fri, 03 Aug 2018 14:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533331827; cv=none; d=google.com; s=arc-20160816; b=0UiYACf2NRdbktsvj93sp66z0GH67hLYPUrvN9AQEwJFC260Mzwk9p5/R1e2npIzg/ e2zuh4QACgrXTAROHY0H3h0b5n8OxznbQ/a6WP0sXIfsqHmbgFaPtVrIuO7E5Rfg8+Vp 9l/sHVlHKrwJGg5V1jqodEueSrCL2qz8Iee03352BadGsdpmikp35ytNlw4Dls06ddSD 4R1yV7eFwsNdV1KO9MPxr8HtKfRDDRWJ7NZEFfaUKZasHDSNWLBIxVtAA4pVPnKKLgf5 VQKK7JoEgTBrRvYQU9v/7Jo4CjYKdPhmL3eZYhY3z5Na5gDHsXz1ojDSfem0hVPHAjEZ wV0A== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=l1tAkLcH7lLC/RDYF8Guzuabgc/xwWes/KPNuA5AhRI=; b=SEWHYgFpORwfIqvBx2k34hthNpUcNUQhnF4uAzLKjCGucu5tFC6ta7Wp4D82JcY8J+ V/SKYURKDgi0lZopW6baqgXEi6iO/MybVlp0N3CHDGBrjnCDTb1Uvoac27LWT47qVLxR +cBkY6059AaU2jpdZdddcnpdIUgbXeOvib7KIuAlKoCu9ByQLxWGZyjoEaDMS+7DfIKn E7+/CViD4Y7WA8JT4a+pJF6yu8VpguwsixMqL8a3AlRLhMon4outYsIXTGQT+v7ITHRX rtf6bbdIDdxqSPlY/qSjuBol35OR7AeXFf8hRAMb7zdLBBiQ1tuv0FGFG1BO/aFbyYP6 JVnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=XGbr8q1D; 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 b205-v6si6337707pfb.358.2018.08.03.14.30.12; Fri, 03 Aug 2018 14:30:27 -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=XGbr8q1D; 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 S1732001AbeHCX1Z (ORCPT + 99 others); Fri, 3 Aug 2018 19:27:25 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40250 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729660AbeHCX1Y (ORCPT ); Fri, 3 Aug 2018 19:27:24 -0400 Received: by mail-wr1-f66.google.com with SMTP id h15-v6so6607807wrs.7 for ; Fri, 03 Aug 2018 14:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=l1tAkLcH7lLC/RDYF8Guzuabgc/xwWes/KPNuA5AhRI=; b=XGbr8q1D3QfUbht9WiOxMZ+CELSxGQJaa6dPA6OWSq9pjdDU1TiKuKiHYwOsUdJ4fx wuNB6iBiRjEKHjXb0xjaup4d0mlszEFmBOCaQ89FPRufZB8HLu6OJj7hjaU1OQQq6Ba9 IoJU/mDyup8OmULBZHOa8pfhGL+Umf8LmfxXiDiwZp4Wr3dV6WecfaLyXaJCoxQyv/xB vDAHWQ+zsnOVJLVimsfGL5HhaXOyY7/bN6DVtk8gkrG9hvkI0YDKTKWWpQInx4tSVgZM XjpS6+RzY7FsCErK8OTNSPMo9Md1tHmMltHTVkw5R4iMd3y6f0ZGOywiQwSOoCBOfaQS QLLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=l1tAkLcH7lLC/RDYF8Guzuabgc/xwWes/KPNuA5AhRI=; b=fucNZTd2BcUj9hJgQKhcwxxfTzXuFcJbRI9DTzx8d9lPrnTNKd+MFwlxPsbNF85XRn ftnrMF983KUKC8lO5Bbhk69nbEx5Ru6B6qZ1bFXnfULIqJOjCKEDuAusGorh/nxLL8Ma dNXsM2lnXIw9QDMKUkZD8JVSPArD/gqzT6HnXDJIyizdr+hXqpUcWsvMPoPW/FXZTito XFNMagt63Y47OuhHxQFm3csIyHzsHPQoo/WcB+a85UaVnvDRyfvR8ZMP6iwRsKqWfRCZ QidQA5kuJl6Sjwy7Y7k70YKG4LFpFmf6nNCpUel6I7HqTBJhVyK/Qna8jrST38UbAxo3 QyRA== X-Gm-Message-State: AOUpUlHkYkDGpAiFCT2+zIZGxon5fQ429Ukuw0AS/xIKQmivgVLz/wVE jnc5l72g/aSqEHbHmhIaOjOz587MiGjgFMUm3rOXjQ== X-Received: by 2002:adf:8325:: with SMTP id 34-v6mr3537290wrd.67.1533331762210; Fri, 03 Aug 2018 14:29:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:548:0:0:0:0:0 with HTTP; Fri, 3 Aug 2018 14:29:01 -0700 (PDT) In-Reply-To: References: <20180801072246.GA15677@sol.localdomain> From: Andy Lutomirski Date: Fri, 3 Aug 2018 14:29:01 -0700 Message-ID: Subject: Re: [PATCH v1 2/3] zinc: Introduce minimal cryptography library To: "Jason A. Donenfeld" Cc: Eric Biggers , Linux Crypto Mailing List , LKML , Netdev , David Miller , Andrew Lutomirski , Greg Kroah-Hartman , Samuel Neves , "Daniel J . Bernstein" , Tanja Lange , Jean-Philippe Aumasson , Karthikeyan Bhargavan 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 Thu, Aug 2, 2018 at 7:48 PM, Jason A. Donenfeld wrote: > Hey Andy, > > Thanks too for the feedback. Responses below: > > On Wed, Aug 1, 2018 at 7:09 PM Andy Lutomirski wrote: >> > I think the above changes would also naturally lead to a much saner >> > patch series where each algorithm is added by its own patch, rather than >> > one monster patch that adds many algorithms and 24000 lines of code. >> > >> >> Yes, please. > > Ack, will be in v2. > > >> I like this a *lot*. (But why are you passing have_simd? Shouldn't >> that check live in chacha20_arch? If there's some init code needed, >> then chacha20_arch() should just return false before the init code >> runs. Once the arch does whatever feature detection it needs, it can >> make chacha20_arch() start returning true.) > > The have_simd stuff is so that the FPU state can be amortized across > several calls to the crypto functions. Here's a snippet from > WireGuard's send.c: > > void packet_encrypt_worker(struct work_struct *work) > { > struct crypt_queue *queue = container_of(work, struct > multicore_worker, work)->ptr; > struct sk_buff *first, *skb, *next; > bool have_simd = simd_get(); Gotcha. That was very hidden in the 24k lines. Please make this (and any similar goodies) be their own patches. Also, please consider spelling it differently: simd_context_t simd_context = simd_get(); Because we'll feel very silly the first time some architecture has more than one possible state. (It wouldn't be entirely insane for x86 to distinguish between "no SIMD", "XMM only", and "go to town!", for example.)