Skip to content

Add Zvbc32e and Zvkgs specifications (into vector crypto chapter)#2369

Open
Nicolas Brunie (nibrunieAtSi5) wants to merge 7 commits into
riscv:mainfrom
nibrunieAtSi5:zvbc32e-zvkgs-freeze
Open

Add Zvbc32e and Zvkgs specifications (into vector crypto chapter)#2369
Nicolas Brunie (nibrunieAtSi5) wants to merge 7 commits into
riscv:mainfrom
nibrunieAtSi5:zvbc32e-zvkgs-freeze

Conversation

@nibrunieAtSi5

@nibrunieAtSi5 Nicolas Brunie (nibrunieAtSi5) commented Nov 1, 2025

Copy link
Copy Markdown
Contributor

Following the ARC review on #1306, I am opening this pull-request to integrate the specifications following the ARC recommendations.

Eventually this PR will represent the frozen specifications for both Zvbc32e and Zvkgs.

RVIA tracking

This pull requests draft the changes associated with two fast track extensions for vector crypto.

Fast track is tracked in https://riscv.atlassian.net/browse/RVS-1915

New features:

  • Zvbc32e: Extending vclmul[h].v[vh] instruction to support SEW=32-bit, 16-bit and 8-bit values. Zvbc32e is available standalone (ELEN >= 32) or in addition to Zvbc (ELEN >= 64). no new encoding
  • Zvkgs: Adding .vs variants to vghsh and vgmul; should depend on Zvkg; new encodings

Related changes:

History

During the specification process for vector crypto 1.0.0 a few items had to be discarded because they appeared too late in the process. This fast track extension tries to address some of them.

The official demand that will be discussed in the Task Group and submitted to the Unpriv Committee is being drafter here: https://docs.google.com/document/d/1zpYhnZi2NxhjfcBGvPOy0oDhx6lTXchscG17Qcl6wv8/edit?usp=sharing

This pull request follows a previous PR against riscv-isa-manual, #1306, which itself was the follow-up to a pull request started on the riscv-crypto repo: riscv/riscv-crypto#362.

Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
@nibrunieAtSi5 Nicolas Brunie (nibrunieAtSi5) changed the title [NOT READY FOR REVIEW] Integrating frozen Zvbc32e and Zvkgs specifications into vector crypto chapter Add Zvbc32e and Zvkgs specifications (into vector crypto chapter) Dec 6, 2025
@nibrunieAtSi5 Nicolas Brunie (nibrunieAtSi5) marked this pull request as ready for review December 6, 2025 16:50
Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/vector-crypto.adoc Outdated
Comment thread src/rationale.adoc Outdated
Comment thread src/rationale.adoc Outdated
The Zabha extension addresses these limitations by adding support for _byte_ and
_halfword_ atomic memory operations to the RISC-V Unprivileged ISA.

=== "Zvbc32e" Extension for Vector Carry-less Multiplication for `SEW <= 32`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace all of the <= with {le} and >= with {ge}.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 7cb19f0

…apter

This changes introduces a new extension, dubbed Zvbc32e, which extends the instructions defined in Zvbc (vclmul.v[x,v] and vclmulh.v[x,v]) to support SEW 8, 16 or 32.
It was developped in the context of a fast track supported by RVIA Cryptography SIG and was submitted after Zvbc had been ratified.
Co-authored-by: Craig Topper <craig.topper@sifive.com>
Signed-off-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com>
Comment thread src/rationale.adoc


<<Zvbc>> defines vector carry-less multiplication instructions for `SEW`=64 only.
It is not suitable for implementations with small `ELEN` (32) and incurs some inefficiencies for algorithms where at least one of the multiplication operands is limited to 32 bits (or less).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is not suitable for implementations with small `ELEN` (32) and incurs some inefficiencies for algorithms where at least one of the multiplication operands is limited to 32 bits (or less).
It is not suitable for implementations with small `ELEN` (32) and incurs some inefficiencies for algorithms where at least one of the multiplication operands is limited to 32-bit (or narrower).

@pz9115

Copy link
Copy Markdown
Contributor

Just a quick update from ISCAS: we have implemented preliminary toolchain support for Zvbc32e and Zvkgs in both GCC and Binutils.

The current development branches are available here:

We will keep tracking this ISA manual PR and the related riscv-opcodes / rvv-intrinsic changes, and are happy to adjust the implementation if the specification or intrinsic naming changes before finalization.

Please feel free to add these branches to the related toolchain support list if that is useful.

Thanks.

@nibrunieAtSi5

Copy link
Copy Markdown
Contributor Author

Just a quick update from ISCAS: we have implemented preliminary toolchain support for Zvbc32e and Zvkgs in both GCC and Binutils.

The current development branches are available here:

We will keep tracking this ISA manual PR and the related riscv-opcodes / rvv-intrinsic changes, and are happy to adjust the implementation if the specification or intrinsic naming changes before finalization.

Please feel free to add these branches to the related toolchain support list if that is useful.

Thanks.

Thank you Jiawei (@pz9115), this is definitely useful.
I think the test inputs are one of the last remaining thing required to freeze Zvbc32e and Zkvgs.

I need to update this PR (rebase) but no material changes are expected at the moment.

@rjiejie

JojoR (rjiejie) commented Jun 18, 2026

Copy link
Copy Markdown

Hi, I have a question regarding the extension versioning used in this implementation. The upstream specification for Zvbc32e/Zvkgs is currently at v0.0.7 (a three-component version: major.minor.patch = 0.0.7).
However, in the LLVM/GCC codebase, the version appears to be encoded as 0p7, which under LLVM/GCC's standard MpN (major-p-minor) convention would represent version 0.7 rather than 0.0. I would have expected 0p0 to faithfully reflect the major.minor components of the spec version (0.0), with the trailing .7 being a patch-level revision that the two-component scheme simply cannot capture.
Could you clarify the rationale behind choosing 0p7? Is this an intentional flattening of the three-component spec version into the two-component LLVM/GCC scheme (i.e., treating 0.0.7 as effectively 0.7), or is there a different convention at play here?
Understanding this would help ensure consistency as the spec continues to evolve toward ratification.
Thank you!

@pz9115

Copy link
Copy Markdown
Contributor

Hi, I have a question regarding the extension versioning used in this implementation. The upstream specification for Zvbc32e/Zvkgs is currently at v0.0.7 (a three-component version: major.minor.patch = 0.0.7). However, in the LLVM/GCC codebase, the version appears to be encoded as 0p7, which under LLVM/GCC's standard MpN (major-p-minor) convention would represent version 0.7 rather than 0.0. I would have expected 0p0 to faithfully reflect the major.minor components of the spec version (0.0), with the trailing .7 being a patch-level revision that the two-component scheme simply cannot capture. Could you clarify the rationale behind choosing 0p7? Is this an intentional flattening of the three-component spec version into the two-component LLVM/GCC scheme (i.e., treating 0.0.7 as effectively 0.7), or is there a different convention at play here? Understanding this would help ensure consistency as the spec continues to evolve toward ratification. Thank you!

Thanks for pointing this out.

The version was encoded as 0p7 intentionally. My understanding is that
the current draft is moving toward the frozen stage, and the version used
for that frozen draft is expected to be 0.7.

Since the RISC-V toolchain ISA string only represents extension versions
as major.minor, using 0p7 follows the normal MpN convention and matches
the version we expect to track for the frozen draft. In other words, this
is not intended to preserve the earlier three-component draft document
version literally as 0.0.7.

I agree the transition from the previous 0.0.7 document version to the
toolchain 0p7 form can be confusing, so I am happy to add a clarification
in the commit message or comments if that would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ratification Pending At Ratification-Ready, pending approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants