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: 979364 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42RNPF5CVGz9s1c for ; Fri, 5 Oct 2018 18:35:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="e8esmuRC"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42RNPF3mm5zF3Sk for ; Fri, 5 Oct 2018 18:35:29 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="e8esmuRC"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linaro.org (client-ip=2a00:1450:4864:20::341; helo=mail-wm1-x341.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="e8esmuRC"; dkim-atps=neutral Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42RMwK6zhYzF3Jx for ; Fri, 5 Oct 2018 18:13:53 +1000 (AEST) Received: by mail-wm1-x341.google.com with SMTP id 206-v6so976947wmb.5 for ; Fri, 05 Oct 2018 01:13:53 -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=YWKn7Xuw1OOteXS+PwmLJelc4fglLTwIJQmRc3ffprcZYka/AsGOvLUxswn9LvGpT1 oYQHw2MUFQh/WuJ1qM7gwgj1Re39MPkt8YIEffBhO57tzQelNI4LqsZOtSCMSeZ4QGFH EIKNWQKXNezsPVXb3r9U6jAy/I1vnPkrmv+UNLlO7zsYv5gbrUwitc5pc/M4y1fOvQP+ rqn35OumBcd7dPXvbixkpoa9beSzrLrTMfFZm7zucn9267WUEE3xqVDjTlktRsht/fpJ bQENm6KoAarjv64P81QP3y+1d8VoRuVah0uLP93UcZsRXLm1zUSDSioSL37TayoQkNnE GGoA== X-Gm-Message-State: ABuFfog/lMNNr4KJ94iEmNpHPwB3B6MDMSnoSb/3vUbECvtb7IbLZi0+ lUNnLQSVj3mKZSKIrDO5fssD/g== X-Google-Smtp-Source: ACcGV61Ibe9AAfd/NquSGQgeZdTsN3JKQyq9DGyJgyEhxqZ5dP7RSW7Wle9DnyJkVviljI3UE2oc5w== 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 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A . Donenfeld" , Peter Zijlstra , Catalin Marinas , Will Deacon , Samuel Neves , Paul Mackerras , Herbert Xu , Richard Weinberger , Eric Biggers , Ingo Molnar , Kees Cook , Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, "Martin K. Petersen" , Ard Biesheuvel , Greg Kroah-Hartman , linux-crypto@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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(-) 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");