Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp320032rwd; Mon, 12 Jun 2023 14:10:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yLtvK3kS9AZH/Q5Xcc0EQP79qSy2rUFsqfYbIOwYgTvd85jV3LUkEvr/c9fzaqQD04Rn7 X-Received: by 2002:adf:f7ce:0:b0:307:cf5e:28a9 with SMTP id a14-20020adff7ce000000b00307cf5e28a9mr6826744wrq.5.1686604211990; Mon, 12 Jun 2023 14:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686604211; cv=none; d=google.com; s=arc-20160816; b=eejlvxlzuogVypE2ltrHX0ENTbs4kR6lTyxnDuQZ+y4bPxJn/1bSx/ehH+UAe7ktb5 N9c9ny1n5QgenyvaXCZTkO7HLcYXdF6rKzdAqmSuvk68P9XaA9ytXeWAZmjLSnNPviEK pt0sGyJg0q2B4I1qz1t/CyKMyTObB+1i32yyjQ8/0p3jn9qwqcVzjhntwduWY+Y9CQDr M6LdbfQIAvu5u1oMSQmrsS9Ri7fU9F+1SolqyeX723omYGy+HLxfHb2qyb/Uco740GpY BGlbor6o6g6Y3iMTAEvHxIRTSbqnQlZZWSmsU7/pAejkGzNV/WvAmD5GDCpt7DyJKTGC hIMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eviVgkS9NlVMOucxjdeY237DiPBE3HgqYjm7UGiykhs=; b=OLZn8MGkGByRSl7HEy2La6Nyj4bzlMV3SjYx/RhSaY+A083s3v4kq7sC3BOIDLAbBA an4WniQwRizD25jOeFL4fOP1G8a/q1cgOocBrOMfgB+fDfARAxPZKXwPQAmELbbRGzW0 xI42DlvxPjo1pPrEEpX/8Sb6Kd6g6df4YaKUF11MT5wu50fapv3WiZ0oAfaaMJ4Gkcwn Of9SP53s1vkUpPkrxEPnsMn6io8z/rvQTUbQyNMD2ciigcHFszWUkg9ZJURYqn9x9M+g GaJMBBUhL4JrLfdmQLcq68JNZmWYSFeGw8tkUMa0moNn70eztL1fg/37IiQu3PsbHDu+ miIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a1709063e1500b0097887934432si5479586eji.651.2023.06.12.14.09.42; Mon, 12 Jun 2023 14:10:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237637AbjFLVIb (ORCPT + 99 others); Mon, 12 Jun 2023 17:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238277AbjFLVHz (ORCPT ); Mon, 12 Jun 2023 17:07:55 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C350698; Mon, 12 Jun 2023 14:05:01 -0700 (PDT) Received: from i53875b22.versanet.de ([83.135.91.34] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q8oia-0005fR-KP; Mon, 12 Jun 2023 23:04:52 +0200 From: Heiko Stuebner To: palmer@dabbelt.com, paul.walmsley@sifive.com Cc: heiko@sntech.de, aou@eecs.berkeley.edu, herbert@gondor.apana.org.au, davem@davemloft.net, conor.dooley@microchip.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, christoph.muellner@vrull.eu, Heiko Stuebner Subject: [PATCH v5 0/4] Implement GCM ghash using Zbc and Zbkb extensions Date: Mon, 12 Jun 2023 23:04:38 +0200 Message-Id: <20230612210442.1805962-1-heiko.stuebner@vrull.eu> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Heiko Stuebner This was originally part of my vector crypto series, but was part of a separate openssl merge request implementing GCM ghash as using non-vector extensions. As that pull-request https://github.com/openssl/openssl/pull/20078 got merged recently into openssl, we could also check if this could go into the kernel as well and provide a base for further accelerated cryptographic support. Changes in v5: - rebased on top of 6.4-based riscv/next - code from openssl is now dual-licensed under Apache + BSD see https://github.com/openssl/openssl/pull/20649 - separate init functions instead of creating them with macros (Nathan) Changes in v4: - rebase on top of riscv/for-next - split out the scalar crypto implementation from the vector series - refresh code from openSSL to match exactly - Remove RFC label, as Zbc and Zbkb are ratified and the cryptographic code was merged into openSSL changes in v3: - rebase on top of 6.3-rc2 - rebase on top of vector-v14 patchset - add the missing Co-developed-by mentions to showcase the people that did the actual openSSL crypto code changes in v2: - rebased on 6.2 + zbb series, so don't include already applied changes anymore - refresh code picked from openssl as that side matures - more algorithms (SHA512, AES, SM3, SM4) Heiko Stuebner (4): RISC-V: add Zbc extension detection RISC-V: add Zbkb extension detection RISC-V: hook new crypto subdir into build-system RISC-V: crypto: add accelerated GCM GHASH implementation arch/riscv/Kbuild | 1 + arch/riscv/Kconfig | 22 ++ arch/riscv/crypto/Kconfig | 18 ++ arch/riscv/crypto/Makefile | 18 ++ arch/riscv/crypto/ghash-riscv64-glue.c | 296 +++++++++++++++++ arch/riscv/crypto/ghash-riscv64-zbc.pl | 427 +++++++++++++++++++++++++ arch/riscv/crypto/riscv.pm | 258 +++++++++++++++ arch/riscv/include/asm/hwcap.h | 2 + arch/riscv/kernel/cpu.c | 2 + arch/riscv/kernel/cpufeature.c | 2 + crypto/Kconfig | 3 + 11 files changed, 1049 insertions(+) create mode 100644 arch/riscv/crypto/Kconfig create mode 100644 arch/riscv/crypto/Makefile create mode 100644 arch/riscv/crypto/ghash-riscv64-glue.c create mode 100644 arch/riscv/crypto/ghash-riscv64-zbc.pl create mode 100644 arch/riscv/crypto/riscv.pm -- 2.39.0