From patchwork Mon Jul 24 10:28:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 108551 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3887419qge; Mon, 24 Jul 2017 03:28:40 -0700 (PDT) X-Received: by 10.84.217.208 with SMTP id d16mr16976187plj.208.1500892120131; Mon, 24 Jul 2017 03:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500892120; cv=none; d=google.com; s=arc-20160816; b=byRT2ZkSWF+OEi5v+M+wVyJ0tOCv6YWOem7E39PvPNTFPxedRFWYOWIgKaeLv731m0 2THm6mVJP3XmCCnHVgIwuzoq4CBXhRwSV4nNV9foAadek+BAjamowqbLhRwmwCsQA3tf iIPLdyUp1JY+N0Q1RZ3PU4kNKGjYVyeplMtDKDeDZ6kivUzge1giCIiuhiNIKouV7Bk2 4H2oPmO+byzF1Z2WAD8n7m9StlgQZUnCrgPRsxmjO5QEKzps2u3lQv65UitnzK4XNg1f EbOBtD6N00VvBy4AqDkiI2B6aqgi3P3s7uXwDkswF4RX3yTEIC0QF/TSgBKfqGoZbGgR vf8Q== 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=zBKCe0pp0KmTrMKo+rEvT1GNR9oJ/NBs44emyjk55HA=; b=n4oKXAwqXlRqKFNMzkNCHQ+yLVKXRrndRzE9FmeMwEfvbMRbcx/uY0FPIgIOynjosJ pra0JJSZaneF0mFVnm4CmBJ2Ni35Yx3RyovUkQ+scfWN/OXZfdOR3LMScjkYgpI9eKeu cHGH+qNgF4ZVxSoGpDq6qLIqzdHKnL3w+iB1XA7Gsmd9B7A/Pe90niI3Ln0UXDDpIRUJ c33vWyrvB3bYem/Woo9jbafQgBXxUw2stouRNAO0Fls2R8SwnT4J9+punVH4wJ8Z8K0s JJ7qT6paw9qNz206/pD0HysPln3n/OaY63KWX/UN5cwdEoSDFg8h/6INu9xSN/RzbSjl NiBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=GaeSWbvq; 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.39; Mon, 24 Jul 2017 03:28:40 -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=GaeSWbvq; 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 S1751966AbdGXK2j (ORCPT + 1 other); Mon, 24 Jul 2017 06:28:39 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:37898 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751559AbdGXK2i (ORCPT ); Mon, 24 Jul 2017 06:28:38 -0400 Received: by mail-wm0-f48.google.com with SMTP id m85so13408426wma.1 for ; Mon, 24 Jul 2017 03:28:37 -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=zBKCe0pp0KmTrMKo+rEvT1GNR9oJ/NBs44emyjk55HA=; b=GaeSWbvqB6ZtEIRcW9fw6tom/tx9LjtCjHYlzxqFtlp1Rus+Jrcw2+WRch3kGBzL6f ZM/UxwMVNodMmN4Mod/0Gr15r7RdWWF2KZsw6CkyO7WQQc874WkvWlHb8U4T3ua0jMON /vDvytjUzOT3zvMGeZNyS8H1gUw/BNk0KkgNo= 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=zBKCe0pp0KmTrMKo+rEvT1GNR9oJ/NBs44emyjk55HA=; b=oI0PdX+FWYtEZF1vNQHJHYaj63mvnuKUQv2s/OsPjsHpE/savMGSPisPa86TvVbqXO hlq8igfjVYVrviYV+SfkyEWRlAs8tnOjm8su9BFZ20G+5DRATNSyfc9btv+I4WF4sysi ie5S6XWSNqLfHJtj9cSa0TpooEFJ2WH2YqjRMCLCfYT/X7FubXuRjoPoldZS3ZN/v7I4 e3/ASrVVdb/hPDiL/IZFFByyxYno3XeUmOuI2L54gVTlmO/b92AvE9FDzZPEaOhDgg23 Gb4sQapMLcKz/36WyUSxRhxLpBUKhyFr3PgKM/WRCUL5eP/A7gJDmxPZmgDmyLFa9d0S HEnw== X-Gm-Message-State: AIVw113xktwhBlhnslTBO37QcuYN6iZs4idR42lwcwwE41OazOj/Dtey cVEtOyN7XtAFuQq6EoWoZQ== X-Received: by 10.28.0.19 with SMTP id 19mr4299036wma.168.1500892116984; Mon, 24 Jul 2017 03:28:36 -0700 (PDT) Received: from localhost.localdomain ([105.148.195.69]) by smtp.gmail.com with ESMTPSA id v44sm13205400wrb.53.2017.07.24.03.28.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 03:28:36 -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 04/18] crypto: arm64/crct10dif - add non-SIMD generic fallback Date: Mon, 24 Jul 2017 11:28:06 +0100 Message-Id: <20170724102820.16534-5-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/crct10dif-ce-glue.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.9.3 diff --git a/arch/arm64/crypto/crct10dif-ce-glue.c b/arch/arm64/crypto/crct10dif-ce-glue.c index 60cb590c2590..96f0cae4a022 100644 --- a/arch/arm64/crypto/crct10dif-ce-glue.c +++ b/arch/arm64/crypto/crct10dif-ce-glue.c @@ -1,7 +1,7 @@ /* * Accelerated CRC-T10DIF 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 @@ -18,6 +18,7 @@ #include #include +#include #define CRC_T10DIF_PMULL_CHUNK_SIZE 16U @@ -48,9 +49,13 @@ static int crct10dif_update(struct shash_desc *desc, const u8 *data, } if (length > 0) { - kernel_neon_begin_partial(14); - *crc = crc_t10dif_pmull(*crc, data, length); - kernel_neon_end(); + if (may_use_simd()) { + kernel_neon_begin(); + *crc = crc_t10dif_pmull(*crc, data, length); + kernel_neon_end(); + } else { + *crc = crc_t10dif_generic(*crc, data, length); + } } return 0;