Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1021157imm; Wed, 26 Sep 2018 10:17:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV62vu17e5v3qe3PWxpOFwXe8OFl1pAatuQQPjzmjMwuRyjjCD4rhvhxnT60YzaclQGVnMX6L X-Received: by 2002:a65:5c83:: with SMTP id a3-v6mr6669208pgt.164.1537982276297; Wed, 26 Sep 2018 10:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537982276; cv=none; d=google.com; s=arc-20160816; b=0Zg1W0QtqzF9vQA3bckJK4NXMvH7Ifyh9aEUOsazRX2O+OggDO1zErSp0Ew13TFFi6 LWhmfLSe5l89htSOVDOPaozZuFkHszA2TDQkhRyMZB9WE+NlflqroteufcTw01YylpR3 vD+K/Z5OmES70apbrntLAg3vxUtTeIio1KG4/dWYDHszMuVStGzY1usbJQqh3/pjfyDX KktajK22b69D8Cd94ihCj5Fobt5vZUzuuAPChDCf8vk7M0QDU7OgxKj8qCtFX4b/Pv8M IkbZK8IaRSmDgGZeT2TaQbvABjSJmIIWL54MHmwMV+hFb4TUAH9zL2PZXf30406CUavY AlDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dbGDkCaAXKyVAl5Mu41yEunqB/fS6udM8rTz1ifZdoI=; b=HeHkQGqQlRcZEpAtL39BOWYbDiqlVV8VqB8z0IzyR/Aw1aHUPQeRWIxkSW+4wayf+f NIl+WvLLqe4shloTiLejHFXuLtVYmkIClTLwjVxtMM+n+8VoRHz6bAvQm4M94+BhjaGr f2yAFoJPYfzEejQUosdNvmFejQ49Elf7qWjcv4jbUxaRPlWizse03UByGWAtMinynKX+ oJusxbWmKLQfC6UtwtABFm4I/6e2XhKHDn4bKoLGYVIONRJ4YwTQfmNoUVQfaabYXFyJ AdLtn1ElEU+eQl0OG4IbCebDsZL0b8zbr8Ude5QHo9LG7nlApH0q8mMs2qqfPUlp0Nhv NL2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dk2E52ER; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4-v6si5267351pfc.219.2018.09.26.10.17.40; Wed, 26 Sep 2018 10:17:56 -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=@linaro.org header.s=google header.b=dk2E52ER; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728929AbeIZX3c (ORCPT + 99 others); Wed, 26 Sep 2018 19:29:32 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:35018 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727411AbeIZX3c (ORCPT ); Wed, 26 Sep 2018 19:29:32 -0400 Received: by mail-it1-f193.google.com with SMTP id 139-v6so3935801itf.0 for ; Wed, 26 Sep 2018 10:15:36 -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:content-transfer-encoding; bh=dbGDkCaAXKyVAl5Mu41yEunqB/fS6udM8rTz1ifZdoI=; b=dk2E52ER/vRG5UAAYi1lfw1+vdGp2CSJIyV8jFKmYoNidvcwJSGhjYDOgFvJsOpkLh aTi9+jUFDI1lL9qPB4+0JT6yvQroPBM/12RXcxw/xzrPhKmmybEcEjUbfcwgUgtQXjQL feN98BdFBlXpRuWkVwBAXJ5pLw4rcSb5FMdx8= 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:content-transfer-encoding; bh=dbGDkCaAXKyVAl5Mu41yEunqB/fS6udM8rTz1ifZdoI=; b=aNnQKwdfoNWkYMU6oxAQJmKpO7L8m0ZLvtNd6iz83EW6JQG5Nx7i8cd7P2JlUIZ9mD Hy8J6hwpkzdif5tkqLjGi3/NgJ9Q7JU7Ht+9OrDft/8zenp+xK1Pl2yzZ715t+uEy6Yw 9LTYsZ+KFobzAvvWO+lX8qhSLwNrBs/0CPDgBg94rPpkbrV9E3ob0CjbB5KHE3GIZgc7 irc56UYo8ialjfrLXd4VybGV/8jy9nC1xZSDrjlSzZ4S5QMk6hkYlohs7gZ0FUQ/uWGP WnidEC+EClriwi7NfeVuyTQFCgh6fnf6GCwC4PRFAuYJ67tZk65NBjM+OWqHt15GvZ3c btjQ== X-Gm-Message-State: ABuFfoh79qGgrAybK3XIj1WZIXkt7dw0lVFwQOpW5jWcHKuOZQFCzK7s e6qPuMUArhSwXzVWS8nHI88+LGz9UCRrpesfOlteSw== X-Received: by 2002:a24:8309:: with SMTP id d9-v6mr5882084ite.123.1537981723593; Wed, 26 Sep 2018 10:08:43 -0700 (PDT) MIME-Version: 1.0 References: <20180925145622.29959-1-Jason@zx2c4.com> <20180925145622.29959-8-Jason@zx2c4.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 26 Sep 2018 19:08:30 +0200 Message-ID: Subject: Re: [PATCH net-next v6 07/23] zinc: ChaCha20 ARM and ARM64 implementations To: "Jason A. Donenfeld" Cc: Andy Lutomirski , Herbert Xu , Thomas Gleixner , Linux Kernel Mailing List , "" , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "David S. Miller" , Greg Kroah-Hartman , Samuel Neves , Andy Lutomirski , Jean-Philippe Aumasson , Russell King , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 26 Sep 2018 at 19:03, Jason A. Donenfeld wrote: > > On Wed, Sep 26, 2018 at 6:21 PM Andy Lutomirski wro= te: > > Are, is what you=E2=80=99re saying that the Zinc chacha20 functions sho= uld call simd_relax() every n bytes automatically for some reasonable value= of n? If so, seems sensible, except that some care might be needed to mak= e sure they interact with preemption correctly. > > > > What I mean is: the public Zinc entry points should either be callable = in an atomic context or they should not be. I think this should be checked= at runtime in an appropriate place with an __might_sleep or similar. Or s= imd_relax should learn to *not* schedule if the result of preempt_enable() = leaves it atomic. (And the latter needs to be done in a way that works even= on non-preempt kernels, and I don=E2=80=99t remember whether that=E2=80=99= s possible.). And this should happen regardless of how many bytes are proce= ssed. IOW, calling into Zinc should be equally not atomic-safe for 100 byte= s and for 10 MB. > > I'm not sure this is actually a problem. Namely: > > preempt_disable(); > kernel_fpu_begin(); > kernel_fpu_end(); > schedule(); <--- bug! > > Calling kernel_fpu_end() disables preemption, but AFAIK, preemption > enabling/disabling is recursive, so kernel_fpu_end's use of > preempt_disable won't actually do anything until the outer preempt > enable is called: > > preempt_disable(); > kernel_fpu_begin(); > kernel_fpu_end(); > preempt_enable(); > schedule(); <--- works! > > Or am I missing some more subtle point? > No that seems accurate to me.