[PATCH] crypto: riscv - use real assembler for vector crypto extensions

Jerry Shih jerry.shih at sifive.com
Thu Dec 21 18:15:04 PST 2023


On Dec 20, 2023, at 14:56, Eric Biggers <ebiggers at kernel.org> wrote:
> From: Eric Biggers <ebiggers at google.com>
> 
> LLVM main and binutils master now both fully support v1.0 of the RISC-V
> vector crypto extensions.  Therefore, delete riscv.pm and use the real
> assembler mnemonics for the vector crypto instructions.
> 
> Signed-off-by: Eric Biggers <ebiggers at google.com>
> ---
> 
> Hi Jerry, this patch applies to your v3 patchset
> (https://lore.kernel.org/linux-crypto/20231205092801.1335-1-jerry.shih@sifive.com).
> Can you consider folding it into your patchset?  Thanks!

Thank you for the vector crypto asm mnemonics works.
Do you mean that fold this patch or append this one as the separated
commit into my next v4 patchset?

> arch/riscv/Kconfig                            |   6 +
> arch/riscv/crypto/Kconfig                     |  16 +-
> .../crypto/aes-riscv64-zvkned-zvbb-zvkg.pl    | 226 +++++------
> arch/riscv/crypto/aes-riscv64-zvkned-zvkb.pl  |  98 ++---
> arch/riscv/crypto/aes-riscv64-zvkned.pl       | 314 +++++++--------
> arch/riscv/crypto/chacha-riscv64-zvkb.pl      |  34 +-
> arch/riscv/crypto/ghash-riscv64-zvkg.pl       |   4 +-
> arch/riscv/crypto/riscv.pm                    | 359 ------------------
> .../sha256-riscv64-zvknha_or_zvknhb-zvkb.pl   | 101 ++---
> .../crypto/sha512-riscv64-zvknhb-zvkb.pl      |  52 +--
> arch/riscv/crypto/sm3-riscv64-zvksh.pl        |  86 ++---
> arch/riscv/crypto/sm4-riscv64-zvksed.pl       |  62 +--
> 12 files changed, 503 insertions(+), 855 deletions(-)
> delete mode 100644 arch/riscv/crypto/riscv.pm
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index dc51164b8fd4..7267a6345e32 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -531,20 +531,26 @@ config RISCV_ISA_V_PREEMPTIVE
> 	  by adding memory on demand for tracking kernel's V-context.
> 
> config TOOLCHAIN_HAS_ZBB
> 	bool
> 	default y
> 	depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb)
> 	depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb)
> 	depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
> 	depends on AS_HAS_OPTION_ARCH
> 
> +# This option indicates that the toolchain supports all v1.0 vector crypto
> +# extensions, including Zvk*, Zvbb, and Zvbc.  LLVM added all of these at once.
> +# binutils added all except Zvkb, then added Zvkb.  So we just check for Zvkb.
> +config TOOLCHAIN_HAS_ZVK
> +	def_bool $(as-instr, .option arch$(comma) +zvkb)
> +

Could we rename to other terms like
`TOOLCHAIN_HAS_VECTOR_CRYPTO/TOOLCHAIN_HAS_V_CRYPTO `?
Some ciphers don't use `ZVK*` extensions.

-Jerry




More information about the linux-riscv mailing list