Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zvk vector crypto support (v5) #1303

Merged
merged 10 commits into from
Jun 20, 2023

Commits on Jun 19, 2023

  1. List extensions alphabetically in riscv_insn_list

    The previous order lacks any obvious logic. Alphabetical order,
    while making it difficult to create interesting groupings,
    makes it easy to find which extensions are compiled in.
    
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    377fb0a View commit details
    Browse the repository at this point in the history
  2. Zvk: extensions parsing

    Zvk is the short name for the Vector Cryptography Instruction
    Set Extension Specification being defined at
    <https://github.com/riscv/riscv-crypto/tree/master/doc/vector>.
    
    This commit adds support for parsing/enabling the Zvk extensions
    (Zvbb, Zvbc, Zvkg, Zvkned, Zvknha, Zvknhb, Zvksed, Zvksh, Zvkt)
    and the combo extensions (Zvkn, Zvknc, Zvkng, Zvks, Zvksc, Zvksg).
    
    This is an early commit in a series implementing Zvk. No instructions
    are actually defined here, only infastructure that will
    support the coming extensions.
    
    The encodings for Zvk instructions have some conflicts with Zpn
    encodings. This commit marks those Zpn instructions as overlapping,
    and adds checks to error out if conflicting extensions are enabled.
    
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    1e5a71f View commit details
    Browse the repository at this point in the history
  3. Zvk: Infrastructure for Zvk extensions, element group handling

    Introduce types and macros useful across multiple Zvk sub-extensions,
    including Zvbb and Zvbc. Those will be used by upcoming
    per-sub-extension commits.
    
    In particular we introduce "Element Group" types and loop macros handling
    those element groups. The concept of element group is described in
    <https://github.com/riscv/riscv-crypto/blob/master/doc/vector/riscv-crypto-vector-element-groups.adoc>.
    
    Note that the element group access method is not implemented
    for WORDS_BIGENDIAN setup. As such, isa_parser.cc is modified to emit
    an error when WORDS_BIGENDIAN is defined and extensions using element
    groups are enabled.
    
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    d5c0339 View commit details
    Browse the repository at this point in the history
  4. Zvk: Implement Zvbb, Vector Bit-manipulation for Cryptography

    Implement the proposed instructions in Zvbb:
     - vandn.{vv,vx}, vector bitwise and-not
     - vbrev.v, vector bit reverse in element
     - vbrev8.v, vector bit reverse in bytes
     - vrev8.v, vector byte reverse
     - vctz.v, vector count trailing zeros
     - vclz.v, vector count leading zeros
     - vcpop.v, vector population count
     - vrol.{vv,vx}, vector rotate left
     - vror.{vi,vv,vx}, vector rotate right
     - vwsll.{vi,vv,vx} vector widening shift left logical
    
    A new instruction field, 'zimm6', is introduced, encoded
    in bits [15, 19] and [26].. It is used by "vror.vi" to encode
    a shift immediate in [0, 63].
    
    Co-authored-by: Raghav Gupta <rgupta@rivosinc.com>
    Co-authored-by: Stanislaw Kardach <kda@semihalf.com>
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    3 people committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    e87038e View commit details
    Browse the repository at this point in the history
  5. Zvk: Implement Zvbc extension, vectory carryless multiplaction

    Implement the Zvbc instructions
    - vclmul.{vv,vx}, vector carryless multiply low
    - vclmulh.{vv,vx}, vector carryless multiply high
    
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    d633af2 View commit details
    Browse the repository at this point in the history
  6. Zvk: Implement Zvkg, Vector GCM/GMAC instruction

    Implement the proposed instruction in Zvkg, vghmac.vv,
    Vector Carryless Multiply Accumulate over GHASH Galois-Field.
    
    The instruction performs one step of GHASH routine as described
    in "NIST Special Publication 800-38D" a.k.a the AES-GCM specification.
    The logic was written to closely track the pseudo-code
    in the Zvk specification.
    
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    Co-authored-by: Kornel Duleba <mindal@semihalf.com>
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos and kornelduleba committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    fbd4ca2 View commit details
    Browse the repository at this point in the history
  7. Zvk: Implement Zvknh[ab], NIST Suite: Vector SHA-2

    Implement the instructions part of the Zvknha and Zvknhb
    sub-extensions:
     - vsha2ms.vv, message schedule
     - vsha2ch.vv / vsha2cl.vv, compression rounds
    
    A header files for common macros is added.
    
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    00873aa View commit details
    Browse the repository at this point in the history
  8. Zvk: Implement Zvkned, vector AES single round

    Implement the Zvkned extension, "NIST Suite: Vector AES Encryption
    & Decryption (Single Round)".
     - vaeskf1.vi: AES forward key scheduling, AES-128.
     - vaeskf2.vi: AES forward key scheduling, AES-256.
     - vaesz.vs: AES encryption/decryption, 0-th round.
     - vaesdm.{vs,vv}: AES decryption, middle rounds.
     - vaesdf.{vs,vv}: AES decryption, final round.
     - vaesem.{vs,vv}: AES encryption, middle rounds.
     - vaesef.{vs,vv}: AES encryption, final round.
    
    An extension specific header containing common logic is added.
    
    Co-authored-by: Stanislaw Kardach <kda@semihalf.com>
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    egouriou-rivos and semihalf-kardach-stanislaw committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    eadb0e1 View commit details
    Browse the repository at this point in the history
  9. Zvk: Implement Zvksed, vector SM4 Block Cipher

    Implement the Zvksed sub-extension, "ShangMi Suite: SM4 Block Cipher":
     - vsm4k.vi, vector SM4 key expansion,
     - vsm4r.{vs,vv}, vector SM4 rounds.
    
    This also introduces a header for common vector SM4 logic.
    
    Co-authored-by: Raghav Gupta <rgupta@rivosinc.com>
    Co-authored-by: Albert Jakieła <aja@semihalf.com>
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    3 people committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    cbb2b1a View commit details
    Browse the repository at this point in the history
  10. Zvk: Implement Zvksh, vector SM3 Hash Function

    Implement the Zvksh sub-extension, "ShangMi Suite: SM3 Hash
    Function Instructions":
     - vsm3me.vv, message expansion,
     - vsm3c.vi, compression rounds.
    
    This also introduces a SM3 specific header for common logic.
    
    Co-authored-by: Raghav Gupta <rgupta@rivosinc.com>
    Co-authored-by: Albert Jakieła <aja@semihalf.com>
    Co-authored-by: Kornel Dulęba <mindal@semihalf.com>
    Signed-off-by: Eric Gouriou <ego@rivosinc.com>
    4 people committed Jun 19, 2023
    Configuration menu
    Copy the full SHA
    a55f96a View commit details
    Browse the repository at this point in the history