All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Shih <jerry.shih@sifive.com>
To: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, herbert@gondor.apana.org.au,
	davem@davemloft.net
Cc: andy.chiu@sifive.com, greentime.hu@sifive.com,
	conor.dooley@microchip.com, guoren@kernel.org,
	bjorn@rivosinc.com, heiko@sntech.de, ebiggers@kernel.org,
	ardb@kernel.org, phoebe.chen@sifive.com, hongrong.hsu@sifive.com,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: [PATCH 00/12] RISC-V: provide some accelerated cryptography implementations using vector extensions
Date: Thu, 26 Oct 2023 02:36:32 +0800	[thread overview]
Message-ID: <20231025183644.8735-1-jerry.shih@sifive.com> (raw)

This series provides cryptographic implementations using the vector crypto
extensions[1] including:
1. AES cipher
2. AES with CBC/CTR/ECB/XTS block modes
3. ChaCha20 stream cipher
4. GHASH for GCM
5. SHA-224/256 and SHA-384/512 hash
6. SM3 hash
7. SM4 cipher

This patch set is based on Heiko Stuebner's work at:
Link: https://lore.kernel.org/all/20230711153743.1970625-1-heiko@sntech.de/

The implementations reuse the perl-asm scripts from OpenSSL[2] with some
changes adapting for the kernel crypto framework.
The perl-asm scripts generate the opcodes into `.S` files instead of asm
mnemonics. The reason for using opcodes is because the assembler hasn't
supported the vector-crypto extensions yet.

All changes pass the kernel run-time crypto self tests and the extra tests
with vector-crypto-enabled qemu.
Link: https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg08822.html

This series depend on:
1. kernel 6.6-rc7
Link: https://github.com/torvalds/linux/commit/05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1
2. support kernel-mode vector
Link: https://lore.kernel.org/all/20230721112855.1006-1-andy.chiu@sifive.com/
3. vector crypto extensions detection
Link: https://lore.kernel.org/lkml/20231017131456.2053396-1-cleger@rivosinc.com/
4. fix the error message:
    alg: skcipher: skipping comparison tests for xts-aes-aesni because
    xts(ecb(aes-generic)) is unavailable
Link: https://lore.kernel.org/linux-crypto/20231009023116.266210-1-ebiggers@kernel.org/

Here is a branch on github applying with all dependent patches:
Link: https://github.com/JerryShih/linux/tree/dev/jerrys/vector-crypto-upstream

[1]
Link: https://github.com/riscv/riscv-crypto/blob/56ed7952d13eb5bdff92e2b522404668952f416d/doc/vector/riscv-crypto-spec-vector.adoc
[2]
Link: https://github.com/openssl/openssl/pull/21923

Heiko Stuebner (2):
  RISC-V: add helper function to read the vector VLEN
  RISC-V: hook new crypto subdir into build-system

Jerry Shih (10):
  RISC-V: crypto: add OpenSSL perl module for vector instructions
  RISC-V: crypto: add Zvkned accelerated AES implementation
  crypto: scatterwalk - Add scatterwalk_next() to get the next
    scatterlist in scatter_walk
  RISC-V: crypto: add accelerated AES-CBC/CTR/ECB/XTS implementations
  RISC-V: crypto: add Zvkg accelerated GCM GHASH implementation
  RISC-V: crypto: add Zvknha/b accelerated SHA224/256 implementations
  RISC-V: crypto: add Zvknhb accelerated SHA384/512 implementations
  RISC-V: crypto: add Zvksed accelerated SM4 implementation
  RISC-V: crypto: add Zvksh accelerated SM3 implementation
  RISC-V: crypto: add Zvkb accelerated ChaCha20 implementation

 arch/riscv/Kbuild                             |    1 +
 arch/riscv/crypto/Kconfig                     |  122 ++
 arch/riscv/crypto/Makefile                    |   68 +
 .../crypto/aes-riscv64-block-mode-glue.c      |  486 +++++++
 arch/riscv/crypto/aes-riscv64-glue.c          |  163 +++
 arch/riscv/crypto/aes-riscv64-glue.h          |   28 +
 .../crypto/aes-riscv64-zvbb-zvkg-zvkned.pl    |  944 +++++++++++++
 arch/riscv/crypto/aes-riscv64-zvkb-zvkned.pl  |  416 ++++++
 arch/riscv/crypto/aes-riscv64-zvkned.pl       | 1198 +++++++++++++++++
 arch/riscv/crypto/chacha-riscv64-glue.c       |  120 ++
 arch/riscv/crypto/chacha-riscv64-zvkb.pl      |  322 +++++
 arch/riscv/crypto/ghash-riscv64-glue.c        |  191 +++
 arch/riscv/crypto/ghash-riscv64-zvkg.pl       |  100 ++
 arch/riscv/crypto/riscv.pm                    |  828 ++++++++++++
 arch/riscv/crypto/sha256-riscv64-glue.c       |  140 ++
 .../sha256-riscv64-zvkb-zvknha_or_zvknhb.pl   |  318 +++++
 arch/riscv/crypto/sha512-riscv64-glue.c       |  133 ++
 .../crypto/sha512-riscv64-zvkb-zvknhb.pl      |  266 ++++
 arch/riscv/crypto/sm3-riscv64-glue.c          |  121 ++
 arch/riscv/crypto/sm3-riscv64-zvksh.pl        |  230 ++++
 arch/riscv/crypto/sm4-riscv64-glue.c          |  120 ++
 arch/riscv/crypto/sm4-riscv64-zvksed.pl       |  268 ++++
 arch/riscv/include/asm/vector.h               |   11 +
 crypto/Kconfig                                |    3 +
 include/crypto/scatterwalk.h                  |    9 +-
 25 files changed, 6604 insertions(+), 2 deletions(-)
 create mode 100644 arch/riscv/crypto/Kconfig
 create mode 100644 arch/riscv/crypto/Makefile
 create mode 100644 arch/riscv/crypto/aes-riscv64-block-mode-glue.c
 create mode 100644 arch/riscv/crypto/aes-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/aes-riscv64-glue.h
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvbb-zvkg-zvkned.pl
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkb-zvkned.pl
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkned.pl
 create mode 100644 arch/riscv/crypto/chacha-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/chacha-riscv64-zvkb.pl
 create mode 100644 arch/riscv/crypto/ghash-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/ghash-riscv64-zvkg.pl
 create mode 100644 arch/riscv/crypto/riscv.pm
 create mode 100644 arch/riscv/crypto/sha256-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sha256-riscv64-zvkb-zvknha_or_zvknhb.pl
 create mode 100644 arch/riscv/crypto/sha512-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sha512-riscv64-zvkb-zvknhb.pl
 create mode 100644 arch/riscv/crypto/sm3-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sm3-riscv64-zvksh.pl
 create mode 100644 arch/riscv/crypto/sm4-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sm4-riscv64-zvksed.pl

--
2.28.0


WARNING: multiple messages have this Message-ID (diff)
From: Jerry Shih <jerry.shih@sifive.com>
To: paul.walmsley@sifive.com, palmer@dabbelt.com,
	aou@eecs.berkeley.edu, herbert@gondor.apana.org.au,
	davem@davemloft.net
Cc: andy.chiu@sifive.com, greentime.hu@sifive.com,
	conor.dooley@microchip.com, guoren@kernel.org,
	bjorn@rivosinc.com, heiko@sntech.de, ebiggers@kernel.org,
	ardb@kernel.org, phoebe.chen@sifive.com, hongrong.hsu@sifive.com,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: [PATCH 00/12] RISC-V: provide some accelerated cryptography implementations using vector extensions
Date: Thu, 26 Oct 2023 02:36:32 +0800	[thread overview]
Message-ID: <20231025183644.8735-1-jerry.shih@sifive.com> (raw)

This series provides cryptographic implementations using the vector crypto
extensions[1] including:
1. AES cipher
2. AES with CBC/CTR/ECB/XTS block modes
3. ChaCha20 stream cipher
4. GHASH for GCM
5. SHA-224/256 and SHA-384/512 hash
6. SM3 hash
7. SM4 cipher

This patch set is based on Heiko Stuebner's work at:
Link: https://lore.kernel.org/all/20230711153743.1970625-1-heiko@sntech.de/

The implementations reuse the perl-asm scripts from OpenSSL[2] with some
changes adapting for the kernel crypto framework.
The perl-asm scripts generate the opcodes into `.S` files instead of asm
mnemonics. The reason for using opcodes is because the assembler hasn't
supported the vector-crypto extensions yet.

All changes pass the kernel run-time crypto self tests and the extra tests
with vector-crypto-enabled qemu.
Link: https://lists.gnu.org/archive/html/qemu-devel/2023-10/msg08822.html

This series depend on:
1. kernel 6.6-rc7
Link: https://github.com/torvalds/linux/commit/05d3ef8bba77c1b5f98d941d8b2d4aeab8118ef1
2. support kernel-mode vector
Link: https://lore.kernel.org/all/20230721112855.1006-1-andy.chiu@sifive.com/
3. vector crypto extensions detection
Link: https://lore.kernel.org/lkml/20231017131456.2053396-1-cleger@rivosinc.com/
4. fix the error message:
    alg: skcipher: skipping comparison tests for xts-aes-aesni because
    xts(ecb(aes-generic)) is unavailable
Link: https://lore.kernel.org/linux-crypto/20231009023116.266210-1-ebiggers@kernel.org/

Here is a branch on github applying with all dependent patches:
Link: https://github.com/JerryShih/linux/tree/dev/jerrys/vector-crypto-upstream

[1]
Link: https://github.com/riscv/riscv-crypto/blob/56ed7952d13eb5bdff92e2b522404668952f416d/doc/vector/riscv-crypto-spec-vector.adoc
[2]
Link: https://github.com/openssl/openssl/pull/21923

Heiko Stuebner (2):
  RISC-V: add helper function to read the vector VLEN
  RISC-V: hook new crypto subdir into build-system

Jerry Shih (10):
  RISC-V: crypto: add OpenSSL perl module for vector instructions
  RISC-V: crypto: add Zvkned accelerated AES implementation
  crypto: scatterwalk - Add scatterwalk_next() to get the next
    scatterlist in scatter_walk
  RISC-V: crypto: add accelerated AES-CBC/CTR/ECB/XTS implementations
  RISC-V: crypto: add Zvkg accelerated GCM GHASH implementation
  RISC-V: crypto: add Zvknha/b accelerated SHA224/256 implementations
  RISC-V: crypto: add Zvknhb accelerated SHA384/512 implementations
  RISC-V: crypto: add Zvksed accelerated SM4 implementation
  RISC-V: crypto: add Zvksh accelerated SM3 implementation
  RISC-V: crypto: add Zvkb accelerated ChaCha20 implementation

 arch/riscv/Kbuild                             |    1 +
 arch/riscv/crypto/Kconfig                     |  122 ++
 arch/riscv/crypto/Makefile                    |   68 +
 .../crypto/aes-riscv64-block-mode-glue.c      |  486 +++++++
 arch/riscv/crypto/aes-riscv64-glue.c          |  163 +++
 arch/riscv/crypto/aes-riscv64-glue.h          |   28 +
 .../crypto/aes-riscv64-zvbb-zvkg-zvkned.pl    |  944 +++++++++++++
 arch/riscv/crypto/aes-riscv64-zvkb-zvkned.pl  |  416 ++++++
 arch/riscv/crypto/aes-riscv64-zvkned.pl       | 1198 +++++++++++++++++
 arch/riscv/crypto/chacha-riscv64-glue.c       |  120 ++
 arch/riscv/crypto/chacha-riscv64-zvkb.pl      |  322 +++++
 arch/riscv/crypto/ghash-riscv64-glue.c        |  191 +++
 arch/riscv/crypto/ghash-riscv64-zvkg.pl       |  100 ++
 arch/riscv/crypto/riscv.pm                    |  828 ++++++++++++
 arch/riscv/crypto/sha256-riscv64-glue.c       |  140 ++
 .../sha256-riscv64-zvkb-zvknha_or_zvknhb.pl   |  318 +++++
 arch/riscv/crypto/sha512-riscv64-glue.c       |  133 ++
 .../crypto/sha512-riscv64-zvkb-zvknhb.pl      |  266 ++++
 arch/riscv/crypto/sm3-riscv64-glue.c          |  121 ++
 arch/riscv/crypto/sm3-riscv64-zvksh.pl        |  230 ++++
 arch/riscv/crypto/sm4-riscv64-glue.c          |  120 ++
 arch/riscv/crypto/sm4-riscv64-zvksed.pl       |  268 ++++
 arch/riscv/include/asm/vector.h               |   11 +
 crypto/Kconfig                                |    3 +
 include/crypto/scatterwalk.h                  |    9 +-
 25 files changed, 6604 insertions(+), 2 deletions(-)
 create mode 100644 arch/riscv/crypto/Kconfig
 create mode 100644 arch/riscv/crypto/Makefile
 create mode 100644 arch/riscv/crypto/aes-riscv64-block-mode-glue.c
 create mode 100644 arch/riscv/crypto/aes-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/aes-riscv64-glue.h
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvbb-zvkg-zvkned.pl
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkb-zvkned.pl
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkned.pl
 create mode 100644 arch/riscv/crypto/chacha-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/chacha-riscv64-zvkb.pl
 create mode 100644 arch/riscv/crypto/ghash-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/ghash-riscv64-zvkg.pl
 create mode 100644 arch/riscv/crypto/riscv.pm
 create mode 100644 arch/riscv/crypto/sha256-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sha256-riscv64-zvkb-zvknha_or_zvknhb.pl
 create mode 100644 arch/riscv/crypto/sha512-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sha512-riscv64-zvkb-zvknhb.pl
 create mode 100644 arch/riscv/crypto/sm3-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sm3-riscv64-zvksh.pl
 create mode 100644 arch/riscv/crypto/sm4-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sm4-riscv64-zvksed.pl

--
2.28.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

             reply	other threads:[~2023-10-25 18:37 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25 18:36 Jerry Shih [this message]
2023-10-25 18:36 ` [PATCH 00/12] RISC-V: provide some accelerated cryptography implementations using vector extensions Jerry Shih
2023-10-25 18:36 ` [PATCH 01/12] RISC-V: add helper function to read the vector VLEN Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-10-25 18:36 ` [PATCH 02/12] RISC-V: hook new crypto subdir into build-system Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-10-25 18:36 ` [PATCH 03/12] RISC-V: crypto: add OpenSSL perl module for vector instructions Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-10-25 18:36 ` [PATCH 04/12] RISC-V: crypto: add Zvkned accelerated AES implementation Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-11-02  4:51   ` Eric Biggers
2023-11-02  4:51     ` Eric Biggers
2023-11-20  2:53     ` Jerry Shih
2023-11-20  2:53       ` Jerry Shih
2023-10-25 18:36 ` [PATCH 05/12] crypto: scatterwalk - Add scatterwalk_next() to get the next scatterlist in scatter_walk Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-10-25 18:36 ` [PATCH 06/12] RISC-V: crypto: add accelerated AES-CBC/CTR/ECB/XTS implementations Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-11-02  5:16   ` Eric Biggers
2023-11-02  5:16     ` Eric Biggers
2023-11-07  8:53     ` Jerry Shih
2023-11-07  8:53       ` Jerry Shih
2023-11-09  7:16       ` Eric Biggers
2023-11-09  7:16         ` Eric Biggers
2023-11-10  3:58         ` Jerry Shih
2023-11-10  3:58           ` Jerry Shih
2023-11-10  4:34           ` Eric Biggers
2023-11-10  4:34             ` Eric Biggers
2023-11-10  4:58         ` Andy Chiu
2023-11-10  4:58           ` Andy Chiu
2023-11-10  5:44           ` Eric Biggers
2023-11-10  5:44             ` Eric Biggers
2023-11-11 11:08             ` Ard Biesheuvel
2023-11-11 11:08               ` Ard Biesheuvel
2023-11-11 17:52               ` Eric Biggers
2023-11-11 17:52                 ` Eric Biggers
2023-11-20  2:47     ` Jerry Shih
2023-11-20  2:47       ` Jerry Shih
2023-11-20 19:28       ` Eric Biggers
2023-11-20 19:28         ` Eric Biggers
2023-11-22  1:14     ` Eric Biggers
2023-11-22  1:14       ` Eric Biggers
2023-11-27  2:52       ` Jerry Shih
2023-11-27  2:52         ` Jerry Shih
2023-11-09  8:05   ` Eric Biggers
2023-11-09  8:05     ` Eric Biggers
2023-11-10  4:06     ` Jerry Shih
2023-11-10  4:06       ` Jerry Shih
2023-11-20  2:36       ` Jerry Shih
2023-11-20  2:36         ` Jerry Shih
2023-10-25 18:36 ` [PATCH 07/12] RISC-V: crypto: add Zvkg accelerated GCM GHASH implementation Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-11-22  1:42   ` Eric Biggers
2023-11-22  1:42     ` Eric Biggers
2023-11-27  2:49     ` Jerry Shih
2023-11-27  2:49       ` Jerry Shih
2023-10-25 18:36 ` [PATCH 08/12] RISC-V: crypto: add Zvknha/b accelerated SHA224/256 implementations Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-10-25 18:36 ` [PATCH 09/12] RISC-V: crypto: add Zvknhb accelerated SHA384/512 implementations Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-11-22  1:32   ` Eric Biggers
2023-11-22  1:32     ` Eric Biggers
2023-11-27  2:50     ` Jerry Shih
2023-11-27  2:50       ` Jerry Shih
2023-10-25 18:36 ` [PATCH 10/12] RISC-V: crypto: add Zvksed accelerated SM4 implementation Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-11-02  5:58   ` Eric Biggers
2023-11-02  5:58     ` Eric Biggers
2023-11-20  2:55     ` Jerry Shih
2023-11-20  2:55       ` Jerry Shih
2023-10-25 18:36 ` [PATCH 11/12] RISC-V: crypto: add Zvksh accelerated SM3 implementation Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-10-25 18:36 ` [PATCH 12/12] RISC-V: crypto: add Zvkb accelerated ChaCha20 implementation Jerry Shih
2023-10-25 18:36   ` Jerry Shih
2023-11-02  5:43   ` Eric Biggers
2023-11-02  5:43     ` Eric Biggers
2023-11-20  2:55     ` Jerry Shih
2023-11-20  2:55       ` Jerry Shih
2023-11-20 19:18       ` Eric Biggers
2023-11-20 19:18         ` Eric Biggers
2023-11-21 10:55         ` Jerry Shih
2023-11-21 10:55           ` Jerry Shih
2023-11-21 13:14           ` Conor Dooley
2023-11-21 13:14             ` Conor Dooley
2023-11-21 23:37             ` Eric Biggers
2023-11-21 23:37               ` Eric Biggers
2023-11-22  0:39               ` Conor Dooley
2023-11-22  0:39                 ` Conor Dooley
2023-11-22 17:37             ` Jerry Shih
2023-11-22 17:37               ` Jerry Shih
2023-11-22 18:05               ` Palmer Dabbelt
2023-11-22 18:05                 ` Palmer Dabbelt
2023-11-22 18:20               ` Conor Dooley
2023-11-22 18:20                 ` Conor Dooley
2023-11-22 19:05                 ` Jerry Shih
2023-11-22 19:05                   ` Jerry Shih
2023-11-22  1:29   ` Eric Biggers
2023-11-22  1:29     ` Eric Biggers
2023-11-27  2:14     ` Jerry Shih
2023-11-27  2:14       ` Jerry Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231025183644.8735-1-jerry.shih@sifive.com \
    --to=jerry.shih@sifive.com \
    --cc=andy.chiu@sifive.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=ardb@kernel.org \
    --cc=bjorn@rivosinc.com \
    --cc=conor.dooley@microchip.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@kernel.org \
    --cc=greentime.hu@sifive.com \
    --cc=guoren@kernel.org \
    --cc=heiko@sntech.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=hongrong.hsu@sifive.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=phoebe.chen@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.