[go] cmd/internal/obj/riscv: add assembly support of Zbc extension

8 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Nov 14, 2025, 3:14:45 AM11/14/25
to goph...@pubsubhelper.golang.org, Xueqi Luo, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

cmd/internal/obj/riscv: add assembly support of Zbc extension

The Zbc extension adds carry-less multiplication instructions for polynomial arithmetic over GF(2), which is used in cryptographic algorithms and error-correcting codes. The instructions included are: clmul, clmulh, and clmulr.
Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
GitHub-Last-Rev: 2cfd9b7fca589b184b849a3ca521dc4d3cb428d5
GitHub-Pull-Request: golang/go#76301

Change diff

diff --git a/src/cmd/asm/internal/asm/testdata/riscv64.s b/src/cmd/asm/internal/asm/testdata/riscv64.s
index 4615119..4b49d84 100644
--- a/src/cmd/asm/internal/asm/testdata/riscv64.s
+++ b/src/cmd/asm/internal/asm/testdata/riscv64.s
@@ -509,6 +509,11 @@
ORCB X5, X6 // 13d37228
REV8 X7, X8 // 13d4836b

+ // 28.4.3: Carry-less multiplication (Zbc)
+ CLMUL X5, X6, X7 // b313530a
+ CLMULH X5, X6, X7 // b333530a
+ CLMULR X5, X6, X7 // b323530a
+
// 28.4.4: Single-bit Instructions (Zbs)
BCLR X23, X24, X25 // b31c7c49
BCLR $63, X24 // 131cfc4b
diff --git a/src/cmd/internal/obj/riscv/anames.go b/src/cmd/internal/obj/riscv/anames.go
index 6c48e2f..1f777dd 100644
--- a/src/cmd/internal/obj/riscv/anames.go
+++ b/src/cmd/internal/obj/riscv/anames.go
@@ -263,6 +263,9 @@
"RORW",
"ORCB",
"REV8",
+ "CLMUL",
+ "CLMULH",
+ "CLMULR",
"BCLR",
"BCLRI",
"BEXT",
diff --git a/src/cmd/internal/obj/riscv/cpu.go b/src/cmd/internal/obj/riscv/cpu.go
index 60174a0..a43bb82 100644
--- a/src/cmd/internal/obj/riscv/cpu.go
+++ b/src/cmd/internal/obj/riscv/cpu.go
@@ -669,7 +669,7 @@
ASEXTH
AZEXTH

- // 28.4.3: Bitwise Rotation (Zbb)
+ // 28.4.2: Bitwise Rotation (Zbb)
AROL
AROLW
AROR
@@ -679,6 +679,11 @@
AORCB
AREV8

+ // 28.4.3: Carry-less multiplication (Zbc)
+ ACLMUL
+ ACLMULH
+ ACLMULR
+
// 28.4.4: Single-bit Instructions (Zbs)
ABCLR
ABCLRI
diff --git a/src/cmd/internal/obj/riscv/inst.go b/src/cmd/internal/obj/riscv/inst.go
index a5b3acd..a41b35d 100644
--- a/src/cmd/internal/obj/riscv/inst.go
+++ b/src/cmd/internal/obj/riscv/inst.go
@@ -1,4 +1,4 @@
-// Code generated by ./parse.py -go rv64_a rv64_c rv64_d rv64_f rv64_i rv64_m rv64_q rv64_zba rv64_zbb rv64_zbs rv_a rv_c rv_c_d rv_d rv_f rv_i rv_m rv_q rv_s rv_system rv_v rv_zba rv_zbb rv_zbs rv_zicond rv_zicsr; DO NOT EDIT.
+// Code generated by ./parse.py -go rv64_a rv64_c rv64_d rv64_f rv64_i rv64_m rv64_q rv64_zba rv64_zbb rv64_zbs rv_a rv_c rv_c_d rv_d rv_f rv_i rv_m rv_q rv_s rv_system rv_v rv_zba rv_zbb rv_zbc rv_zbs rv_zicond rv_zicsr; DO NOT EDIT.
package riscv

import "cmd/internal/obj"
@@ -170,6 +170,12 @@
return &inst{0x2, 0x4, 0x1, 0x0, 0, 0x0}
case ACXOR:
return &inst{0x21, 0x0, 0x1, 0x0, 0, 0x0}
+ case ACLMUL:
+ return &inst{0x33, 0x1, 0x0, 0x0, 160, 0x5}
+ case ACLMULH:
+ return &inst{0x33, 0x3, 0x0, 0x0, 160, 0x5}
+ case ACLMULR:
+ return &inst{0x33, 0x2, 0x0, 0x0, 160, 0x5}
case ACLZ:
return &inst{0x13, 0x1, 0x0, 0x0, 1536, 0x30}
case ACLZW:
diff --git a/src/cmd/internal/obj/riscv/obj.go b/src/cmd/internal/obj/riscv/obj.go
index 3deab34..dd13bba 100644
--- a/src/cmd/internal/obj/riscv/obj.go
+++ b/src/cmd/internal/obj/riscv/obj.go
@@ -2621,7 +2621,7 @@
AXNOR & obj.AMask: {enc: rIIIEncoding, ternary: true},
AZEXTH & obj.AMask: {enc: rIIEncoding},

- // 28.4.3: Bitwise Rotation (Zbb)
+ // 28.4.2: Bitwise Rotation (Zbb)
AROL & obj.AMask: {enc: rIIIEncoding, ternary: true},
AROLW & obj.AMask: {enc: rIIIEncoding, ternary: true},
AROR & obj.AMask: {enc: rIIIEncoding, immForm: ARORI, ternary: true},
@@ -2631,6 +2631,11 @@
AORCB & obj.AMask: {enc: rIIEncoding},
AREV8 & obj.AMask: {enc: rIIEncoding},

+ // 28.4.3: Carry-less Multiplication (Zbc)
+ ACLMUL & obj.AMask: {enc: rIIIEncoding, ternary: true},
+ ACLMULH & obj.AMask: {enc: rIIIEncoding, ternary: true},
+ ACLMULR & obj.AMask: {enc: rIIIEncoding, ternary: true},
+
// 28.4.4: Single-bit Instructions (Zbs)
ABCLR & obj.AMask: {enc: rIIIEncoding, immForm: ABCLRI, ternary: true},
ABCLRI & obj.AMask: {enc: iIIEncoding, ternary: true},

Change information

Files:
  • M src/cmd/asm/internal/asm/testdata/riscv64.s
  • M src/cmd/internal/obj/riscv/anames.go
  • M src/cmd/internal/obj/riscv/cpu.go
  • M src/cmd/internal/obj/riscv/inst.go
  • M src/cmd/internal/obj/riscv/obj.go
Change size: S
Delta: 5 files changed, 27 insertions(+), 3 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
Gerrit-Change-Number: 720520
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Xueqi Luo <18243...@qq.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
Nov 14, 2025, 3:14:47 AM11/14/25
to Xueqi Luo, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. You have a long 227 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
2. You usually need to reference a bug number for all but trivial or cosmetic fixes. For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message. Should you have a bug reference?

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Comment-Date: Fri, 14 Nov 2025 08:14:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Joel Sing (Gerrit)

    unread,
    Nov 22, 2025, 1:56:47 AM11/22/25
    to Xueqi Luo, Gerrit Bot, goph...@pubsubhelper.golang.org, Mark Ryan, Meng Zhuo, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Mark Ryan and Meng Zhuo

    Joel Sing added 2 comments

    Commit Message
    Line 9, Patchset 1 (Latest):The Zbc extension adds carry-less multiplication instructions for polynomial arithmetic over GF(2), which is used in cryptographic algorithms and error-correcting codes. The instructions included are: clmul, clmulh, and clmulr.
    Joel Sing . unresolved

    Please wrap to ~80 characters.

    File src/cmd/asm/internal/asm/testdata/riscv64.s
    Line 513, Patchset 1 (Latest): CLMUL X5, X6, X7 // b313530a
    Joel Sing . unresolved

    Please add two register versions (see ROL as an example):

    ```
    CLMUL X5, X6, X7
    CLMUL X5, X6
    CLMULH X5, X6, X7
    CLMULH X5, X6
    CLMULR X5, X6, X7
    CLMULR X5, X6
    ```

    (all two register forms should expand to `X5, X6, X6`)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Ryan
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Comment-Date: Sat, 22 Nov 2025 06:56:38 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gerrit Bot (Gerrit)

    unread,
    Nov 27, 2025, 1:29:33 AM11/27/25
    to Xueqi Luo, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

    Gerrit Bot uploaded new patchset

    Gerrit Bot uploaded patch set #2 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Mark Ryan
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    unsatisfied_requirement
    open
    diffy

    Xueqi Luo (Gerrit)

    unread,
    Nov 27, 2025, 1:36:27 AM11/27/25
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Mark Ryan, Joel Sing, Meng Zhuo, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

    Xueqi Luo added 2 comments

    Commit Message
    Line 9, Patchset 1:The Zbc extension adds carry-less multiplication instructions for polynomial arithmetic over GF(2), which is used in cryptographic algorithms and error-correcting codes. The instructions included are: clmul, clmulh, and clmulr.
    Joel Sing . resolved

    Please wrap to ~80 characters.

    Xueqi Luo

    Done

    File src/cmd/asm/internal/asm/testdata/riscv64.s
    Line 513, Patchset 1: CLMUL X5, X6, X7 // b313530a
    Joel Sing . unresolved

    Please add two register versions (see ROL as an example):

    ```
    CLMUL X5, X6, X7
    CLMUL X5, X6
    CLMULH X5, X6, X7
    CLMULH X5, X6
    CLMULR X5, X6, X7
    CLMULR X5, X6
    ```

    (all two register forms should expand to `X5, X6, X6`)

    Xueqi Luo

    Fixed, thank you.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Mark Ryan
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Mark Ryan <mark...@rivosinc.com>
    Gerrit-Comment-Date: Thu, 27 Nov 2025 06:36:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Joel Sing <jo...@sing.id.au>
    unsatisfied_requirement
    open
    diffy

    Gerrit Bot (Gerrit)

    unread,
    Nov 27, 2025, 1:37:11 AM11/27/25
    to Xueqi Luo, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

    Gerrit Bot uploaded new patchset

    Gerrit Bot uploaded patch set #3 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Mark Ryan
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 3
    unsatisfied_requirement
    open
    diffy

    Mark Ryan (Gerrit)

    unread,
    Jan 31, 2026, 7:50:04 AMJan 31
    to Xueqi Luo, Gerrit Bot, goph...@pubsubhelper.golang.org, Joel Sing, Meng Zhuo, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Joel Sing and Meng Zhuo

    Mark Ryan added 1 comment

    Patchset-level comments
    File-level comment, Patchset 3 (Latest):
    Mark Ryan . resolved

    Before reviewing this patch and its counterpart (https://go-review.googlesource.com/c/arch/+/735880) (thanks so much for submitting a corresponding objdump patch BTW) I guess we should discuss whether we want to add support for Zbc in golang.

    Why might we not want to add support for Zbc?

    Zbc is listed as an expansion option in the RVA profiles (https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc#rva23u64-optional-extensions) meaning that it will probably never become mandatory. The only way to safely use Zbc will be to first dynamically detect it at runtime, a check we'll never be able to avoid by setting GORISCV64. Zvbc (the vector version of Zbc) on the other hand is listed as a development option in the profiles and is expected to become mandatory in a future profile. It can be used instead of Zbc on devices that support it.

    So I guess I'm wondering whether there are any devices that support Zbc but not Zvbc? If not, then I'm not sure we'd use Zbc internally in Go. If we don't end up using Zbc internally in Go then we'd just be adding Zbc assembler support for 3rd party users of Go, which is fine if we agree it's worth doing.

    @18243...@qq.com are you aware of any RISC-V devices that support Zbc and not Zvbc?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@meta.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Comment-Date: Sat, 31 Jan 2026 12:49:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Xueqi Luo (Gerrit)

    unread,
    Feb 1, 2026, 9:38:41 PMFeb 1
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Mark Ryan, Joel Sing, Meng Zhuo, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

    Xueqi Luo added 1 comment

    Patchset-level comments
    Mark Ryan . resolved

    Before reviewing this patch and its counterpart (https://go-review.googlesource.com/c/arch/+/735880) (thanks so much for submitting a corresponding objdump patch BTW) I guess we should discuss whether we want to add support for Zbc in golang.

    Why might we not want to add support for Zbc?

    Zbc is listed as an expansion option in the RVA profiles (https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc#rva23u64-optional-extensions) meaning that it will probably never become mandatory. The only way to safely use Zbc will be to first dynamically detect it at runtime, a check we'll never be able to avoid by setting GORISCV64. Zvbc (the vector version of Zbc) on the other hand is listed as a development option in the profiles and is expected to become mandatory in a future profile. It can be used instead of Zbc on devices that support it.

    So I guess I'm wondering whether there are any devices that support Zbc but not Zvbc? If not, then I'm not sure we'd use Zbc internally in Go. If we don't end up using Zbc internally in Go then we'd just be adding Zbc assembler support for 3rd party users of Go, which is fine if we agree it's worth doing.

    @18243...@qq.com are you aware of any RISC-V devices that support Zbc and not Zvbc?

    Xueqi Luo

    Hi @mark...@meta.com

    Thanks for the feedback. To clarify the necessity of Zbc support, I’ve verified the hardware capabilities on a SOPHON SG2044 (a 64-core RISC-V server).

    While the SoC is high-performance and supports Vector (V), it implements the scalar Zbc extension but lacks Zvbc or other Vector Crypto extensions. The /proc/cpuinfo confirms this:

    isa : rv64imafdcv_..._zba_zbb_zbc_zbs_zve32f_zve32x_zve64d_zve64f_zve64x_...

    I also ran a Go feature detection tool, which confirms that cpu.RISCV64.HasZvbc is false on this production silicon.

    Since Zbc is already present in real-world server hardware while Zvbc is absent, supporting Zbc in the Go assembler allows cryptography and checksum libraries to utilize existing hardware acceleration rather than falling back to slower software implementations.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Mark Ryan
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@meta.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Mark Ryan <mark...@meta.com>
    Gerrit-Comment-Date: Mon, 02 Feb 2026 02:38:31 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Mark Ryan <mark...@meta.com>
    unsatisfied_requirement
    open
    diffy

    Mark Ryan (Gerrit)

    unread,
    Feb 14, 2026, 4:31:50 PM (11 days ago) Feb 14
    to Xueqi Luo, Gerrit Bot, goph...@pubsubhelper.golang.org, Joel Sing, Meng Zhuo, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Meng Zhuo and Xueqi Luo

    Mark Ryan added 1 comment

    Patchset-level comments
    Mark Ryan . resolved

    Before reviewing this patch and its counterpart (https://go-review.googlesource.com/c/arch/+/735880) (thanks so much for submitting a corresponding objdump patch BTW) I guess we should discuss whether we want to add support for Zbc in golang.

    Why might we not want to add support for Zbc?

    Zbc is listed as an expansion option in the RVA profiles (https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc#rva23u64-optional-extensions) meaning that it will probably never become mandatory. The only way to safely use Zbc will be to first dynamically detect it at runtime, a check we'll never be able to avoid by setting GORISCV64. Zvbc (the vector version of Zbc) on the other hand is listed as a development option in the profiles and is expected to become mandatory in a future profile. It can be used instead of Zbc on devices that support it.

    So I guess I'm wondering whether there are any devices that support Zbc but not Zvbc? If not, then I'm not sure we'd use Zbc internally in Go. If we don't end up using Zbc internally in Go then we'd just be adding Zbc assembler support for 3rd party users of Go, which is fine if we agree it's worth doing.

    @18243...@qq.com are you aware of any RISC-V devices that support Zbc and not Zvbc?

    Xueqi Luo

    Hi @mark...@meta.com

    Thanks for the feedback. To clarify the necessity of Zbc support, I’ve verified the hardware capabilities on a SOPHON SG2044 (a 64-core RISC-V server).

    While the SoC is high-performance and supports Vector (V), it implements the scalar Zbc extension but lacks Zvbc or other Vector Crypto extensions. The /proc/cpuinfo confirms this:

    isa : rv64imafdcv_..._zba_zbb_zbc_zbs_zve32f_zve32x_zve64d_zve64f_zve64x_...

    I also ran a Go feature detection tool, which confirms that cpu.RISCV64.HasZvbc is false on this production silicon.

    Since Zbc is already present in real-world server hardware while Zvbc is absent, supporting Zbc in the Go assembler allows cryptography and checksum libraries to utilize existing hardware acceleration rather than falling back to slower software implementations.

    Mark Ryan

    Thanks for checking this @18243...@qq.com. Looks like it might be worth implementing after all. Just one quick question. What kernel version were you running? I think you need 6.8 or newer to detect zvbc.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Meng Zhuo
    • Xueqi Luo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@meta.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Comment-Date: Sat, 14 Feb 2026 21:31:42 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Xueqi Luo <18243...@qq.com>
    Comment-In-Reply-To: Mark Ryan <mark...@meta.com>
    unsatisfied_requirement
    open
    diffy

    Xueqi Luo (Gerrit)

    unread,
    2:04 AM (3 hours ago) 2:04 AM
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Mark Ryan, Joel Sing, Meng Zhuo, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Joel Sing, Mark Ryan and Meng Zhuo

    Xueqi Luo added 1 comment

    Patchset-level comments
    Mark Ryan . resolved

    Before reviewing this patch and its counterpart (https://go-review.googlesource.com/c/arch/+/735880) (thanks so much for submitting a corresponding objdump patch BTW) I guess we should discuss whether we want to add support for Zbc in golang.

    Why might we not want to add support for Zbc?

    Zbc is listed as an expansion option in the RVA profiles (https://github.com/riscv/riscv-profiles/blob/main/src/rva23-profile.adoc#rva23u64-optional-extensions) meaning that it will probably never become mandatory. The only way to safely use Zbc will be to first dynamically detect it at runtime, a check we'll never be able to avoid by setting GORISCV64. Zvbc (the vector version of Zbc) on the other hand is listed as a development option in the profiles and is expected to become mandatory in a future profile. It can be used instead of Zbc on devices that support it.

    So I guess I'm wondering whether there are any devices that support Zbc but not Zvbc? If not, then I'm not sure we'd use Zbc internally in Go. If we don't end up using Zbc internally in Go then we'd just be adding Zbc assembler support for 3rd party users of Go, which is fine if we agree it's worth doing.

    @18243...@qq.com are you aware of any RISC-V devices that support Zbc and not Zvbc?

    Xueqi Luo

    Hi @mark...@meta.com

    Thanks for the feedback. To clarify the necessity of Zbc support, I’ve verified the hardware capabilities on a SOPHON SG2044 (a 64-core RISC-V server).

    While the SoC is high-performance and supports Vector (V), it implements the scalar Zbc extension but lacks Zvbc or other Vector Crypto extensions. The /proc/cpuinfo confirms this:

    isa : rv64imafdcv_..._zba_zbb_zbc_zbs_zve32f_zve32x_zve64d_zve64f_zve64x_...

    I also ran a Go feature detection tool, which confirms that cpu.RISCV64.HasZvbc is false on this production silicon.

    Since Zbc is already present in real-world server hardware while Zvbc is absent, supporting Zbc in the Go assembler allows cryptography and checksum libraries to utilize existing hardware acceleration rather than falling back to slower software implementations.

    Mark Ryan

    Thanks for checking this @18243...@qq.com. Looks like it might be worth implementing after all. Just one quick question. What kernel version were you running? I think you need 6.8 or newer to detect zvbc.

    Xueqi Luo

    Hi, @mark...@meta.com I'm using kernel 6.12, which is well above 6.8, so the detection should be reliable.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joel Sing
    • Mark Ryan
    • Meng Zhuo
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I77a40add1a795c7b90b478dc65835c689e82167a
    Gerrit-Change-Number: 720520
    Gerrit-PatchSet: 3
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Joel Sing <jo...@sing.id.au>
    Gerrit-Reviewer: Mark Ryan <mark...@meta.com>
    Gerrit-Reviewer: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Xueqi Luo <18243...@qq.com>
    Gerrit-Attention: Joel Sing <jo...@sing.id.au>
    Gerrit-Attention: Meng Zhuo <mengzh...@gmail.com>
    Gerrit-Attention: Mark Ryan <mark...@meta.com>
    Gerrit-Comment-Date: Wed, 25 Feb 2026 07:04:30 +0000
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages