From patchwork Mon Jul 24 10:28:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 108552 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3887445qge; Mon, 24 Jul 2017 03:28:42 -0700 (PDT) X-Received: by 10.98.74.10 with SMTP id x10mr15782851pfa.252.1500892121940; Mon, 24 Jul 2017 03:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500892121; cv=none; d=google.com; s=arc-20160816; b=AjBHEUpq6lrzRoXARhCLItVhFIqkZMISwJVS5hsAKGe7jj6+bAUbGxbSbkSEv+sGEf ezu2Sv6PQFvGQibmSJCXvGKFje123KPtwoGh9ztmhP2Ug6lLa3UCjMtmEEuJ1Z9f+12y lZL+gD5dfGB46Ya1vr2r7xB2gQoOnDz/UwetFqxLKznn5VY09AM06tGhgJdm10230ItO kgCWzFaMIaPteaFvRTO6lMHbrtgC0o/PFFWzawwG3DuPHn0tqFV61n1r23S44iFiwLxu pqXHrs63QUPmP9GF2B9MrbLSkWCq/v75HCBfOFLfevJV09aZGuvpM7sTmhN2HdKHIqsa rx0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=WUNDdM4SDE+JdS3WUxk6ux+pnehBuSATXJixrw/hBn8=; b=d3AyeTdvptBZq57+p9L/HgZUtaMWK4RQ7AVtLiHrgP2fw1AFWLoT26KavANk2AP2q0 xfhaKflb+69CDvcjmMp6v+QEBrP4rUqmeGKX7iSjOotxJ3QJ2yBlGlF3MZFjonCGMId5 J1oIFqfulqPM5LZVZ1Zf8A3m/mwUjXW6R66+Xvt50yOWVNLISWAr1z6t/ljo2GzcoGD8 1XKILx6xMJMyJL32+DND15bpux9qw6uvjFVFEPTM7IyUvbk7hQZykRd89Y8B425b+5eu Bw/OHT0U+ekny/GXAzzKsBbDmckPi/Ii8ZGFmVGKMrfEhSNMNFQLWPyCbSwzuiCB68LJ P81Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=BNWzcxzd; 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 38si3348411pld.76.2017.07.24.03.28.41; Mon, 24 Jul 2017 03:28:41 -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.b=BNWzcxzd; 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 S1752140AbdGXK2k (ORCPT + 1 other); Mon, 24 Jul 2017 06:28:40 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:34653 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751559AbdGXK2k (ORCPT ); Mon, 24 Jul 2017 06:28:40 -0400 Received: by mail-wr0-f180.google.com with SMTP id 12so104447461wrb.1 for ; Mon, 24 Jul 2017 03:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WUNDdM4SDE+JdS3WUxk6ux+pnehBuSATXJixrw/hBn8=; b=BNWzcxzddnbM/Gh5Gp8XpgEBkTEgfsxXSNXNW/p7tdeTIczZLx4B/av3w9Gx7ptgs7 O/zF/vadYDqcXxgFjKgWt+tZev0PKGFEllpvAFXqlX5o/F71yxrI534lAhKa2AblzOdD A/d7I0vFgRztQqSZHu4HjZBRrRrS4y/3lCxt8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WUNDdM4SDE+JdS3WUxk6ux+pnehBuSATXJixrw/hBn8=; b=Ds1g3ZEys6trgDhlz3zgj/GhLbiF6+v8GTOGzBlQww01N/gHULo9QY6Ry9qZhOIB6x JWzCyaMzFqOY6AfNIBLoS5sErxO156SUWwJopKybKUc12Jh77mRK0TOi5qgpSSmDrQp1 YeaZFQjrE1Y9RQEfvTIX89B2nYiBeT+OyyFfq3Uybwtw7URPR1byN7Dy2BzYRIWiVO3h 89qmu0qDKRf19OGcxGZKdX3rk43/TA4xegD/0XKiq7vpIzCl2K0u4FClQNbauq5OQZXd 945lH1DiMZy4SCDFSMs1xLCakqGe7EbKxX7RckVWv6WMsZ4YMKANwzS5uMhrZJX3vV6a R5iw== X-Gm-Message-State: AIVw112hWyDaFhagm66RhwojRV4K5MzIeBYJqNiadoK3zLH+UYs24WOy U9XSq0lMJphdj9E5Wvoo1g== X-Received: by 10.223.177.158 with SMTP id q30mr18144262wra.123.1500892118809; Mon, 24 Jul 2017 03:28:38 -0700 (PDT) Received: from localhost.localdomain ([105.148.195.69]) by smtp.gmail.com with ESMTPSA id v44sm13205400wrb.53.2017.07.24.03.28.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 03:28:38 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: herbert@gondor.apana.org.au, dave.martin@arm.com, Ard Biesheuvel Subject: [PATCH resend 05/18] crypto: arm64/crc32 - add non-SIMD scalar fallback Date: Mon, 24 Jul 2017 11:28:07 +0100 Message-Id: <20170724102820.16534-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170724102820.16534-1-ard.biesheuvel@linaro.org> References: <20170724102820.16534-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The arm64 kernel will shortly disallow nested kernel mode NEON, so add a fallback to scalar C code that can be invoked in that case. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/crc32-ce-glue.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.9.3 diff --git a/arch/arm64/crypto/crc32-ce-glue.c b/arch/arm64/crypto/crc32-ce-glue.c index eccb1ae90064..624f4137918c 100644 --- a/arch/arm64/crypto/crc32-ce-glue.c +++ b/arch/arm64/crypto/crc32-ce-glue.c @@ -1,7 +1,7 @@ /* * Accelerated CRC32(C) using arm64 NEON and Crypto Extensions instructions * - * Copyright (C) 2016 Linaro Ltd + * Copyright (C) 2016 - 2017 Linaro Ltd * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -19,6 +19,7 @@ #include #include +#include #include #define PMULL_MIN_LEN 64L /* minimum size of buffer @@ -105,10 +106,10 @@ static int crc32_pmull_update(struct shash_desc *desc, const u8 *data, length -= l; } - if (length >= PMULL_MIN_LEN) { + if (length >= PMULL_MIN_LEN && may_use_simd()) { l = round_down(length, SCALE_F); - kernel_neon_begin_partial(10); + kernel_neon_begin(); *crc = crc32_pmull_le(data, l, *crc); kernel_neon_end(); @@ -137,10 +138,10 @@ static int crc32c_pmull_update(struct shash_desc *desc, const u8 *data, length -= l; } - if (length >= PMULL_MIN_LEN) { + if (length >= PMULL_MIN_LEN && may_use_simd()) { l = round_down(length, SCALE_F); - kernel_neon_begin_partial(10); + kernel_neon_begin(); *crc = crc32c_pmull_le(data, l, *crc); kernel_neon_end();