Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3601503rdh; Mon, 27 Nov 2023 20:25:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbdUlmMa1PzZHHN5ZvUQBmstHad9pKh/Z8syZtIgC6wSKWUTnqYAYvZmm4S2neKmamrNoz X-Received: by 2002:a05:6870:8dc3:b0:1fa:1d14:2a43 with SMTP id lq3-20020a0568708dc300b001fa1d142a43mr14552202oab.24.1701145515312; Mon, 27 Nov 2023 20:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701145515; cv=none; d=google.com; s=arc-20160816; b=G2kABUGRvd9RBwIRlvYGOu9HofR6OZ0zVn+O/ROQ8ZqsQiFwl47iBLd2nA4foZ9xOM 2Ehq0tgIPHwLXLK6Up/XI2ITYtW9cNwu8R875ZnMkJt3Oi1lfTsPXkKxXnMQoB1bJL56 IgdJCP4gOReTIgcjx/XKigPanmEDEgQibGPPLhk/xklmDwABvq6C2ghjJeMILptKPa7O OHLCYx7DMBhl17Oi3qQYIZDfqLGr0rCZyinhnz3RWfkztFMFjb2UArG7OW7ctYxPUCKT a9/6DoC8aACO051VrYHE2HEgGdbIWtCjvp2kdet63poGJQ+/4UsOmoPey53/u1IOv7es forg== 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=6mbHdNUvR7KOfQfgBUQ8+rMUmwOLmCgB/UQegfEO7pM=; fh=zbDRpcBgg9Y8vPgjc5rEEysmrqOVa145mcP3uY0f1po=; b=MBExe9Dmt3nt0aclovWG2+aT40B1khk8nK1MADAQQoxXAhUWcHpjq8IUy/hav/zMyV hsSKMTKiYQGiYHcjXoR26xO3ncN+j1IzRjVK7Zs2uqEvTL11PcRrTN1NdDCbm0IirBMv Hh7bzoPp6rkaqo5H2a1n1W62Qtx+4zZEZLE6n+s7ro5Krs1kiO81y5uwuKlkZiEQgtOL 1jsMTO5h4DfK7RLvAe39w08cXUpOfYKq8viewEYAyv1GiYpN1Ouww3Qd24tnVPQPuvSa PJAdwlfnYJlebUqbb2VcbbbjBKa6cnANrUWDDZ9MPXxHVI/C2OIg19YrXeKq4Ah8/9yz ljXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UgG2OmKR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id w191-20020a6382c8000000b00565e509dc75si11318477pgd.359.2023.11.27.20.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 20:25:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UgG2OmKR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-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 morse.vger.email (Postfix) with ESMTP id 3A54B810F6DA; Mon, 27 Nov 2023 20:25:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234467AbjK1EZA (ORCPT + 99 others); Mon, 27 Nov 2023 23:25:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbjK1EY7 (ORCPT ); Mon, 27 Nov 2023 23:24:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFE8B1A2 for ; Mon, 27 Nov 2023 20:25:05 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33FF1C433C8; Tue, 28 Nov 2023 04:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701145505; bh=393VLQEt4vyW6mXZn3SVeUaSptJZ9Z0HCv/6wrn7U2Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UgG2OmKRc5L3umGA0uU9/vhqiiWipuXcQGdSaRnR+puCrVVUEC51wtFrssi0XAK9W 1bRAhEun1WNkQ9xm5nTJ15vVcrcE1e5qh9blYfTrGiIeScvg5jU6TuNUjnv63Zx1Uv rncPG5OqHI3hvL1nT+mJGiMpH79zyAl7PSgjPX3qBzVEKXBksyk0jYPOnaKObP7gwF oPeauCSQYZqFW27/49jwsSwjqgvhnpRd+vPDCjHHW12QkU3zJF+fFSkSCkpbRYZUR0 aAjx54Ryy27Fmniq9u9DBrDyUFTa7R+Dpv72zMv/0XnbR/zZCJuUGBtu53m5LaR8/W pYHN2UlnN+/dA== Date: Mon, 27 Nov 2023 20:25:03 -0800 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, conor.dooley@microchip.com, ardb@kernel.org, heiko@sntech.de, 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 v2 13/13] RISC-V: crypto: add Zvkb accelerated ChaCha20 implementation Message-ID: <20231128042503.GL1463@sol.localdomain> References: <20231127070703.1697-1-jerry.shih@sifive.com> <20231127070703.1697-14-jerry.shih@sifive.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231127070703.1697-14-jerry.shih@sifive.com> X-Spam-Status: No, score=-1.2 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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 20:25:13 -0800 (PST) On Mon, Nov 27, 2023 at 03:07:03PM +0800, Jerry Shih wrote: > +config CRYPTO_CHACHA20_RISCV64 Can you call this kconfig option just CRYPTO_CHACHA_RISCV64? I.e. drop the "20". The ChaCha family of ciphers includes more than just ChaCha20. The other architectures do use "CHACHA20" in their equivalent option, even when they implement XChaCha12 too. But that's for historical reasons -- we didn't want to break anything by renaming the kconfig options. For a new option we should use the more general name from the beginning, even if initially only ChaCha20 is implemented (which is fine). > +static int chacha20_encrypt(struct skcipher_request *req) riscv64_chacha_crypt(), please. chacha20_encrypt() is dangerously close to being the same name as chacha20_crypt() which already exists in crypto/chacha.h. > +static inline bool check_chacha20_ext(void) > +{ > + return riscv_isa_extension_available(NULL, ZVKB) && > + riscv_vector_vlen() >= 128; > +} Just to double check: your intent is to simply require VLEN >= 128 for all the RISC-V vector crypto code, even when some might work with a shorter VLEN? I don't see anything in chacha-riscv64-zvkb.pl that assumes VLEN >= 128, for example. I think it would even work with VLEN == 32. I think requiring VLEN >= 128 anyway makes sense so that we don't have to worry about validating the code with shorter VLEN. And "application processors" are supposed to have VLEN >= 128. But I just wanted to make sure this is what you intended too. - Eric