From 457e92d0de6138a33cb8a8ce31c6646958e43026 Mon Sep 17 00:00:00 2001 From: Nicolas Brunie Date: Wed, 25 Sep 2024 19:36:52 -0700 Subject: [PATCH 1/9] [vector crypto] Clarifying mandate for vector register index alignment to LMUL/EMUL --- src/vector-crypto.adoc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index 8c422e1c7..99588da6b 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -269,6 +269,17 @@ Element Group Size (`EGS`). LMUL constraints:: For element-group instructions, `LMUL`*`VLEN` must always be at least as large as `EGW`, otherwise an _illegal instruction exception_ is raised, even if `vl`=0. ++ +A *Vector Element Group* operand or destination sets `EMUL = LMUL`. ++ +A *Scalar Element Group* operand or destination sets `EMUL = ceil(EGW / VLEN)`. ++ +The standard RISC-V Vector mandates on vector register group indices alignment to `EMUL` apply: operand or destination register indices must be aligned to `EMUL`, all other non-aligned cases are __reserved__. ++ +[NOTE] +==== +These `EMUL` alignement constraints allow scalar element group operands to be allocated to any vector register group (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. +==== [%autowidth] [%header,cols="4,2,2"] From 5e280505178e237cf07b39b4aca36d6d252dbef0 Mon Sep 17 00:00:00 2001 From: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> Date: Thu, 26 Sep 2024 02:32:47 -0700 Subject: [PATCH 2/9] Applying Andrew's feedback Signed-off-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> --- src/vector-crypto.adoc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index 99588da6b..1fff0509a 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -270,15 +270,14 @@ LMUL constraints:: For element-group instructions, `LMUL`*`VLEN` must always be at least as large as `EGW`, otherwise an _illegal instruction exception_ is raised, even if `vl`=0. + -A *Vector Element Group* operand or destination sets `EMUL = LMUL`. +A *Vector Element Group* operand or destination has `EMUL = LMUL`. + -A *Scalar Element Group* operand or destination sets `EMUL = ceil(EGW / VLEN)`. +A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. + -The standard RISC-V Vector mandates on vector register group indices alignment to `EMUL` apply: operand or destination register indices must be aligned to `EMUL`, all other non-aligned cases are __reserved__. + [NOTE] ==== -These `EMUL` alignement constraints allow scalar element group operands to be allocated to any vector register group (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. +These `EMUL` alignement constraints allow scalar element group operands to be allocated to any vector register (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. ==== [%autowidth] From 6cf2aa089e0a3f30167fa91b0b94059f02578dff Mon Sep 17 00:00:00 2001 From: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> Date: Thu, 26 Sep 2024 02:33:07 -0700 Subject: [PATCH 3/9] Update src/vector-crypto.adoc Signed-off-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> --- src/vector-crypto.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index 1fff0509a..3cd7c703a 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -274,7 +274,6 @@ A *Vector Element Group* operand or destination has `EMUL = LMUL`. + A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. + -+ [NOTE] ==== These `EMUL` alignement constraints allow scalar element group operands to be allocated to any vector register (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. From 73618e35caf4ace061834192fce9678205fac823 Mon Sep 17 00:00:00 2001 From: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> Date: Fri, 18 Oct 2024 02:40:25 +0800 Subject: [PATCH 4/9] fixing typo Signed-off-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> --- src/vector-crypto.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index 3cd7c703a..4d9fabb97 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -276,7 +276,7 @@ A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. + [NOTE] ==== -These `EMUL` alignement constraints allow scalar element group operands to be allocated to any vector register (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. +These `EMUL` alignment constraints allow scalar element group operands to be allocated to any vector register (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. ==== [%autowidth] From c7f0dd257961c98156c2a24faff64d692e0dda1f Mon Sep 17 00:00:00 2001 From: Nicolas Brunie Date: Fri, 18 Oct 2024 14:42:07 -0700 Subject: [PATCH 5/9] Review feedback: rewording the note (and fixing the too permissing phrasing "any vector register") --- src/vector-crypto.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index 4d9fabb97..fb385bafd 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -276,7 +276,7 @@ A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. + [NOTE] ==== -These `EMUL` alignment constraints allow scalar element group operands to be allocated to any vector register (without need to be aligned to `LMUL`) for any implementation with `VLEN >= EGW`. +Scalar element group operands do not need to be aligned to LMUL for any implementation with VLEN >= EGW. ==== [%autowidth] From 361b65fc5861db0a89657751493318e9c37d4f4b Mon Sep 17 00:00:00 2001 From: Nicolas Brunie Date: Thu, 31 Oct 2024 09:48:28 -0700 Subject: [PATCH 6/9] Review feedback: Ken's comments --- src/vector-crypto.adoc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index fb385bafd..f0ae8a876 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -243,8 +243,13 @@ for vector crypto instructions. [[crypto-vector-instruction-constraints]] ==== Instruction Constraints + +All standard vector instruction constraints specified by RVV 1.0 apply to Vector Crypto instructions. +In addition to those constraints a few additional specific constraints are introduced. + The following is a quick reference for the various constraints of specific Vector Crypto instructions. + vl and vstart constraints:: Since `vl` and `vstart` refer to elements, Vector Crypto instructions that use elements groups (See <>) require that these values are an integer multiple of the @@ -269,15 +274,6 @@ Element Group Size (`EGS`). LMUL constraints:: For element-group instructions, `LMUL`*`VLEN` must always be at least as large as `EGW`, otherwise an _illegal instruction exception_ is raised, even if `vl`=0. -+ -A *Vector Element Group* operand or destination has `EMUL = LMUL`. -+ -A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. -+ -[NOTE] -==== -Scalar element group operands do not need to be aligned to LMUL for any implementation with VLEN >= EGW. -==== [%autowidth] [%header,cols="4,2,2"] @@ -317,6 +313,18 @@ all other `SEW` values are _reserved_. |=== +EMUL and Source/Destination index alignment constraints:: ++ +A *Vector Element Group* operand or destination has `EMUL = LMUL`. ++ +A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. ++ +The https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#342-vector-register-grouping-vlmul20[Standard RVV vector register group alignment constraints] apply. +[NOTE] +==== +Scalar element group operands do not need to be aligned to LMUL for any implementation with VLEN >= EGW. +==== + Source/Destination overlap constraints:: Some Vector Crypto instructions have overlap constraints. Encodings that violate these constraints are _reserved_. From 2161a3b88338ea04a30ceec06149b9008e09cc0e Mon Sep 17 00:00:00 2001 From: Nicolas Brunie Date: Thu, 31 Oct 2024 13:05:52 -0700 Subject: [PATCH 7/9] Updating links to RISC-V unprivilege manual --- src/scalar-crypto.adoc | 1 + src/v-st-ext.adoc | 1 + src/vector-crypto.adoc | 7 +++---- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/scalar-crypto.adoc b/src/scalar-crypto.adoc index 59dec79c2..64426d0dd 100644 --- a/src/scalar-crypto.adoc +++ b/src/scalar-crypto.adoc @@ -1,3 +1,4 @@ +[[crypto_scalar_instructions]] == Cryptography Extensions: Scalar & Entropy Source Instructions, Version 1.0.1 === Changelog diff --git a/src/v-st-ext.adoc b/src/v-st-ext.adoc index 30e44dcb5..a48321638 100644 --- a/src/v-st-ext.adoc +++ b/src/v-st-ext.adoc @@ -228,6 +228,7 @@ will run. The `vill` bit in `vtype` should be checked after setting code path should be provided if it is not. Alternatively, a profile can mandate the minimum SEW at each LMUL setting. +[[vector-register-grouping]] ===== Vector Register Grouping (`vlmul[2:0]`) Multiple vector registers can be grouped together, so that a single diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index f0ae8a876..f2e585660 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -319,7 +319,7 @@ A *Vector Element Group* operand or destination has `EMUL = LMUL`. + A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. + -The https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#342-vector-register-grouping-vlmul20[Standard RVV vector register group alignment constraints] apply. +The <<#vector-register-grouping, Standard RVV vector register group alignment constraints>> apply. [NOTE] ==== Scalar element group operands do not need to be aligned to LMUL for any implementation with VLEN >= EGW. @@ -370,7 +370,6 @@ The Vector Crypto Extensions define Vector-Scalar instructions that are similar Vector Reduction Operations in that they get a scalar operand from a vector register. However, they differ in that they get a scalar element group (see <>) -// link:https://github.com/riscv/riscv-v-spec/blob/master/element_groups.adoc[RISC-V Vector Element Groups]) from `vs2` and they return _vector_ results to `vd`, which is also a source vector operand. These Vector-Scalar crypto instructions also use the `.vs` suffix in their mnemonics. @@ -499,7 +498,7 @@ on _any_ embedded (Zve*) or application ("V") base Vector Extension. All _cryptography-specific_ instructions defined in this Vector Crypto specification (i.e., those in <>, <>, <>, <> and <> but _not_ <>,<>, or <>) shall be executed with data-independent execution latency as defined in the -link:https://github.com/riscv/riscv-crypto/releases/tag/v1.0.1-scalar[RISC-V Scalar Cryptography Extensions specification]. +<<#crypto_scalar_instructions,RISC-V Scalar Cryptography Extensions specification>>. It is important to note that the Vector Crypto instructions are independent of the implementation of the `Zkt` extension and do not require that `Zkt` is implemented. @@ -1015,7 +1014,7 @@ GCM/GMAC extension to enable high-performace SM4-GCM. The Zvkt extension requires all implemented instructions from the following list to be executed with data-independent execution latency as defined in the -link:https://github.com/riscv/riscv-crypto/releases/tag/v1.0.1-scalar[RISC-V Scalar Cryptography Extensions specification]. +<<#crypto_scalar_instructions,RISC-V Scalar Cryptography Extensions specification>>. Data-independent execution latency (DIEL) applies to all _data operands_ of an instruction, even those that are not a part of the body or that are inactive. However, DIEL does not apply From e50a8bd64c272f2fb3505ada6ea1e68a2c107a29 Mon Sep 17 00:00:00 2001 From: Ken Dockser Date: Mon, 4 Nov 2024 19:11:04 -0600 Subject: [PATCH 8/9] Update vector-crypto.adoc It makes sense to combine all of the vector/scalar constraints into one section. We no longer need to specify that each constraint is inherited from Vector as this is now included above. Signed-off-by: Ken Dockser --- src/vector-crypto.adoc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index f2e585660..e41745260 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -313,21 +313,14 @@ all other `SEW` values are _reserved_. |=== -EMUL and Source/Destination index alignment constraints:: -+ -A *Vector Element Group* operand or destination has `EMUL = LMUL`. -+ -A *Scalar Element Group* operand or destination has `EMUL = ceil(EGW / VLEN)`. -+ -The <<#vector-register-grouping, Standard RVV vector register group alignment constraints>> apply. +Vector/Scalar constraints:: +This specification defines new vector/scalar (.vs) instructions that used *Scalar ELement Groups*. The *Scalar Element Group* operand has `EMUL = ceil(EGW / VLEN)`. + [NOTE] ==== Scalar element group operands do not need to be aligned to LMUL for any implementation with VLEN >= EGW. ==== -Source/Destination overlap constraints:: -Some Vector Crypto instructions have overlap constraints. Encodings that violate these constraints are _reserved_. - In the case of the `.vs` instructions defined in this specification, `vs2` holds a 128-bit scalar element group. For implementations with `VLEN` ≥ 128, `vs2` refers to a single register. Thus, the `vd` register group must not overlap the `vs2` register. From 736afbc47b4b7c05b6ca75a958209479f499335e Mon Sep 17 00:00:00 2001 From: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> Date: Wed, 27 Nov 2024 03:03:07 +0800 Subject: [PATCH 9/9] review feedback: fix typo Signed-off-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> --- src/vector-crypto.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector-crypto.adoc b/src/vector-crypto.adoc index e41745260..f1a32930d 100644 --- a/src/vector-crypto.adoc +++ b/src/vector-crypto.adoc @@ -314,7 +314,7 @@ all other `SEW` values are _reserved_. |=== Vector/Scalar constraints:: -This specification defines new vector/scalar (.vs) instructions that used *Scalar ELement Groups*. The *Scalar Element Group* operand has `EMUL = ceil(EGW / VLEN)`. +This specification defines new vector/scalar (.vs) instructions that uses *Scalar Element Groups*. The *Scalar Element Group* operand has `EMUL = ceil(EGW / VLEN)`. [NOTE] ====