Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp906368rdb; Fri, 1 Dec 2023 01:31:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3EQ65tWaZFIyuXhd1nrttPt6UOH/xCrigcxdqGl5Why8m6UZpAKhwJVcbeofYwvnwolgi X-Received: by 2002:a05:6358:560a:b0:168:e737:6b25 with SMTP id b10-20020a056358560a00b00168e7376b25mr26343101rwf.20.1701423115501; Fri, 01 Dec 2023 01:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701423115; cv=none; d=google.com; s=arc-20160816; b=ce2AxWm1jHwYbm666ltz8ZQkXZKC2X9HnLQnCj4PnZZABxWtaiD9wAR/sD4Jr379+L qO2uCVNkjzl5kmY53GjR/NtddaUmBo8M6gzw3kYVLohn09HiaNpmqLOr+DnsVCHa8/ZX HV8WYR01GvKiW17vAwy2giQ6fpmFKys6WKoE0xogc3jULgTM5Lz8LFtSQmuiMq4Vnbd4 0922+Hr5UwIJwugCY529FkMBwqbf5pvsnNL2il1IWFa4Jt9Whkol/o7eoUKzNse6Db9Q e8PIv2yxBxikn3+sHE6J/pJ0HJFryT3bZHrAg+S/V8okvGyUmkNjh11y83PQPx/XgHjY PPUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=KfX2E6VGxo20WQBfxiaGSuURGMnukORg9InqlmeVXls=; fh=9q7EKAvQJRo+aUMTDLsfY+zc/ha3bqC0jzzKO6DmwR0=; b=QQ0NEIhBmaiT2h9DtV5nhRD/yGXERDsZ4NBncu2P13/hqWFKVDHMWI8KIUCEjp30a0 EjSD9CJyIZo95Jky8bpSk7+EffwTNf1TxAw7HwaxuxPloEYilqsUH+eq6bivNAw+MKXM tgQ5mfpa+/v6JK23mU6GQy4h1vAIMhOwXwQw0WZvgTnN801PpkD8YcwYVtEUcCF0qdjW ltlrqtrTlZXWt0EtG5SzKtza1TT7lkLHfezMMokpr77ujV61n+dygx3sDmIsWwxw0M1i Zz43ltn3d/VONuzSnjC18jHCDYnql3rUJh2QF+lZL63YSfJfxch/8PfwhBXZG4Rtr3X7 59YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id fd3-20020a056a002e8300b0068beee4922csi3141656pfb.23.2023.12.01.01.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:31:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DB68C80B633A; Fri, 1 Dec 2023 01:31:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378096AbjLAJbZ (ORCPT + 99 others); Fri, 1 Dec 2023 04:31:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378042AbjLAJbH (ORCPT ); Fri, 1 Dec 2023 04:31:07 -0500 Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2080173B; Fri, 1 Dec 2023 01:28:00 -0800 (PST) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1r8znq-005gYB-SE; Fri, 01 Dec 2023 17:27:19 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 01 Dec 2023 17:27:28 +0800 Date: Fri, 1 Dec 2023 17:27:28 +0800 From: Herbert Xu To: LeoLiu-oc Cc: davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, seanjc@google.com, kim.phillips@amd.com, pbonzini@redhat.com, babu.moger@amd.com, jiaxi.chen@linux.intel.com, jmattson@google.com, pawan.kumar.gupta@linux.intel.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, CobeChen@zhaoxin.com, TonyWWang@zhaoxin.com, YunShen@zhaoxin.com, Leoliu@zhaoxin.com Subject: Re: [PATCH v3] crypto: x86/sm2 -add Zhaoxin SM2 algorithm implementation Message-ID: References: <20231109094744.545887-1-LeoLiu-oc@zhaoxin.com> <20231122064355.638946-1-LeoLiu-oc@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231122064355.638946-1-LeoLiu-oc@zhaoxin.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:31:52 -0800 (PST) On Wed, Nov 22, 2023 at 02:43:55PM +0800, LeoLiu-oc wrote: > From: LeoLiuoc > > Add support for SM2 (ShangMi 2) public key algorithm by Zhaoxin GMI > Instruction. The purpose of this driver is to ensure that the application > has both high performance and high security. > > --- > > v1 -> v2: > 1. The assembly code is modified to be embedded in the .c file. > 2. Optimize code style and details. > > v2 -> v3: > 1. Increase compatibility with i386 architecture. > 2. Optimize variable and return value types in some functions.. > > Signed-off-by: LeoLiuoc > --- > arch/x86/crypto/Kconfig | 11 ++ > arch/x86/crypto/Makefile | 2 + > arch/x86/crypto/sm2-zhaoxin-gmi_glue.c | 158 +++++++++++++++++++++++++ > arch/x86/include/asm/cpufeatures.h | 2 + > 4 files changed, 173 insertions(+) > create mode 100644 arch/x86/crypto/sm2-zhaoxin-gmi_glue.c > > diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig > index 9bbfd01cfa2f..974d4c3806ff 100644 > --- a/arch/x86/crypto/Kconfig > +++ b/arch/x86/crypto/Kconfig > @@ -519,4 +519,15 @@ config CRYPTO_CRCT10DIF_PCLMUL > Architecture: x86_64 using: > - PCLMULQDQ (carry-less multiplication) > > +config CRYPTO_SM2_ZHAOXIN_GMI > + tristate "SM2 Cipher algorithm (Zhaoxin GMI Instruction)" > + depends on X86 && (CPU_SUP_CENTAUR || CPU_SUP_ZHAOXIN) > + select CRYPTO_AKCIPHER > + select CRYPTO_MANAGER Why does this depend on CRYPTO_MANAGER? > +static int zhaoxin_sm2_verify(struct akcipher_request *req) > +{ > + struct crypto_akcipher *tfm = crypto_akcipher_reqtfm(req); > + struct sm2_cipher_data *ec = akcipher_tfm_ctx(tfm); > + unsigned char *buffer; > + int ret, buf_len; > + > + buf_len = req->src_len + req->dst_len; What if this overflows? I know you copied this from the generic sm2 code, but that's still broken and both should be fixed up. Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt