Repository navigation
Stabilize RISC-V Zk and Zb intrinsics - #2248
TechnoPorg wants to merge 1 commit into
Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @sayantn (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Why was this reviewer chosen?The reviewer was selected based on:
|
|
Error: The feature Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
Zkn intrinsicsZk and Zb intrinsics
4c5b583 to
ce1255a
Compare
ce1255a to
fbc461b
Compare
|
@rustbot blocked Based on rust-lang/rust#114544 (comment), we'd like to change to match the C API first. We should make sure there is fuzz testing against C intrinsics as mentioned in #2221 (comment). |
|
Error: The feature Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
I've just updated #2247 to match the C API.
That seems reasonable. I can start on a branch for it now, but I'd ideally like to wait until #2247 and #2254 are merged so as to not be stuck in an endless cycle of rebases.
I tried the same thing 😂 |
This comment has been minimized.
This comment has been minimized.
303f84b to
fadf8b8
Compare
This comment has been minimized.
This comment has been minimized.
|
As of commit fadf8b8, the stabilized API here matches https://github.com/riscv-non-isa/riscv-c-api-doc/blob/b3df26527b2fa27d7219b6d6abe775f6bd13615b/src/c-api.adoc "Scalar Bit Manipulation Extension Intrinsics", "Scalar Cryptography Extension Intrinsics", with the following exceptions that are available as API on integers:
Our naming and signatures now also match, with one exception: some AES functions take a We're also including the "Emulated with ... on RV64" API that is sometimes two instructions but can be optimized, also seems fine. That's my mini stabilization report, I'm not going to propose FCP since it's not yet in its final form because of |
Do we want to make these available via intrinsics? There was some dissent in rust-lang/rust#114544 about it.
I think I might as well wait for #2254. Afaik I also still need to open a PR with fuzz testing of the intrinsics against the C API before they can be stabilized. |
This comment has been minimized.
This comment has been minimized.
fadf8b8 to
7187087
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Nope, not for now. Maybe we'd want to add them later but I don't think we need to.
Ah, this hasn't been done yet? Feel free to open a draft if you have something started but need help. Until then, |
|
Error: The feature Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #triagebot on Zulip. |
I haven't found a great source for the intrinsic definitions to use in |
|
What exactly do you need? You could grab a list from https://github.com/llvm/llvm-project/blob/fa5e5fcfc594f86297d0f3bfd3f15c37cfcb87c4/clang/lib/Headers/riscv_bitmanip.h. |
|
The bitmanip ones are fine, but I'd also like the crypto intrinsic signatures, and a lot of them look like this: |
|
If you can put up a PR with what you have, somebody more familiar with the tests can probably give you a hand. Or you might be able to figure something out from the loongarch tests, which I believe has similar signatures. |
Stabilization report
Summary
These intrinsics allow using instructions from the RISC-V ratified scalar crypto extensions and bit manipulation extensions. This includes:
ZkneandZkndZknhZbkbZbkcZbkxZksedZkshThese have the potential to significantly accelerate cryptographic operations on both RV32 and RV64 devices.
Tracking:
What isn't stabilized
Other RISC-V ratified extension intrinsics, such as the packed SIMD extension
P.Design
Answers to unresolved questions
From the tracking issue:
The conclusion in rust-lang/rust#114544 from the libs team is that for this set of intrinsics, u32/u64 are preferable. This matches the way they are used by current nightly consumers and feels more appropriate given that these operate on data and not addresses.
Feedback
Nightly use
Zknhbackend.In all of these, u32/u64 are more ergonomic than usize.
Breaking changes
None.
History
ZkintrinsicsZbintrinsicsAcknowledgments
Open items
rustc_legacy_const_genericsfrom unstable intrinsics #2254No LLMs were used to write this PR.