Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8319716: RISC-V: Add SHA-2 #16562

Closed
wants to merge 22 commits into from
Closed

8319716: RISC-V: Add SHA-2 #16562

wants to merge 22 commits into from

Conversation

robehn
Copy link
Contributor

@robehn robehn commented Nov 8, 2023

Hi, please consider.

Main author is @luhenry, I only fixed some minor things and tested it.

Such as:
test/hotspot/jtreg/compiler/intrinsics/sha/
test/jdk/java/security/MessageDigest/
test/jdk/jdk/security/
tier1

And still running some test.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

Reviewers

Contributors

  • Robbin Ehn <rehn@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16562/head:pull/16562
$ git checkout pull/16562

Update a local copy of the PR:
$ git checkout pull/16562
$ git pull https://git.openjdk.org/jdk.git pull/16562/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16562

View PR using the GUI difftool:
$ git pr show -t 16562

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16562.diff

Webrev

Link to Webrev Comment

@robehn robehn changed the title SHA-2 8319716: RISC-V: Add SHA-2 Nov 8, 2023
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 8, 2023

👋 Welcome back rehn! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 8, 2023
@openjdk
Copy link

openjdk bot commented Nov 8, 2023

@robehn The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Nov 8, 2023
@robehn
Copy link
Contributor Author

robehn commented Nov 8, 2023

/author set @luhenry

@robehn
Copy link
Contributor Author

robehn commented Nov 8, 2023

/contributor add @robehn

@openjdk
Copy link

openjdk bot commented Nov 8, 2023

@robehn
Setting overriding author to Ludovic Henry <luhenry@openjdk.org>. When this pull request is integrated, the overriding author will be used in the commit.

@openjdk
Copy link

openjdk bot commented Nov 8, 2023

@robehn
Contributor Robbin Ehn <rehn@openjdk.org> successfully added.

@mlbridge
Copy link

mlbridge bot commented Nov 8, 2023

@VladimirKempik
Copy link

We still have https://bugs.openjdk.org/browse/JDK-8295382 and https://bugs.openjdk.org/browse/JDK-8295383, some of them should be marked as duplicates, or this PR need to go under 8295382&8295383 issues

@robehn
Copy link
Contributor Author

robehn commented Nov 9, 2023

We still have https://bugs.openjdk.org/browse/JDK-8295382 and https://bugs.openjdk.org/browse/JDK-8295383, some of them should be marked as duplicates, or this PR need to go under 8295382&8295383 issues

Ah, I missed them, thanks, closed as dups.

@RealFYang
Copy link
Member

Hi, I am told today that a riscv64 version of sha256/512 for openssl has been added two weeks ago [1][2]
Seems their version are more efficient after a brief look. Might be a good reference for us I guess.

[1] https://github.com/openssl/openssl/blob/master/crypto/sha/asm/sha256-riscv64-zvkb-zvknha_or_zvknhb.pl
[2] https://github.com/openssl/openssl/blob/master/crypto/sha/asm/sha512-riscv64-zvkb-zvknhb.pl

@robehn
Copy link
Contributor Author

robehn commented Nov 9, 2023

AFIACT the are pretty much the same, except for constants handling in 256.
Openssl preloads the constants into V10->V25 for 256.
I think that is beneficial for multi block, but not for single pass.

Compare these 512 round 2s:

    __ vl1re64_v(v15, consts);     |    @{[vle64_v $V20, ($KT)]}
    __ addi(consts, consts, 32);   |    addi $KT, $KT, 32
    __ vadd_vv(v14, v15, v12);     |    @{[vadd_vv $V18, $V20, $V14]}
    __ vsha2cl_vv(v17, v16, v14);  |    @{[vsha2cl_vv $V24, $V22, $V18]}
    __ vsha2ch_vv(v16, v17, v14);  |    @{[vsha2ch_vv $V22, $V24, $V18]}
    __ vmerge_vvm(v14, v10, v13);  |    @{[vmerge_vvm $V18, $V10, $V16, $V0]}
    __ vsha2ms_vv(v12, v14, v11);  |    @{[vsha2ms_vv $V14, $V18, $V12]}

I suggest we create a new enhancement for preload constants in 256 multi-block and ship this.

@RealFYang
Copy link
Member

@robehn : Thanks for checking & comparing those two versions. I think I can take a more closer look tomorrow or maybe next week.

@robehn
Copy link
Contributor Author

robehn commented Nov 9, 2023

@robehn : Thanks for checking & comparing those two versions. I think I can take a more closer look tomorrow or maybe next week.

No rush at all, rdp1 is 4 weeks away :)

And we also need to sort out what our future plans is for describing the arch.
LLVM supports 100+ extensions now, the plan can't be add these as UseXXX flags :)

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
@robehn
Copy link
Contributor Author

robehn commented Nov 28, 2023

An update, not all comments addressed yet.

Copy link

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

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

Thanks for updating.
Please check the initial comments below.

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/macroAssembler_riscv.hpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/vm_version_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
Copy link

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

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

Some other comments

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
@robehn
Copy link
Contributor Author

robehn commented Dec 22, 2023

Passes compiler/intrinsics/sha/ with:
QEMU_CPU=rv64,v=true,vext_spec=v1.0,vlen=128,elen=64,rvv_ma_all_1s=true,rvv_ta_all_1s=true,zvknhb=true
QEMU_CPU=rv64,v=true,vext_spec=v1.0,vlen=256,elen=64,rvv_ma_all_1s=true,rvv_ta_all_1s=true,zvknhb=true

This part:

function clause execute (VSHA2c(vs2, vs1, vd)) = {
  if(LMUL*VLEN < EGW)  then {
    handle_illegal();  // illegal instruction exception
    RETIRE_FAIL
  } else {

Seems not to be implemented in qemu as only using m1 passes also, since almost all instructions are fixed width (the few that aren't splatting is okay).

Please consider :)

Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Hi, Thanks for the update. Having another look :-)

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Outdated Show resolved Hide resolved
@robehn
Copy link
Contributor Author

robehn commented Jan 5, 2024

Ran the tests (compiler/intrinsics/sha/) with -XX:+PrintFlagsFinal and verified the MaxVectorSize was 16/32.
Manually tested the flags.

Thanks, Robbin

Copy link

@Hamlin-Li Hamlin-Li left a comment

Choose a reason for hiding this comment

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

Thanks for updating, looks good to me.

@openjdk
Copy link

openjdk bot commented Jan 7, 2024

@robehn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8319716: RISC-V: Add SHA-2

Co-authored-by: Robbin Ehn <rehn@openjdk.org>
Reviewed-by: fyang, mli, luhenry

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 18 new commits pushed to the master branch:

  • d75d876: 8322806: Eliminate -Wparentheses warnings in aarch64 code
  • e442769: 8322754: click JComboBox when dialog about to close causes IllegalComponentStateException
  • 3560e68: 8322815: Eliminate -Wparentheses warnings in shenandoah code
  • faa9c69: 8322846: Running with -Djdk.tracePinnedThreads set can hang
  • ace010b: 8319757: java/nio/channels/DatagramChannel/InterruptibleOrNot.java failed: wrong exception thrown
  • be4614e: 8323016: Improve reporting for bad options
  • 35a1b77: 8322636: [JVMCI] HotSpotSpeculationLog can be inconsistent across a single compile
  • 46965a0: 8322981: Fix 2 locations in JDI that throw IOException without using the "Caused by" exception
  • 700c25f: 8322954: Shenandoah: Convert evac-update closures asserts to rich asserts
  • 631a9f6: 8323073: ProblemList gc/g1/TestSkipRebuildRemsetPhase.java on linux-aarch64
  • ... and 8 more: https://git.openjdk.org/jdk/compare/2a9c3589d941d9a57e536ea0b3d7919c6ddb82dc...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 7, 2024
Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Two minor comments remain, otherwise looks good.

src/hotspot/cpu/riscv/vm_version_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/stubGenerator_riscv.cpp Show resolved Hide resolved
Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your patience.

@robehn
Copy link
Contributor Author

robehn commented Jan 8, 2024

LGTM. Thanks for your patience.

My fault screwing up the vlen 128 testing....

Thank you!

@robehn
Copy link
Contributor Author

robehn commented Jan 8, 2024

Thanks for updating, looks good to me.

Thanks!

@robehn
Copy link
Contributor Author

robehn commented Jan 9, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Jan 9, 2024

Going to push as commit 4cf131a.
Since your change was applied there have been 44 commits pushed to the master branch:

  • 7286f52: 8322829: Refactor nioBlocker to avoid blocking while holding Thread's interrupt lock
  • 07fce8e: 8320864: Serial: Extract out Full GC related fields from ContiguousSpace
  • 176606d: 8310995: missing @SInCE tags in 36 jdk.dynalink classes
  • 8ae309e: 8318971: Better Error Handling for Jar Tool When Processing Non-existent Files
  • 841ab48: 8322657: CDS filemap fastdebug assert while loading Graal CE Polyglot in isolated classloader
  • 61ebe3b: 8323032: OptimizedModuleHandlingTest failed in dynamic CDS archive mode
  • ca9635d: 8322759: Eliminate -Wparentheses warnings in compiler code
  • 8a4dc79: 8274300: Address dsymutil warning by excluding platform specific files
  • d78e8da: 8322545: Declare newInsets as static in ThemeReader.cpp
  • 24823ba: 8323095: Expand TraceOptoParse block output abbreviations
  • ... and 34 more: https://git.openjdk.org/jdk/compare/2a9c3589d941d9a57e536ea0b3d7919c6ddb82dc...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 9, 2024
@openjdk openjdk bot closed this Jan 9, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 9, 2024
@openjdk
Copy link

openjdk bot commented Jan 9, 2024

@robehn Pushed as commit 4cf131a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@robehn robehn deleted the sha256 branch May 27, 2024 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants