From patchwork Mon Dec 20 08:22:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "tianjia.zhang" X-Patchwork-Id: 12696798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE8A1C433EF for ; Mon, 20 Dec 2021 08:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zH0WrJT844UxdqX/aJmeIluHqlM9xeO1B1PBKJHyXiM=; b=TYjP6S5XukrC3d 0OsJGaqKlY5kH8A778+tdDU6C+EApGZ9r5/aFk6H4CP1zVKre0Op6VbxRtx05y3iLq5Ya++7OVW8Y M8Fi2ylRcfRJ4rmjZTP4cBOHPX25mHFbNxZupQGr6AXbaYU1gSbM2tBcSuKQkULGVJQaseWDvDsIf EJJiFvD4NMn6DRQw7uuBxGru7lGVdzOTgcnUmcHBVZCeAHdURsGLL92JBwad2Z0XlPY3DW4rzAWVR /LSFgXfcA9farF4XSOfFTOsUoJS8biwOlOnN//WklT+BnmDQ770N/JUK82eMev0Kq+nZ0NH08jYxv QV+XdiHe/Ya+TfrzkFIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzDwn-001Ahp-Qf; Mon, 20 Dec 2021 08:23:06 +0000 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzDwi-001AeU-HP for linux-arm-kernel@lists.infradead.org; Mon, 20 Dec 2021 08:23:02 +0000 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R281e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04395; MF=tianjia.zhang@linux.alibaba.com; NM=1; PH=DS; RN=20; SR=0; TI=SMTPD_---0V.9dyJi_1639988572; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0V.9dyJi_1639988572) by smtp.aliyun-inc.com(127.0.0.1); Mon, 20 Dec 2021 16:22:53 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , Vitaly Chikunov , Eric Biggers , Eric Biggers , Gilad Ben-Yossef , Ard Biesheuvel , Jussi Kivilinna , Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , linux-crypto@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tianjia Zhang Subject: [PATCH 0/6] Introduce x86 assembly accelerated implementation for SM3 algorithm Date: Mon, 20 Dec 2021 16:22:45 +0800 Message-Id: <20211220082251.1445-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211220_002300_796319_DDE729C1 X-CRM114-Status: UNSURE ( 9.05 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series of patches creates an stand-alone library for SM3 hash algorithm in the lib/crypto directory, and makes the implementations that originally depended on sm3-generic depend on the stand-alone SM3 library, which also includes sm3-generic itself. On this basis, the AVX assembly acceleration implementation of SM3 algorithm is introduced, the main algorithm implementation based on SM3 AES/BMI2 accelerated work by libgcrypt at: https://gnupg.org/software/libgcrypt/index.html From the performance benchmark data, the performance improvement of SM3 algorithm after AVX optimization can reach up to 38%. Tianjia Zhang (6): crypto: sm3 - create SM3 stand-alone library crypto: arm64/sm3-ce - make dependent on sm3 library crypto: sm2 - make dependent on sm3 library crypto: sm3 - make dependent on sm3 library crypto: x86/sm3 - add AVX assembly implementation crypto: tcrypt - add asynchronous speed test for SM3 arch/arm64/crypto/Kconfig | 2 +- arch/arm64/crypto/sm3-ce-glue.c | 20 +- arch/x86/crypto/Makefile | 3 + arch/x86/crypto/sm3-avx-asm_64.S | 521 +++++++++++++++++++++++++++++++ arch/x86/crypto/sm3_avx_glue.c | 134 ++++++++ crypto/Kconfig | 16 +- crypto/sm2.c | 36 +-- crypto/sm3_generic.c | 142 +-------- crypto/tcrypt.c | 14 +- include/crypto/sm3.h | 35 ++- lib/crypto/Kconfig | 3 + lib/crypto/Makefile | 3 + lib/crypto/sm3.c | 246 +++++++++++++++ 13 files changed, 1010 insertions(+), 165 deletions(-) create mode 100644 arch/x86/crypto/sm3-avx-asm_64.S create mode 100644 arch/x86/crypto/sm3_avx_glue.c create mode 100644 lib/crypto/sm3.c