Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp142209lqt; Thu, 18 Apr 2024 10:32:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+K5qVKI21ixg+rsH/u8y9vYfzmB85+1Yf2ik/nSKgcf8kTjRL/dsW5dps60qTr+ycuogo41XiJ314zFRm2fno0SsTw0XGRoTHdBIr8g== X-Google-Smtp-Source: AGHT+IF3i9DCi7yF82fPI8LHDFLmYRe1b+YnSOe7MF8+ItQlYwTg7HrTGELdbhCs7+sRTujsfDBW X-Received: by 2002:a17:90b:802:b0:2a6:f414:4e0b with SMTP id bk2-20020a17090b080200b002a6f4144e0bmr3540446pjb.41.1713461564550; Thu, 18 Apr 2024 10:32:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713461564; cv=pass; d=google.com; s=arc-20160816; b=pX4PJY3CFUiPFjYWu4yHTLhQ3gCuQqFBImUMEFaDZRw0cDauJhlap097h3TfPoOEx2 agfHuP/QAkYEOSo7fvypVfN1j1SWgqkvzY9PsdRdjwNaU/0R51+WpgwfiEia++za0X6Q UQ8xXKZdiWDCvTMbC+t58JmWSffKoNH2RqtzMJJf4HiKpitvdSbYpMYLFIG74wK/sLBm vJVONRy95poe7H0tAPUFr2zrGTqX6aOJPIwwFiZBJ53AP6yNza5auoohcXRqKQ90WlNS xolj0JOXFQtaieeWJ+8hncyF5cQOfzAxh79f9EuzlKLjeH+wfMBLWRm+G6uIznwnJEe6 hUzQ== ARC-Message-Signature: i=2; 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=IjwLMYSI20WsaFsDuqPZllXKm1myZ21qCI9s6lxJyg8=; fh=T73h2XYC4WAvI1Q3MW1h541BQoy2pbWfaZG1Lg1tQ/U=; b=KaiwZQX+bU6+fUUgttQM54JXl1C+wNGyylkA+BMbjJrRJ/ttUonSFJlLpSsP6pcYzK qNqwh4hLJ+zsIDAk5eYhrb36CkysGMba4jPrU0S0Pvrn39AUdXNKuRj/0ivSzttHUJ2d wM4kdiRcO5K1izn+rSnnnBKAQ2qr4hj+SqyiT0XeZ7j48i4XO6pV5hU3E0D67rSBALo5 Bhgk3SAj+7JvHk78V4tobjTSlpyDOb04j7wl98+3sWCDucKy13wYF0KMOfzY9bT5/Fx2 VnWMVvm2ge4YUH/U1fWu+lhuhvJ+IgY0fvvF2gg9VWADYsbTFtr07Hn8dKllYkCY6+VV WSVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CgMkaLsZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-150575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id nl6-20020a17090b384600b0029fb5c619a4si1935395pjb.137.2024.04.18.10.32.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 10:32:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CgMkaLsZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-150575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150575-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 519ADB2259C for ; Thu, 18 Apr 2024 17:32:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9414B17555C; Thu, 18 Apr 2024 17:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CgMkaLsZ" 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 AD77B15B98A; Thu, 18 Apr 2024 17:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713461526; cv=none; b=MFYwXpQhPpdeU9EooLClyfSSkBsRSiMn5a8j0JqAlnkwMul0bQT+Sje5XbQ0sq5wqhia46yR30hmHA5TgCQdC7nSlR/wsgEfUj78orei/6+HHJsGg1wzlbKHMxe85jAmNMEXCmtgvJJwtPKflO82fAM8SRpde/yyGbJNnPd/Et8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713461526; c=relaxed/simple; bh=ackjtFhEwPS1DWwxwOO1J3VcSzyK+7bkMK70V249e+M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bRIL8OG13++xbFEbWnf4r2QdMw0ryjitzQuIjMyz4sUrWEE18qM8R27RJVoPCK+uG4UaXmZxnjN8f7SYsl/tWiCoY7/bd9ROksqN3I4dASKbbC+JunllOpRDcFLaI51UTo8xPnjKWibDRbVhv4fxGdabksWw2A2JBooq4cxqKWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CgMkaLsZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90FF2C113CC; Thu, 18 Apr 2024 17:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713461526; bh=ackjtFhEwPS1DWwxwOO1J3VcSzyK+7bkMK70V249e+M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CgMkaLsZL6MDFoi5pOJZ9Uqc06yo9NSEFh/o7HjCO5s0W2kKW8/U8XwpEcOUYkfLR RuShVXQimLY85SYSdAYAGrsNvGnXS93Uc1J1h/iz1t1C0rXIsyT4PVPW+7qXgaB/3t Juw3kluI6GsEYo+wBLEAUHqdVfx4jtG9iLK5WLn2sAQJfO8LkAyTesefKFebGggfpT ZcwNGzTFBXyDliQUc3GCmxAlTaeGDadJB6/zE1C49B9xuJ4O2vgHuFfiiC9aiRqCSS AuIwkH53dn5sKGtUxzs8vuwWfGgpcuBk1DUz6E+3eX29bWLAiD2Y+mab6KB+Zjvrpj lHERzYdAahI+w== Date: Thu, 18 Apr 2024 10:32:03 -0700 From: Eric Biggers To: Conor Dooley Cc: Conor Dooley , Andy Chiu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Stuebner , Guo Ren , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Evan Green , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Shuah Khan , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Vincent Chen , Greentime Hu , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Joel Granados , Jerry Shih Subject: Re: [PATCH v4 7/9] riscv: vector: adjust minimum Vector requirement to ZVE32X Message-ID: <20240418173203.GA1081@sol.localdomain> References: <20240412-zve-detection-v4-0-e0c45bb6b253@sifive.com> <20240412-zve-detection-v4-7-e0c45bb6b253@sifive.com> <20240418-brook-chili-4d3e61d1a55c@wendy> <20240418155256.GA2410@sol.localdomain> <20240418-ultimatum-yam-11de4b063b83@spud> Precedence: bulk X-Mailing-List: linux-kernel@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: <20240418-ultimatum-yam-11de4b063b83@spud> On Thu, Apr 18, 2024 at 05:53:55PM +0100, Conor Dooley wrote: > > If it would be useful to do so, we should be able to enable some of the code > > with a smaller VLEN and/or EEW once it has been tested in those configurations. > > Some of it should work, but some of it won't be able to work. (For example, the > > SHA512 instructions require EEW==64.) > > > > Also note that currently all the RISC-V vector crypto code only supports riscv64 > > (XLEN=64). Similarly, that could be relaxed in the future if people really need > > the vector crypto acceleration on 32-bit CPUs... But similarly, the code would > > need to be revised and tested in that configuration. > > > > > Eric/Jerry (although read the previous paragraph too): > > > I noticed that the sha256 glue code calls crypto_simd_usable(), and in > > > turn may_use_simd() before kernel_vector_begin(). The chacha20 glue code > > > does not call either, which seems to violate the edict in > > > kernel_vector_begin()'s kerneldoc: > > > "Must not be called unless may_use_simd() returns true." > > > > skcipher algorithms can only be invoked in process and softirq context. This > > differs from shash algorithms which can be invoked in any context. > > > > My understanding is that, like arm64, RISC-V always allows non-nested > > kernel-mode vector to be used in process and softirq context -- and in fact, > > this was intentionally done in order to support use cases like this. So that's > > why the RISC-V skcipher algorithms don't check for may_use_simd() before calling > > kernel_vector_begin(). > > I see, thanks for explaining that. I think you should probably check > somewhere if has_vector() returns true in that driver though before > using vector instructions. Only checking vlen seems to me like relying on > an implementation detail and if we set vlen for the T-Head/0.7.1 vector > it'd be fooled. That said, I don't think that any of the 0.7.1 vector > systems actually support Zvkb, but I hope you get my drift. All the algorithms check for at least one of the vector crypto extensions being supported, for example Zvkb. 'if (riscv_isa_extension_available(NULL, ZVKB))' should return whether the ratified version of Zvkb is supported, and likewise for the other vector crypto extensions. The ratified version of the vector crypto extensions depends on the ratified version of the vector extension. So there should be no issue. If there is, the RISC-V core architecture code needs to be fixed to not declare that extensions are supported when they are actually incompatible non-standard versions of those extensions. Incompatible non-standard extensions should be represented as separate extensions. - Eric