Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp165811rdb; Wed, 1 Nov 2023 22:43:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwgvp0r40EgiO+1RGouMpzhcB2kFdXn+Q2LVEKiBsHZAqLwrD245X6h6vUQznJ5sm3IhEh X-Received: by 2002:aa7:c68f:0:b0:53d:b59c:8f91 with SMTP id n15-20020aa7c68f000000b0053db59c8f91mr14607418edq.27.1698903817068; Wed, 01 Nov 2023 22:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698903817; cv=none; d=google.com; s=arc-20160816; b=reVU+r5FrN3sSlyuRCqZ9pbcfQXTA29CJ7zrco8kFtmHBy9KzMhg8ZZneZ+JrPbiiq nx3E9b+QZN9p2YcLJkj7zfFVEC8fKpc/Ac01QXCEsth66JGw/Q2lP8R8mMojPpm5OZbm 112TPqhhIh1b/3uMt7sqC3HkpkT9Z/K2KQzKdQw8+rNy88xpPGaVSliXVk8qIvdg/9Uv ib8GZS66KCMwmEM4h5NJOBL7Ae2pMgS4E6TChNUuW/jmXO+lgucHDwT6h0n/+k3hKsNP or4JfSCVSXV0jME8/47kaHj7/mLajJo4opep5K5hJw66AAC4knvdWPHa3xA36TKT0pKY FXjg== 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:dkim-signature; bh=TN/0mIPbZrGMEPstRn7hwasmAiKTsyR2mIaJBWr6qWs=; fh=r6l/0fNLL/AXSlcs77R52Y8eFsr4+G/MvscPXgtp5Xs=; b=msihegO3n21+1/vjj8Dn22GLrm1m4WMtiDPCFkvzXOkA/2Wj2vA/mWkZEXF+d5C1uv cvAolsu4wFiWz7pbLxGFQJ2pfRbyTksr+23T2TXjcWdzLQz23N/x+5BYOz0ylCE3tGZE zvIhkmJZSb4uq6kXyA3FibmXvmZJyt4HGsVJ6c5svi7k0zjW7h5dXXQgjnHp2R2b/d1/ DQ83amRdi1eH0zLRR5TY9LOH2CrEj/FPaief7U53iCIE/1Ood5NAk051mS2GTMMv6Qnt SIe/8Axi1sPozUoIl3GfyxK7Ckb6WaNF5UrnfG15CXN48DYEbQ9/vClT2rbzCiJLUF9V N91w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NsUDOceg; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id fd22-20020a056402389600b0053fe43aaf7bsi1389820edb.641.2023.11.01.22.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 22:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NsUDOceg; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 24D92804C6D6; Wed, 1 Nov 2023 22:43:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbjKBFnc (ORCPT + 99 others); Thu, 2 Nov 2023 01:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbjKBFnc (ORCPT ); Thu, 2 Nov 2023 01:43:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE326112; Wed, 1 Nov 2023 22:43:29 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 041C9C433C8; Thu, 2 Nov 2023 05:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698903809; bh=ptXWBqG/5/N20EjAoLJcSbKkpw8UYizDxZ7qmFczEZ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NsUDOcegxMfT3N0PyIitMJFmWqA9uGO2I2KjwtRvGVRyd1yvaBKsxKne2Sb3j6t1x XUtHyz2ZrrTUFPOY8E4D08VGM/rw0/JMNKF3PZJ7KXJTQpNXkz7w2QcVlR92d9h/iG NwZXHzzw9hdU0exJQ8vqMfuHIzVcmdGa0EN59WblZC1jE3we3uh+TATRUqEfIDI7p2 zdBuobfnYOOIVb3WPUua8EtmvWNqUEiJ6n7moiiF8oMfApkLJ2mQ3XUzNrgtZpJi2a hZtTtzUc748wFeyvg27BlTsBcbd1qeCMZEE6cxKXj1xHkhKj8Ayoz0X48NpSzaBPwj 3Jsi0k7n0l6wQ== Date: Wed, 1 Nov 2023 22:43:27 -0700 From: Eric Biggers To: Jerry Shih Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, herbert@gondor.apana.org.au, davem@davemloft.net, andy.chiu@sifive.com, greentime.hu@sifive.com, conor.dooley@microchip.com, guoren@kernel.org, bjorn@rivosinc.com, heiko@sntech.de, ardb@kernel.org, phoebe.chen@sifive.com, hongrong.hsu@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH 12/12] RISC-V: crypto: add Zvkb accelerated ChaCha20 implementation Message-ID: <20231102054327.GH1498@sol.localdomain> References: <20231025183644.8735-1-jerry.shih@sifive.com> <20231025183644.8735-13-jerry.shih@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231025183644.8735-13-jerry.shih@sifive.com> X-Spam-Status: No, score=-1.6 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 01 Nov 2023 22:43:32 -0700 (PDT) On Thu, Oct 26, 2023 at 02:36:44AM +0800, Jerry Shih wrote: > +static struct skcipher_alg riscv64_chacha_alg_zvkb[] = { { > + .base = { > + .cra_name = "chacha20", > + .cra_driver_name = "chacha20-riscv64-zvkb", > + .cra_priority = 300, > + .cra_blocksize = 1, > + .cra_ctxsize = sizeof(struct chacha_ctx), > + .cra_module = THIS_MODULE, > + }, > + .min_keysize = CHACHA_KEY_SIZE, > + .max_keysize = CHACHA_KEY_SIZE, > + .ivsize = CHACHA_IV_SIZE, > + .chunksize = CHACHA_BLOCK_SIZE, > + .walksize = CHACHA_BLOCK_SIZE * 4, > + .setkey = chacha20_setkey, > + .encrypt = chacha20_encrypt, > + .decrypt = chacha20_encrypt, > +} }; > + > +static inline bool check_chacha20_ext(void) > +{ > + return riscv_isa_extension_available(NULL, ZVKB) && > + riscv_vector_vlen() >= 128; > +} > + > +static int __init riscv64_chacha_mod_init(void) > +{ > + if (check_chacha20_ext()) > + return crypto_register_skciphers( > + riscv64_chacha_alg_zvkb, > + ARRAY_SIZE(riscv64_chacha_alg_zvkb)); > + > + return -ENODEV; > +} > + > +static void __exit riscv64_chacha_mod_fini(void) > +{ > + if (check_chacha20_ext()) > + crypto_unregister_skciphers( > + riscv64_chacha_alg_zvkb, > + ARRAY_SIZE(riscv64_chacha_alg_zvkb)); > +} When there's just one algorithm being registered/unregistered, crypto_register_skcipher() and crypto_unregister_skcipher() can be used. > +# - RV64I > +# - RISC-V Vector ('V') with VLEN >= 128 > +# - RISC-V Vector Cryptography Bit-manipulation extension ('Zvkb') > +# - RISC-V Zicclsm(Main memory supports misaligned loads/stores) How is the presence of the Zicclsm extension guaranteed? - Eric