From patchwork Fri Oct 5 08:13:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 148153 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp151147lji; Fri, 5 Oct 2018 01:13:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV60DNv/AN/mSbcHt6x2ORe3s054r1Kd1FKkTHEnEHoJYrRJlk42p3VbFWh6kWXmkFNb9+7A2 X-Received: by 2002:a17:902:7109:: with SMTP id a9-v6mr10379495pll.310.1538727236094; Fri, 05 Oct 2018 01:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538727236; cv=none; d=google.com; s=arc-20160816; b=QnS09kHvUjy5eoMvj7c5dRuwLlZgxVeR09+MmGMmT+9A2QWpLJ4IenpZvraskW13tJ 7d36+GBniWAMCxjb8z7ITTFVAjcdRHicKbx5LqIRHMXG+3Q1KeY1WTZ8QuEBT7XDYDFR x+Q3x2JI/BY6orqLeqBIJj/FDa2eq1/1sNeuitzKQN1SWft78/xDjmLZAhNJPE5n5cFN AICQZg76lZQCT9IY3v5A/BXnTtpLw4gDMWz27bY+FkSasHfCfzl3PRXusuqek3ihhTPO gA3E17KRSPg+ldb0ZtP/RCQ5zwq7hfnV7uziTFUvfnATgErA8+wT6WA22Wc1+0VleWy6 a5Ug== 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; bh=J4kMEdjdjyVuuZO5lYFdItsW+zGD6WfP39sVuKslDsg=; b=Zcm5HRRpUho2o/GZGYjT+EotZxDVOhM2Ta7cCGY1fvVn1ac7GKTb8pWzpEVut9SB4e pCjdaWGuZxe0avmGpymbk10nkI1zTcaDyJtoyVOkJNnlBALLYicn0J+JCUeR4mW5Qtd1 KK5amvzYgHt+RmoE9wTF1oMFWpfRmlhR6j3779ZnmotP1kWHQLQ4/uXG8aAxYleeFO5U werfnrJ52g3dhFfZAe+b6WOR8UoTpVTh+YlJ/7ZelLycu4h73slpa4tEnb4Xnw4Z2B+J Ixos3f0nj9oEDodruOI7zrF/IrOweH+aXZZSUxuZGGixcVkbSuqekt8D7D3P4C0t+4eI eY6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e8esmuRC; 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 1-v6si7894961plw.121.2018.10.05.01.13.55; Fri, 05 Oct 2018 01:13: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.s=google header.b=e8esmuRC; 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 S1728582AbeJEPL3 (ORCPT + 2 others); Fri, 5 Oct 2018 11:11:29 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53522 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727236AbeJEPL2 (ORCPT ); Fri, 5 Oct 2018 11:11:28 -0400 Received: by mail-wm1-f66.google.com with SMTP id b19-v6so981346wme.3 for ; Fri, 05 Oct 2018 01:13:52 -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=J4kMEdjdjyVuuZO5lYFdItsW+zGD6WfP39sVuKslDsg=; b=e8esmuRCIp6ko/JwvDO3kBBIs0dTMMN1wtG2whhv2f4XMHEle3rjYH89bQUST5qiFq y01wiSYV80GPMjl+jFCfCvbACNJysosMxzXmakYDLal79M0Jvjtc315CNojt1VlrX3wv 1kEIFKnSbXS0TIqiC1s6eOzAaXSjfGUTetKb4= 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=J4kMEdjdjyVuuZO5lYFdItsW+zGD6WfP39sVuKslDsg=; b=iWmo7Rkvs2BqIaeTQz8pCrcaglrn/nr7dmzrzvP2S/OgmFPYeAx/pwKI4ZVPKmbhJ0 2eRNj2QfHBWsoc0aID72rBN6Biw4cCOqbn/lrRtx0MhjKGp/b6G2MMR2QYszYQMg3KlA es1maCOQeET+n9sP7Z+Z9sDdyCk86plJBDTQP4GnIXt/kH7LJQAObDAaOIlMTyhEUgd3 JkONlAF538bLh3fSd2Juxzc49eie9/qk6n4qkppMyJwqPkm6pThDQoXK18ejdhO2j35S h+qorRMnTpWGgxzuy4Hj7WCgbafwlb0Hsnj9mhKOHCDE8UQ1zBkLvqjKWrt0BVVpYXSm H1pQ== X-Gm-Message-State: ABuFfohAv49+wngaDsEPgxiOS6QS7JHtHJPOdHsNlWQCoWfnUBsNqh9x aym6+hsorAv1G3dE9tlrElbLQw== X-Received: by 2002:a1c:14d1:: with SMTP id 200-v6mr7368323wmu.106.1538727231291; Fri, 05 Oct 2018 01:13:51 -0700 (PDT) Received: from localhost.localdomain ([2a01:cb1d:112:6f00:697e:67d9:a05d:22c7]) by smtp.gmail.com with ESMTPSA id t4-v6sm6565620wrb.45.2018.10.05.01.13.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Oct 2018 01:13:50 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , "Jason A . Donenfeld" , Eric Biggers , Samuel Neves , Andy Lutomirski , Arnd Bergmann , Herbert Xu , "David S. Miller" , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Kees Cook , "Martin K. Petersen" , Greg Kroah-Hartman , Andrew Morton , Richard Weinberger , Peter Zijlstra , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 8/9] crypto: crc-t10dif/powerpc - move PMULL based code into core library Date: Fri, 5 Oct 2018 10:13:32 +0200 Message-Id: <20181005081333.15018-9-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181005081333.15018-1-ard.biesheuvel@linaro.org> References: <20181005081333.15018-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Move the PMULL based routines out of the crypto API into the core CRC-T10DIF library. Signed-off-by: Ard Biesheuvel --- arch/powerpc/crypto/crct10dif-vpmsum_glue.c | 55 +++----------------- 1 file changed, 6 insertions(+), 49 deletions(-) -- 2.11.0 diff --git a/arch/powerpc/crypto/crct10dif-vpmsum_glue.c b/arch/powerpc/crypto/crct10dif-vpmsum_glue.c index 02ea277863d1..a4db7ecc0ccc 100644 --- a/arch/powerpc/crypto/crct10dif-vpmsum_glue.c +++ b/arch/powerpc/crypto/crct10dif-vpmsum_glue.c @@ -11,8 +11,8 @@ */ #include -#include #include +#include #include #include #include @@ -63,59 +63,18 @@ static u16 crct10dif_vpmsum(u16 crci, unsigned char const *p, size_t len) return crc & 0xffff; } -static int crct10dif_vpmsum_init(struct shash_desc *desc) -{ - u16 *crc = shash_desc_ctx(desc); - - *crc = 0; - return 0; -} - -static int crct10dif_vpmsum_update(struct shash_desc *desc, const u8 *data, - unsigned int length) -{ - u16 *crc = shash_desc_ctx(desc); - - *crc = crct10dif_vpmsum(*crc, data, length); - - return 0; -} - - -static int crct10dif_vpmsum_final(struct shash_desc *desc, u8 *out) -{ - u16 *crcp = shash_desc_ctx(desc); - - *(u16 *)out = *crcp; - return 0; -} - -static struct shash_alg alg = { - .init = crct10dif_vpmsum_init, - .update = crct10dif_vpmsum_update, - .final = crct10dif_vpmsum_final, - .descsize = CRC_T10DIF_DIGEST_SIZE, - .digestsize = CRC_T10DIF_DIGEST_SIZE, - .base = { - .cra_name = "crct10dif", - .cra_driver_name = "crct10dif-vpmsum", - .cra_priority = 200, - .cra_blocksize = CRC_T10DIF_BLOCK_SIZE, - .cra_module = THIS_MODULE, - } -}; - static int __init crct10dif_vpmsum_mod_init(void) { - if (!cpu_has_feature(CPU_FTR_ARCH_207S)) - return -ENODEV; + SET_FFP(crc_t10dif_update_arch, crct10dif_vpmsum); - return crypto_register_shash(&alg); + return 0; } static void __exit crct10dif_vpmsum_mod_fini(void) { - crypto_unregister_shash(&alg); + RESET_FFP(crc_t10dif_update_arch); + /* wait for all users to switch back to the old version */ + synchronize_rcu(); } module_cpu_feature_match(PPC_MODULE_FEATURE_VEC_CRYPTO, crct10dif_vpmsum_mod_init); @@ -124,5 +83,3 @@ module_exit(crct10dif_vpmsum_mod_fini); MODULE_AUTHOR("Daniel Axtens "); MODULE_DESCRIPTION("CRCT10DIF using vector polynomial multiply-sum instructions"); MODULE_LICENSE("GPL"); -MODULE_ALIAS_CRYPTO("crct10dif"); -MODULE_ALIAS_CRYPTO("crct10dif-vpmsum");