]> git.ipfire.org Git - thirdparty/openssl.git/commit - crypto/riscv64cpuid.pl
riscv: Add basic vector extension support
authorChristoph Müllner <christoph.muellner@vrull.eu>
Tue, 14 Feb 2023 05:22:03 +0000 (06:22 +0100)
committerHugo Landau <hlandau@openssl.org>
Thu, 26 Oct 2023 14:55:49 +0000 (15:55 +0100)
commitcdea67193da8aab0f1a49d2b7ce144ad21bfc51d
tree92920e6b2f0163708a406f3a8d78f412da365dcc
parent2126ca3dba3907f49b232442c06db1cae8bee0c3
riscv: Add basic vector extension support

The RISC-V vector extension comes with an implementation-defined
number of bits per vector register (VLEN), which can be read out at
run-time using the CSR 'vlenb' (which returns VLEN/8) followed by a
multiplication by 8 (to convert bytes to bits).

This patch introduces a RISC-V capability 'V' to specify the
availability of the vector extension. If this extension is found at
run-time, then we read out VLEN as described above and cache it.
Caching ensures that we only read the CSR once at startup.
This is necessary because reading out CSR can be expensive
(e.g. if CSR readout is implemented using trap-and-emulate).

Follow-up patches can make use of VLEN and chose the best strategy
based on the available length of the vector registers.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)
crypto/riscv64cpuid.pl
crypto/riscvcap.c
include/crypto/riscv_arch.def
include/crypto/riscv_arch.h