From patchwork Mon Jul 24 10:28:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 108559 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3887627qge; Mon, 24 Jul 2017 03:28:56 -0700 (PDT) X-Received: by 10.98.150.16 with SMTP id c16mr15870547pfe.64.1500892136227; Mon, 24 Jul 2017 03:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500892136; cv=none; d=google.com; s=arc-20160816; b=m2Qbed5Fy8a9DobjhV//SEazRwS61X9ifRV4GxN8j5gY354M8KU8lkF47L0SC9YAJ9 vL8LuKDc4mq8FTVeJQ/qgqkVzYynW18Za4i1HceMcmOxfrwGsrJ2YfCmsHclILMZ7O3N VPk5LZOXWUt5kjxEg7nU62J6D9Ql60sK/bFnfk4xvEBen1xjrDAYwjYNa4X65ejOK25c qjwWhGjhJkjeTptHMa1GGF6f79jTT9j1hrW4Mk2RnDMZ+SGy5wKDhIa3JQfq9ZR+1Z1J t5xEL3p4Bd3KIy96cKDKDY5qYh/m/9iv+bTFlslRUc2oEqiY7udupaixBij14JTQdq+V rNqQ== 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=WZklumhDDVsOZVNG9ejRpmsrpjRPQORsSJScJg4cN8E=; b=eYBK2MO9RG0JEByvdNj5kVlaDXX78ZMbVoqcGtqWozlV658A+efA7oJia067wO1BGz elyYN/SpKC5zvxdgFztFTvgAlSq2H5DLGdVLkke2qbugO5g+T3AjMkQpq5J5nLzRhd9l PGvZtNgKlLoG3W/2jAUcX67HF10aaJoUndjDCJeqkbgcWqtIcIpHNZDoZs5sn4/X31ox IZmT9g/H2iM1qDmW1Ts88WU4f4/HW3pjLHvz8A2MZHFlx4dGS/0/ZMCteDXxtplJc6hG wotCNmU+yk44XY09+XYxF/B+LY5/3hAT3xNZGRp+q85wy92QokmxVsFJYnBmHrs5tAJu vRPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=UtxmKQB9; 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.56; Mon, 24 Jul 2017 03:28:56 -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=UtxmKQB9; 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 S1752568AbdGXK2z (ORCPT + 1 other); Mon, 24 Jul 2017 06:28:55 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:38254 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbdGXK2y (ORCPT ); Mon, 24 Jul 2017 06:28:54 -0400 Received: by mail-wr0-f182.google.com with SMTP id f21so47779515wrf.5 for ; Mon, 24 Jul 2017 03:28:54 -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=WZklumhDDVsOZVNG9ejRpmsrpjRPQORsSJScJg4cN8E=; b=UtxmKQB99vxY4X5gIZVdHxS15J2gTGOZx0gjxxSjJTGhC0ESYhPxMKF428YeopnNGq clwqpwi1ifseDVUZDn3hSoH9Ij2jfOZuGjQuqOJgDQzCg733WZC2wA6wcozMklOHtgTl OxcLDd6yOtIUD4zSZ+YGoEJdhe+/B/cw4QaLI= 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=WZklumhDDVsOZVNG9ejRpmsrpjRPQORsSJScJg4cN8E=; b=iYchYfu2i+kFtKzsuhf3KOBl+PClMZ5net75nYn1PLfXms3fIQH28Vi+YDNib0eT/3 ro6j7OZf2ropbY4u74HefIHED6+0db7evEe0vJJWLVIA7X0o0aZZ0qm7Ry7nxs0wDedm 2b88vwibcrfC2jLnekfUgo2oZ82lv0mjdBiNY+OPoSq/2EeKWxlFmU5O4hr7/pYb0VPG OJkev0TdqrPYjFRCl8dmwTfZdT751TkecAr6E244wUq+UaI4TAF33CtgXOndkSYQUuDh YrSKQesmzPKZKZIVACH6QqVqa8JXJuM64MWRbwUo70AvAt6eLW6iG52xxwnFYmSAXvNQ m7FA== X-Gm-Message-State: AIVw111pDiLhCN2+ocLPuL1DjH9zCaTekosvLq1cD6608+8BLLSVWeD1 +B36HFtfZxXn+TuKyERWdQ== X-Received: by 10.223.179.193 with SMTP id x1mr15333737wrd.86.1500892133110; Mon, 24 Jul 2017 03:28:53 -0700 (PDT) Received: from localhost.localdomain ([105.148.195.69]) by smtp.gmail.com with ESMTPSA id v44sm13205400wrb.53.2017.07.24.03.28.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 03:28:52 -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 12/18] crypto: arm64/chacha20 - take may_use_simd() into account Date: Mon, 24 Jul 2017 11:28:14 +0100 Message-Id: <20170724102820.16534-13-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 To accommodate systems that disallow the use of kernel mode NEON in some circumstances, take the return value of may_use_simd into account when deciding whether to invoke the C fallback routine. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/chacha20-neon-glue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.9.3 diff --git a/arch/arm64/crypto/chacha20-neon-glue.c b/arch/arm64/crypto/chacha20-neon-glue.c index a7cd575ea223..cbdb75d15cd0 100644 --- a/arch/arm64/crypto/chacha20-neon-glue.c +++ b/arch/arm64/crypto/chacha20-neon-glue.c @@ -1,7 +1,7 @@ /* * ChaCha20 256-bit cipher algorithm, RFC7539, arm64 NEON functions * - * 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 @@ -26,6 +26,7 @@ #include #include +#include asmlinkage void chacha20_block_xor_neon(u32 *state, u8 *dst, const u8 *src); asmlinkage void chacha20_4block_xor_neon(u32 *state, u8 *dst, const u8 *src); @@ -64,7 +65,7 @@ static int chacha20_neon(struct skcipher_request *req) u32 state[16]; int err; - if (req->cryptlen <= CHACHA20_BLOCK_SIZE) + if (!may_use_simd() || req->cryptlen <= CHACHA20_BLOCK_SIZE) return crypto_chacha20_crypt(req); err = skcipher_walk_virt(&walk, req, true);