RFR: 8319716: RISC-V: Add SHA-2

Fei Yang fyang at openjdk.org
Mon Nov 13 09:11:03 UTC 2023


On Thu, 9 Nov 2023 08:03:17 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

>> src/hotspot/cpu/riscv/vm_version_riscv.cpp line 169:
>> 
>>> 167:   }
>>> 168: 
>>> 169:   if (UseZvknhb && UseZvkb) {
>> 
>> this looks weird, two jdk options needed to enable sha intrinsincs. 
>> Can we simplify it somehow  for now , like UseRVVCryptoExt ?
>> Splitting this into UseZvknhb && UseZvkb can be done in future, if it really would be needed one day
>
> Yes, this is a total mess.
> For bystanders this is a 'simple' march to clang:
> `rv64im0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zacas1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0`
> A simple RVA23U64 CPU may have like 40 extensions, a high performance server class CPU may have well over a hundred.
> 
> Just the scalar crypto ones:
> `Zbkb, Zbkc, Zbkx, Zknd, Zkne, Zknh, Zksed, Zksh, Zkr, Zkt, Zkn, Zks, Zk`
> 
> It is no reasonable to add all these as flags.
> So flags for the collections seems like much better idea.
> But we probably need to be able to turn off a sub-extension such UseZvknhb.
> "-XX:+UseVectorCryptoExt:zvknhb=false"
> Suggestions welcome.
> 
> Just top of my head, at the moment I need to supply this crazy arch string to compiler, obj dump, qemu(bit different but still crazy :) ) and there doesn't seem to be a solution near, so maybe we should be able to supply that arch string to the VM also.
> `-XX:UseArch=rv64im0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zacas1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0`

I think that's what RISC-V profiles are for [1] which make some basic extensions mandatory for each profile. And we already have JVM options like `UseRVA20U64` and `UseRVA22U64` for riscv. But there are still some optional extensions for each profile, say RVV for RVA22U64. So instead of feeding a rather long march to the JVM, I feel it's more reasonable to have some JVM options at the extension level (instead of sub-extension level) as suggested by @robehn.

Personally, I would suggest something slightly different. Say:
 "-XX:VectorCryptoExt=zvknhb", "-XX:VectorCryptoExt=zvknhb_zvkb", or "-XX:VectorCryptoExt=all"

This way we will still be able to distinguish specific sub-extensions while keeping one JVM option for each extension/collection.

[1] https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16562#discussion_r1390793824


More information about the hotspot-dev mailing list