From patchwork Sat Jun 10 16:22:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 103566 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp270906qgd; Sat, 10 Jun 2017 09:23:34 -0700 (PDT) X-Received: by 10.84.233.204 with SMTP id m12mr48206170pln.273.1497111814255; Sat, 10 Jun 2017 09:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497111814; cv=none; d=google.com; s=arc-20160816; b=KRFfvs9KMZUoqwIqigzRvuhQIO2b1Qz6U0l8kIl640HzVh+ZwJGdVG0+qrEHCN9Rsv DJLt9gRLx8wocOlLtRi/PzH/65+p/xI6ow04/fvVH/G1rPHHQvH6NDy80spJfmkT4Eav WvPuge4ebIHBb/qW3aK0ujU7Y/78IptSKsdGqAhjnJw1gk7j0WtI7HfRB3DMERKVOqG4 QeIqE3VVBUBqkx8VHEpmVFRQsz+3rRj6lC7Bcg7HX3F3pbqloOCGA+doobzokfS+pcgt T8nWJOs9iRgc0b3tvzo9OTG7uHH0mipnxnQzhTey6886jsQFueyoKtbXKgT5iUvNBvNL r8wg== 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=Gjn54yeOEILt3asFCwopbWX4iaXQMbY9VZg15wikTMw=; b=SWEIhGfO03mFA0SibEAIcxYfbGv3PsvzG+fwW6IVkBXGXHPoB5b4GDsc43HuJTJwng f92XH1z3w1ZJZqyvV5AB+cpBIVi5EEKyWpj2mrJin38EPdkQndwfB63d9+tlRJBRPpLM xrQuttUjQoegBT9COHJEQXdSZv2Ig3zMS7FryHSvI84umXj6FrUpr8K1BHu0hfVGr6tB /BSD7Tp38Bn8JkiSoJq8AHsb1tMRSxBzQV3yRV6466cDmUn7pIjmZGW5TQBFV9JSK0Qe suw9eioeEIY6sRKSPdYcFfA3qN+tdXlWjpW9WCb8NfD42jk5+BDRC2eP1NRGkxm09TYW gkmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; 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 m11si9340618pgc.389.2017.06.10.09.23.34; Sat, 10 Jun 2017 09:23:34 -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; 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 S1752208AbdFJQXd (ORCPT + 1 other); Sat, 10 Jun 2017 12:23:33 -0400 Received: from mail-wr0-f169.google.com ([209.85.128.169]:34910 "EHLO mail-wr0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752205AbdFJQXc (ORCPT ); Sat, 10 Jun 2017 12:23:32 -0400 Received: by mail-wr0-f169.google.com with SMTP id q97so58893555wrb.2 for ; Sat, 10 Jun 2017 09:23:32 -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=Gjn54yeOEILt3asFCwopbWX4iaXQMbY9VZg15wikTMw=; b=N06oK6R9iKf5lU16VZNJryT9GjSs94AZPW4/HLpIqnNYJ/qgNId6xKhs5nxswyfapz R4gqlSBmJNjA3oSPvNbczguTu/aSLQCKpZ86FABO6UdZJrOdWa2D27jxNb7/gaksh+LK O99Gmg7s6prp2+dKJnUefDCUwG/+IxDa/ytwc= 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=Gjn54yeOEILt3asFCwopbWX4iaXQMbY9VZg15wikTMw=; b=hthVVLJ8oIA/l/4f79rmxLFYRaVSXfROIh4Xr6OEmTJw34ZzN+o5JVy57cv0Jx9Prt HphurI5YaD5pztUfbTF5hr+ssPp/ryIEfYC8nic7fUOoSCsHeGPEYTMg5WxFFXL6fsLq v+RXyS+pvjmCFEE/ktXQ9qJtb3XWB9dBFJcR3YWK6jdrL9up8Q9uZ5VYgbeQDJHcflrx y+ZA+bTKMAPRYFxoldaO9kR6PdT74EAwwOeRJvd3pEvaiWI2SoZug7RNfm8W11FC78ky ZFX5OmyE5SCpF7Z81kE9ny4OFIULIKtzHjwxC0icK7K7C02+bwnIq2QE+K0FlCirZPhI T37g== X-Gm-Message-State: AKS2vOxeOO23DKRhlCwSndK0WFFBTME52TbgUDIOE0a0BLzr+qmZgq9Z wL4D14vfX8NdfBezW0KvVQ== X-Received: by 10.28.222.195 with SMTP id v186mr3118596wmg.88.1497111811249; Sat, 10 Jun 2017 09:23:31 -0700 (PDT) Received: from localhost.localdomain ([160.165.120.116]) by smtp.gmail.com with ESMTPSA id k35sm4440181wre.9.2017.06.10.09.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Jun 2017 09:23:30 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, dave.martin@arm.com Cc: Ard Biesheuvel Subject: [PATCH 11/12] crypto: arm64/chacha20 - take may_use_simd() into account Date: Sat, 10 Jun 2017 16:22:57 +0000 Message-Id: <1497111778-4210-12-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497111778-4210-1-git-send-email-ard.biesheuvel@linaro.org> References: <1497111778-4210-1-git-send-email-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.7.4 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);