jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8332130: RISC-V: remove wrong instructions of Vector Crypto Extension

Open Hamlin-Li opened this issue 9 months ago • 5 comments

Hi, Can you help to reivew this simple patch to remove some wrong instrunctions on riscv? These instrunctions are wrong in that e.g. take vror.vx as example,

  • by definition of spec, it should be vror.vx vd, vs2, *rs1*, vm
  • the implementation here, it is indeed vror_vx(VectorRegister Vd, VectorRegister Vs2, *VectorRegister* Vs1, VectorMask vm = unmasked)

Thanks


Progress

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

Issue

  • JDK-8332130: RISC-V: remove wrong instructions of Vector Crypto Extension (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19211

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

Using diff file

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

Webrev

Link to Webrev Comment

Hamlin-Li avatar May 13 '24 08:05 Hamlin-Li

:wave: Welcome back mli! 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.

bridgekeeper[bot] avatar May 13 '24 08:05 bridgekeeper[bot]

@Hamlin-Li 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:

8332130: RISC-V: remove wrong instructions of Vector Crypto Extension

Reviewed-by: luhenry, fyang

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 12 new commits pushed to the master branch:

  • ea5eb74a65f20ce28fa0a94ea851915d4a6f83da: 8326404: Assertion error when trying to compile switch with fallthrough with pattern
  • beea5305b071820e2b128a55c5ca384caf470fdd: 8331907: BigInteger and BigDecimal should use optimized division
  • 440782e0160f867f08afbec0abf48d557a522c72: 8331466: Problemlist serviceability/dcmd/gc/RunFinalizationTest.java on generic-all
  • 5ded8da676d62158d0011086d7f80ff2c9096e13: 8332085: Remove 10 year old transition check in GenerateCurrencyData tool
  • 7c2c24fc0511b36132952c96be46eea5904a53c5: 8261433: Better pkcs11 performance for libpkcs11:C_EncryptInit/libpkcs11:C_DecryptInit
  • ff4bf1cf9f18547cff8f484433c3c55b4c288aaa: 8332102: Add @since to package-info of jdk.security.jarsigner
  • abf54bb1e6da6d7bc432b3e9bb3ff164a895bd3e: 8332100: Add missing @since to KeyValue::EC_TYPE in java.xml.crypto
  • 1484153c1a092cefc20270b35aa1e508280843a4: 8332080: Update troff man page for javadoc
  • 391bbbc7d0fb95b0cd55e2f56c43bee019aeab7f: 8330584: IGV: XML does not save all node properties
  • adaa509b6ed3d12569b8e5f2ec802cef22ab53c7: 8327499: MethodHandleStatics.traceLambdaForm includes methods that cannot be generated
  • ... and 2 more: https://git.openjdk.org/jdk/compare/d517d2df451e135583083ed3684d7d3241b36f76...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[bot] avatar May 13 '24 08:05 openjdk[bot]

@Hamlin-Li The following label will be automatically applied to this pull request:

  • hotspot-compiler

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[bot] avatar May 13 '24 08:05 openjdk[bot]

Webrevs

mlbridge[bot] avatar May 13 '24 08:05 mlbridge[bot]

What do you mean by wrong? Happy to remove them but we should give some more context.

Thanks, update the pr desc to explain why they're wrong.

Hamlin-Li avatar May 13 '24 09:05 Hamlin-Li

I think you mean the funct3 (OPIVV vs OPIVX) encoding is wrong?

Yes

Hamlin-Li avatar May 14 '24 06:05 Hamlin-Li

I think you mean the funct3 (OPIVV vs OPIVX) encoding is wrong?

Yes

From the RVV spec [1], the funct3 encoding for OPIVX is 0b100, which is also reflected on the instruction encoding. So why would you think it's wrong? Anything I missed?

[1] https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#vector-arithmetic-instruction-formats

RealFYang avatar May 14 '24 07:05 RealFYang

@RealFYang the .vx variant expect a scalar register while our vandn_vx takes a vector register. If we had a use for vandn_vx (or any of the other removed instructions), we would need to add another section with

#define INSN(NAME, op, funct3, funct6)                                                             \
  void NAME(VectorRegister Vd, VectorRegister Vs2, Register Rs1, VectorMask vm = unmasked) { \
    patch_VArith(op, Vd, funct3, Rs1->raw_encoding(), Vs2, vm, funct6);                            \
  }

But given we have no use for these instructions, I'm ok with removing them.

luhenry avatar May 14 '24 08:05 luhenry

@RealFYang the .vx variant expect a scalar register while our vandn_vx takes a vector register. If we had a use for vandn_vx (or any of the other removed instructions), we would need to add another section with

#define INSN(NAME, op, funct3, funct6)                                                             \
  void NAME(VectorRegister Vd, VectorRegister Vs2, Register Rs1, VectorMask vm = unmasked) { \
    patch_VArith(op, Vd, funct3, Rs1->raw_encoding(), Vs2, vm, funct6);                            \
  }

But given we have no use for these instructions, I'm ok with removing them.

Ah, I see. Looks good. Thanks.

RealFYang avatar May 14 '24 10:05 RealFYang

Sorry for misleading. Thanks @luhenry @RealFYang for your reviewing.

/integrate

Hamlin-Li avatar May 14 '24 11:05 Hamlin-Li

Going to push as commit 7ce4a13c0a891e606480e138f4025ffa328a18b3. Since your change was applied there have been 12 commits pushed to the master branch:

  • ea5eb74a65f20ce28fa0a94ea851915d4a6f83da: 8326404: Assertion error when trying to compile switch with fallthrough with pattern
  • beea5305b071820e2b128a55c5ca384caf470fdd: 8331907: BigInteger and BigDecimal should use optimized division
  • 440782e0160f867f08afbec0abf48d557a522c72: 8331466: Problemlist serviceability/dcmd/gc/RunFinalizationTest.java on generic-all
  • 5ded8da676d62158d0011086d7f80ff2c9096e13: 8332085: Remove 10 year old transition check in GenerateCurrencyData tool
  • 7c2c24fc0511b36132952c96be46eea5904a53c5: 8261433: Better pkcs11 performance for libpkcs11:C_EncryptInit/libpkcs11:C_DecryptInit
  • ff4bf1cf9f18547cff8f484433c3c55b4c288aaa: 8332102: Add @since to package-info of jdk.security.jarsigner
  • abf54bb1e6da6d7bc432b3e9bb3ff164a895bd3e: 8332100: Add missing @since to KeyValue::EC_TYPE in java.xml.crypto
  • 1484153c1a092cefc20270b35aa1e508280843a4: 8332080: Update troff man page for javadoc
  • 391bbbc7d0fb95b0cd55e2f56c43bee019aeab7f: 8330584: IGV: XML does not save all node properties
  • adaa509b6ed3d12569b8e5f2ec802cef22ab53c7: 8327499: MethodHandleStatics.traceLambdaForm includes methods that cannot be generated
  • ... and 2 more: https://git.openjdk.org/jdk/compare/d517d2df451e135583083ed3684d7d3241b36f76...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar May 14 '24 11:05 openjdk[bot]

@Hamlin-Li Pushed as commit 7ce4a13c0a891e606480e138f4025ffa328a18b3.

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

openjdk[bot] avatar May 14 '24 11:05 openjdk[bot]