Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp272893rdb; Mon, 15 Jan 2024 22:36:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlUWekVBP6Xf23a+63bljwBQOplm6eyjglaDxwLT2HSW4nRkyWZjQO2o4NWCNXnfW91rR4 X-Received: by 2002:ac8:7c49:0:b0:429:f3b6:d922 with SMTP id o9-20020ac87c49000000b00429f3b6d922mr2589154qtv.46.1705386963697; Mon, 15 Jan 2024 22:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705386963; cv=none; d=google.com; s=arc-20160816; b=g8GWQ5ssJdnlOqrluZo3K7jn2YWpZmctV/lp/Vzx+rEUMZkyKnX2RSc24ljZXkzlw6 edXVlCH8ePoI4SlJ+F0rlkc+8Zc2n4diAINiVCErr1a+g9ojcqbjScdYkNyESq/B5WPx kCJ+ugcqsCW67PCMhOWsVC1ojKUlW/UlKYFVztk/b0U1uJl5as+D3/UF493Tog8PzHz3 yHdvmtYiXEEDgiSthEajSre29DFJCPtSyK1EDEssnXaWosSoMm0yLqqGYIbYFV9eC01y W/t/Vw1EtPkVNEvlLa5nXPA/Sgd7J7vHBgYrj4Es46xWH6K9bTCD0ScFD00nAUnueo2p UlZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=fqxQ7J7MXykaGI+k0PfTOGbmU9d+CIwuoEFlGCkPDWI=; fh=/DJancj+MVsnzMVCUp2iErr9P0bPMLJHvcEOHip9mxc=; b=Hi/cs8ULoA4SnD6TOB1MkAYwLPy/9sVRw4VFfi8NBbNQSat66i8mHhJ3+tUSf9SOwM Phxb9VY/9diL8C2j8M5Gohuc+5jfpNm3OJPakancUALlCzXj1JN+q5HeRLE9oPucGADJ aWVgJrIQ4y/kB4ZA3pHGhzDJZvoiwLK1dj/6AH61YrDGywF7dNI0tMsFuDi1oeJCDLDk 8wBvKIVc/wXRmEdeuctMabSSmawDHMchwwYisX74vjOJ0efUo0ebLLO7luKc/Ambd5UV 4oqI1/1jr5fOmKR6kN7OLIuyc5St9IdbjTM7R7H8DaOzL0KkfbxakW1JWgA2bIAMJ9gK XI1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto+bounces-1453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1453-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g4-20020ac87f44000000b00429bcd3ebb5si9527616qtk.145.2024.01.15.22.36.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 22:36:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto+bounces-1453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1453-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 75C8F1C22C54 for ; Tue, 16 Jan 2024 06:36:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 281FC10A13; Tue, 16 Jan 2024 06:35:59 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from mx1.zhaoxin.com (MX1.ZHAOXIN.COM [210.0.225.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2696C10A0A for ; Tue, 16 Jan 2024 06:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zhaoxin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zhaoxin.com X-ASG-Debug-ID: 1705386949-086e230f2720520001-Xm9f1P Received: from ZXSHMBX1.zhaoxin.com (ZXSHMBX1.zhaoxin.com [10.28.252.163]) by mx1.zhaoxin.com with ESMTP id iNK00W2aUaMy3sse (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Tue, 16 Jan 2024 14:35:49 +0800 (CST) X-Barracuda-Envelope-From: TonyWWang-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.163 Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHMBX1.zhaoxin.com (10.28.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 16 Jan 2024 14:35:48 +0800 Received: from localhost.localdomain (10.32.65.162) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 16 Jan 2024 14:35:46 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.163 From: Tony W Wang-oc X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.163 To: <675146817@qq.com>, , , , , , , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH 0/3] Add Zhaoxin hardware engine driver support for SHA Date: Tue, 16 Jan 2024 14:35:46 +0800 X-ASG-Orig-Subj: [PATCH 0/3] Add Zhaoxin hardware engine driver support for SHA Message-ID: <20240116063549.3016-1-TonyWWang-oc@zhaoxin.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To zxbjmbx1.zhaoxin.com (10.29.252.163) X-Barracuda-Connect: ZXSHMBX1.zhaoxin.com[10.28.252.163] X-Barracuda-Start-Time: 1705386949 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.35:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 3441 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.119492 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Zhaoxin CPUs have implemented the SHA(Secure Hash Algorithm) as its CPU instructions, including SHA1, SHA256, SHA384 and SHA512, which conform to the Secure Hash Algorithms specified by FIPS 180-3. With the help of implementation of SHA in hardware instead of software, can develop applications with higher performance, more security and more flexibility. Below table gives a summary of test using the driver tcrypt with different crypt algorithm drivers on Zhaoxin KH-40000 platform: --------------------------------------------------------------------------- tcrypt driver 16* 64 256 1024 2048 4096 8192 --------------------------------------------------------------------------- zhaoxin** 442.80 1309.21 3257.53 5221.56 5813.45 6136.39 6264.50*** 403:SHA1 generic** 341.44 813.27 1458.98 1818.03 1896.60 1940.71 1939.06 ratio 1.30 1.61 2.23 2.87 3.07 3.16 3.23 --------------------------------------------------------------------------- zhaoxin 451.70 1313.65 2958.71 4658.55 5109.16 5359.08 5459.13 404:SHA256 generic 202.62 463.55 845.01 1070.50 1117.51 1144.79 1155.68 ratio 2.23 2.83 3.50 4.35 4.57 4.68 4.72 --------------------------------------------------------------------------- zhaoxin 350.90 1406.42 3166.16 5736.39 6627.77 7182.01 7429.18 405:SHA384 generic 161.76 654.88 979.06 1350.56 1423.08 1496.57 1513.12 ratio 2.17 2.15 3.23 4.25 4.66 4.80 4.91 --------------------------------------------------------------------------- zhaoxin 334.49 1394.71 3159.93 5728.86 6625.33 7169.23 7407.80 406:SHA512 generic 161.80 653.84 979.42 1351.41 1444.14 1495.35 1518.43 ratio 2.07 2.13 3.23 4.24 4.59 4.79 4.88 --------------------------------------------------------------------------- *: The length of each data block to be processed by one complete SHA sequence, namely one INIT, multi UPDATEs and one FINAL. **: Crypt algorithm driver used by tcrypt, "zhaoxin" represents zhaoxin-sha while "generic" represents the generic software SHA driver. ***: The speed of each crypt algorithm driver processing different length of data blocks, unit is Mb/s. The ratio in the table implies the performance of SHA implemented by zhaoxin-sha driver is much higher than the ones implemented by the generic software driver of sha1/sha256/sha384/sha512. In order to support Zhaoxin-sha driver, make padlock-sha driver matches the CENTAUR CPUs with Family == 6 and add two Zhaoxin Hash Engine cpufeatures. Tony W Wang-oc (3): crypto: padlock-sha: Matches CPU with Family with 6 explicitly x86/cpufeatures: Add CPU feature flags for Zhaoxin Hash Engine crypto: Zhaoxin: Hardware Engine Driver for SHA1/256/384/512 arch/x86/include/asm/cpufeatures.h | 4 +- drivers/crypto/Kconfig | 15 + drivers/crypto/Makefile | 1 + drivers/crypto/padlock-sha.c | 2 +- drivers/crypto/zhaoxin-sha.c | 500 +++++++++++++++++++++++ drivers/crypto/zhaoxin-sha.h | 16 + tools/arch/x86/include/asm/cpufeatures.h | 4 +- 7 files changed, 539 insertions(+), 3 deletions(-) create mode 100644 drivers/crypto/zhaoxin-sha.c create mode 100644 drivers/crypto/zhaoxin-sha.h -- 2.25.1