Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7159800rdb; Wed, 3 Jan 2024 06:36:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGijvAksd+1YwdpAZTDijoUa1lE16ezbixG/4HkNdLLd7v+S/X0bT/KFMiSmHKwBeeK7CLa X-Received: by 2002:a05:620a:4591:b0:77f:34c1:3ef4 with SMTP id bp17-20020a05620a459100b0077f34c13ef4mr26513506qkb.72.1704292570730; Wed, 03 Jan 2024 06:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704292570; cv=none; d=google.com; s=arc-20160816; b=Xbx3cnvkbfhgoJ5dtTiMMRX/av57ReDLqCuO20ynjDbJTAV6tU9OcPtVOWKuJMn5Q4 kTBubzq4o1ATDW/akrXgvi2KF87x6NenI7E6PYt0Lzc6IocKC7Yi5PDvs00FeJbmG8Re oNo9iVE10URKNT9ypBOFXZSrz4ay79O3LEd4vcliKHMPM0+33GTJVyKavN1xkVivmP6h U1u3M0767SNRI+7jEB7nLVUMN2o7oNHd/mv6aqRBNAAHsUTPRZ726NplVFwmhxzLbIzx t3rea349PjyCpcnw3Rd9IyLSuQBE7E2Kfgo2dvqd8CZEXvit5s15s5t621KZ5t/PiGbF bA/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=J9kXRZYrWjaxjc7LDFvAViAG1zYZE3SB1BiA5jFpRGo=; fh=0VMKRBjH9P4vivwM+Nm/e8HNlsGtmY1oryef/xUJb1E=; b=VQxE+UHsSTnBT5fmLNIAnePSer6fxAl141T+sL45EijNkNNWKkZn7wfgk7GCIbUcsd EPFHfURMCv6v6WjaXC2yZxSrlqv+9i/deeqx2rqYF8qFyzHT1dS/ze/piuSr95U47A8t 5x3c7dT9//5Oo1zh2KRGf1/SvPIA7RSgEWjntV4lkYpLyfCGRXh8kW6PKrOKWQVNkBkf nvNGaKUCgVaPvOaktm0gbdZaCfhNGj7EE+AWmzqzhuEW1dduRLxenF64xIIULij8ZlM+ Chcp396s9oaEpozoFQ/7cWnNXdCmVl8NfgpFI567RUfvuTDdVH1WwiCg40v7ilhXiPXq LF3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pj111nEW; spf=pass (google.com: domain of linux-crypto+bounces-1219-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1219-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b11-20020a05620a126b00b0077f0aef8580si28681605qkl.335.2024.01.03.06.36.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 06:36:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1219-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pj111nEW; spf=pass (google.com: domain of linux-crypto+bounces-1219-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1219-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 7B2F01C23698 for ; Wed, 3 Jan 2024 14:36:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4CD91A5B2; Wed, 3 Jan 2024 14:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pj111nEW" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 982C11A5A0; Wed, 3 Jan 2024 14:36:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8961AC433C8; Wed, 3 Jan 2024 14:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704292564; bh=is7O5uMKlFnKVd3x+vpOi0jZoWskFl0wA4r7k43/gWY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pj111nEWhbwtnIBXAmtPTKY07uMZLZalmcUisGEP01x91bzK1WMukhkXdmvcbLiz4 nzjuKfvPLvnFmmJnrLQ3u5SNnbNuN7NK7IuyAO7jqoF0a4BeqbHjaoYV14ky9gjX7u AQMYN2St2mGoLuzjRd+80Ftvu2tbiJmi8zaOAteCnijOw/MGNC+tQiq1/XqiG9txGu R1dqFESMQMMqdCT57+JD8QAZu4Xa5xXNj+LQwbw3REC5LQfR/1AaGwt0+F/MikT/nw bzj0byS0nAt1ZtobKqk3F5og48OWQeWe5VrN+DFCETjFL6EO7F3nQiUlMw5X/4jtnA qAzRUdUnPCWuQ== Date: Wed, 3 Jan 2024 08:35:57 -0600 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, linux-riscv@lists.infradead.org, Jerry Shih , linux-kernel@vger.kernel.org, Heiko Stuebner , Phoebe Chen , hongrong.hsu@sifive.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Andy Chiu Subject: Re: [RFC PATCH 00/13] RISC-V crypto with reworked asm files Message-ID: <20240103143557.GA773@quark.localdomain> References: <20240102064743.220490-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jan 03, 2024 at 03:00:29PM +0100, Ard Biesheuvel wrote: > On Tue, 2 Jan 2024 at 07:50, Eric Biggers wrote: > > > > As discussed previously, the proposed use of the so-called perlasm for > > the RISC-V crypto assembly files makes them difficult to read, and these > > files have some other issues such extensively duplicating source code > > for the different AES key lengths and for the unrolled hash functions. > > There is/was a desire to share code with OpenSSL, but many of the files > > have already diverged significantly; also, for most of the algorithms > > the source code can be quite short anyway, due to the native support for > > them in the RISC-V vector crypto extensions combined with the way the > > RISC-V vector extension naturally scales to arbitrary vector lengths. > > > > Since we're still waiting for prerequisite patches to be merged anyway, > > we have a bit more time to get this cleaned up properly. So I've had a > > go at cleaning up the patchset to use standard .S files, with the code > > duplication fixed. I also made some tweaks to make the different > > algorithms consistent with each other and with what exists in the kernel > > already for other architectures, and tried to improve comments. > > > > The result is this series, which passes all tests and is about 2400 > > lines shorter than the latest version with the perlasm > > (https://lore.kernel.org/linux-crypto/20231231152743.6304-1-jerry.shih@sifive.com/). > > All the same functionality and general optimizations are still included, > > except for some minor optimizations in XTS that I dropped since it's not > > clear they are worth the complexity. (Note that almost all users of XTS > > in the kernel only use it with block-aligned messages, so it's not very > > important to optimize the ciphertext stealing case.) > > > > I'd appreciate people's thoughts on this series. Jerry, I hope I'm not > > stepping on your toes too much here, but I think there are some big > > improvements here. > > > > As I have indicated before, I fully agree with Eric here that avoiding > perlasm is preferable: sharing code with OpenSSL is great if we can > simply adopt the exact same code (and track OpenSSL as its upstream) > but this never really worked that well for skciphers, due to API > differences. (The SHA transforms can be reused a bit more easily) > > I will also note that perlasm is not as useful for RISC-V as it is for > other architectures: in OpenSSL, perlasm is also used to abstract > differences in calling conventions between, e.g., x86_64 on Linux vs > Windows, or to support building with outdated [proprietary] > toolchains. > > I do wonder if we could also use .req directives for register aliases > instead of CPP defines? It shouldn't matter for working code, but the > diagnostics tend to be a bit more useful if the aliases are visible to > the assembler. .req unfortunately isn't an option since it is specific to AArch64 and ARM assembly. So we have to use #defines like x86 does. Ultimately, the effect is about the same. - Eric