Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp152504imm; Fri, 5 Oct 2018 01:14:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV619CE/TjiRXSvjEhJ/dihF1UE3UWuMVFHgftqm+xku3uR3glAFXseayHgNBHsUa3xqibbT6 X-Received: by 2002:a17:902:5a89:: with SMTP id r9-v6mr10277159pli.95.1538727269027; Fri, 05 Oct 2018 01:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538727269; cv=none; d=google.com; s=arc-20160816; b=K8J7z9oZ0IZqtrUIqMj0fMlVGwAOlg9lG8u1EjseeCbP5fsCo9la4TIfacr812ITtI kbU7teZ3MgNXgdQcUM3xF9kP+usXLaWw6zyYGNBwAKxSfvC36lC9Qrg7q2XhRL7Ld75h +kfT2DBIKX9B0ky8oHzLwlPlqkT33+Z3/6dO6IQjjf7E9KA3hELs1+ZvSEvUWhKqWbf1 xjELu3QZcei+OORh+YVlQgwU0bPKzBbl27OGSSJbyOcDd3kQVqZu5UM9iLnq4dmI7CEp g/Kk0kkIc4VTrOHygmzDA/XM4lKwTlt1eCw2f8QYbQ4f96huL1uW9UbwT/xVy2WM+EPN s3tQ== 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=vQD/mLNcOvoSWdMaaXJkRcR2ZyIbkfdL3QYsKPVFg8j4JXzgKL5w3wsiNRmv5ooQIw aOrrmI8HINy8Jnkt6TC3JryTQmFxuntYjbnvXhKhEeYPAJL47afYhAWA5XuJsHx1HrUw e1OxXd5+yxHnVGwznSeiiDk+w6R8cs8xDCgTfnUg87OdItaqmkGjGCufT7cPsb2XhDAT iULKjHUS5JWpPyu5ZKfKSWDYgTZisxLWuW/k1UouEvJC+WGuwX5HukDFbpuYGVEJKBu9 wuIDM2i1fG81x2pufanRuN3EhqqKrqs3v+vUoATgTXwP04u2/T9afeUTFCWqlvuVy0Gm udBA== 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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 21-v6si7528759pgs.520.2018.10.05.01.14.13; Fri, 05 Oct 2018 01:14:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1728595AbeJEPLa (ORCPT + 99 others); Fri, 5 Oct 2018 11:11:30 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50676 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728498AbeJEPL2 (ORCPT ); Fri, 5 Oct 2018 11:11:28 -0400 Received: by mail-wm1-f66.google.com with SMTP id s12-v6so991527wmc.0 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=lTI/acK2eCmEjFOCsrki+PHgktjyu70/3q4G9qWd3vNh6dVRCVjuWODnI/S3BU6qyP 4o0vmRTThBsupRK2wtpxCKrjYOoclEX1T364qPYTxfARmw9q5h3jOiCKGNuBQBN2hOuf F++V27y/J9vxI2Pa2CcGfgQ7zerOf1vJx2VL/Y4rMeOT/ZRqBTSa7PW6AEmkflGbbAR7 jGlArXKmP2D8p+fMLrjZKgj1LczlDbVg/DpGzav0h/kqEmC4JWltBCgGJnicHk/xrqVb U8S2xBI8h4V9bXEX7KiUZPsPjJafn8LeEUhxKaWLgaUsgowQrQGddcq7+PYU/QOdVfar 6OGw== X-Gm-Message-State: ABuFfog6hk7ZaopCKKE6FjWMAcbW9QL7oB/b0KQq7Sk+h3P8iY7P3zSU 7RpKz9PHElRLvrvB70OIDZtmBNMlO14= 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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"); -- 2.11.0