Message ID | 20230711153743.1970625-4-heiko@sntech.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp598137vqm; Tue, 11 Jul 2023 09:20:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlHFf46cEoidFsURALLxFqo7+y61Zgx+CDLP9wHAIQV1o07gjEcKoK3xtrwUugPQ86fk8816 X-Received: by 2002:a05:6a20:8f0c:b0:131:47f7:e80d with SMTP id b12-20020a056a208f0c00b0013147f7e80dmr10492016pzk.23.1689092411653; Tue, 11 Jul 2023 09:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689092411; cv=none; d=google.com; s=arc-20160816; b=B/Ay626bBBfsSBnWn9QtHmqJjencxj22sGwPVCUYV48mUFjuROMU0fQeC4nbEA0QkJ NDHhgepqywy/mx5scavEHNcEw3kSliDe7NiMQb1lsKBUSME+5hPSSd6QUt9RaJcytpkd vq0NjDrS6UQ47R5w0ezVN0fsNiubxQIPYWgv96lQW/RztIfnX0xLWMA7fNcPiHI7ew5J aWvdSgK6R/bVhRuZ/EU63QYyLKcwDdTiroek6FEWCgASUWimuNPkTXCeiORbQK+qDlP6 Fm/vRArs7TzbPHx1eDAhYusbmN8AAQ1biAzipASF6IieAxRFyxCN3SzeuhgHK8BuOiir WYXQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=enckXy5PKEXltc++ObuBOVlkJmWTmP4SohRB35pO0nY=; fh=kdZoYQ7OxiOlgk8JV6AaRDhZ3ti3Lsh9kEAaaefSh4Y=; b=HhBQu3v03+88RLgw+z4N6DHj4/gSAmtJ85RQuDKsga7r7UvUv8oJ/qvnnqC3jdE85N WkD/OOBhQPca/Z+ha+nxlrkKbJ03aBYxN7oasYtbqu9djavPcmTJZeT2qtQbM01kFxLc 99qlgFVuE5p1RF6tN8huZFDFC71Haj+Iz03nI1hq6iMEqi9duDWxDRG7YNu+rsVm/K70 xN6v4R5N0Ooz+SZ74RPkjUex80kLXO/KD+jIPDZl+/SeIOfMir2A+qOwfzHojHj0b7b7 3wU345TjSGHYv3xVPEtcOXAGtfnPpcOOXGhmvqWFxQfwyv3sHxHgbalCuECZPF9Ufupf sniA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br9-20020a056a00440900b00666c9148d03si1681422pfb.6.2023.07.11.09.19.58; Tue, 11 Jul 2023 09:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S233131AbjGKPjb (ORCPT <rfc822;gnulinuxfreebsd@gmail.com> + 99 others); Tue, 11 Jul 2023 11:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233026AbjGKPjA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Jul 2023 11:39:00 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5351310EB; Tue, 11 Jul 2023 08:38:02 -0700 (PDT) Received: from i53875a50.versanet.de ([83.135.90.80] 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 <heiko@sntech.de>) id 1qJFQy-0000g0-G2; Tue, 11 Jul 2023 17:37:48 +0200 From: Heiko Stuebner <heiko@sntech.de> To: palmer@dabbelt.com, paul.walmsley@sifive.com Cc: aou@eecs.berkeley.edu, heiko@sntech.de, 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, ebiggers@kernel.org, Heiko Stuebner <heiko.stuebner@vrull.eu> Subject: [PATCH v4 03/12] RISC-V: add helper function to read the vector VLEN Date: Tue, 11 Jul 2023 17:37:34 +0200 Message-Id: <20230711153743.1970625-4-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230711153743.1970625-1-heiko@sntech.de> References: <20230711153743.1970625-1-heiko@sntech.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771141764571273465 X-GMAIL-MSGID: 1771141764571273465 |
Series |
RISC-V: support some cryptography accelerations
|
|
Commit Message
Heiko Stübner
July 11, 2023, 3:37 p.m. UTC
From: Heiko Stuebner <heiko.stuebner@vrull.eu> VLEN describes the length of each vector register and some instructions need specific minimal VLENs to work correctly. The vector code already includes a variable riscv_vsize that contains the value of "32 vector registers with vlenb length" that gets filled during boot. vlenb is the value contained in the CSR_VLENB register and the value represents "VLEN / 8". So add riscv_vector_vlen() to return the actual VLEN value for in-kernel users when they need to check the available VLEN. Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu> --- arch/riscv/include/asm/vector.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
Comments
Le tiistaina 11. heinäkuuta 2023, 18.37.34 EEST Heiko Stuebner a écrit : > From: Heiko Stuebner <heiko.stuebner@vrull.eu> > > VLEN describes the length of each vector register and some instructions > need specific minimal VLENs to work correctly. > > The vector code already includes a variable riscv_vsize that contains the > value of "32 vector registers with vlenb length" that gets filled during > boot. vlenb is the value contained in the CSR_VLENB register and > the value represents "VLEN / 8". > > So add riscv_vector_vlen() to return the actual VLEN value for in-kernel > users when they need to check the available VLEN. > > Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu> > --- > arch/riscv/include/asm/vector.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/arch/riscv/include/asm/vector.h > b/arch/riscv/include/asm/vector.h index ac2c23045eec..88cf76a2316d 100644 > --- a/arch/riscv/include/asm/vector.h > +++ b/arch/riscv/include/asm/vector.h > @@ -232,4 +232,15 @@ static inline bool > riscv_v_vstate_ctrl_user_allowed(void) { return false; } > > #endif /* CONFIG_RISCV_ISA_V */ > > +/* > + * Return the implementation's vlen value. > + * > + * riscv_vsize contains the value of "32 vector registers with vlenb > length" + * so rebuild the vlen value in bits from it. > + */ > +static inline int riscv_vector_vlen(void) > +{ > + return riscv_v_vsize / 32 * 8; > +} KVM already has a bespoke conversion to bytes (rather than bits). Factor code? > + > #endif /* ! __ASM_RISCV_VECTOR_H */
diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h index ac2c23045eec..88cf76a2316d 100644 --- a/arch/riscv/include/asm/vector.h +++ b/arch/riscv/include/asm/vector.h @@ -232,4 +232,15 @@ static inline bool riscv_v_vstate_ctrl_user_allowed(void) { return false; } #endif /* CONFIG_RISCV_ISA_V */ +/* + * Return the implementation's vlen value. + * + * riscv_vsize contains the value of "32 vector registers with vlenb length" + * so rebuild the vlen value in bits from it. + */ +static inline int riscv_vector_vlen(void) +{ + return riscv_v_vsize / 32 * 8; +} + #endif /* ! __ASM_RISCV_VECTOR_H */