-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8354668: Missing REX2 prefix accounting in ZGC barriers leads to incorrect encoding #24664
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
Conversation
/label add hotspot-compiler-dev |
👋 Welcome back jbhateja! A progress list of the required criteria for merging this PR into |
/label add hotspot-gc-dev |
@jatin-bhateja 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:
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 121 new commits pushed to the
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 |
@jatin-bhateja |
@jatin-bhateja |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but need to communicate with JVMCI implementors.
Also pre-exisiting but maybe ZBarrierRelocationFormatLoadGoodAfterShl
should be called ZBarrierRelocationFormatLoadGoodAfterShX
as we use it for both shr and shl.
@@ -221,7 +221,7 @@ bool CodeInstaller::pd_relocate(address pc, jint mark) { | |||
return true; | |||
#if INCLUDE_ZGC | |||
case Z_BARRIER_RELOCATION_FORMAT_LOAD_GOOD_BEFORE_SHL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably communicate with the JVMCI / Graal @dougxc so we can both update this exported symbol name to reflect the new behaviour, and give them the opportunity to adapt to the new relocation patching.
This looks OK, but we could do better. Instead of making the relocation point to the end of the instruction and then looking up the offset with patch_barrier_relocation_offset(), why not make the offset always 0 and have the relocation point to the data offset inside the instruction? |
Hi @dean-long , [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp#L394 |
Yes, I am suggesting doing something like:
which would be a bigger change to the implementation. |
Hi @dean-long , |
When I made my suggestions, I didn't realize it would also require changes on the Graal side. So I would suggest a separate PR only if the Graal team agrees. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes looks good. But coordinate with the Graal team before pushing anything.
I think @dean-long's suggestion is good. But it should be done for all relocations in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me as well.
Hi @dean-long , |
/integrate |
Going to push as commit 4c37370.
Your commit was automatically rebased without conflicts. |
@jatin-bhateja Pushed as commit 4c37370. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Backed out again with #24815 due to failures in our testing. |
ZGC bookkeeps multiple place holders in barrier code snippets through relocations, these are later used to patch appropriate contents (mostly immediate values) in instruction encoding. While most of the relocation records the patching offsets from the end of the instruction, SHL instruction, which is used for pointer coloring, computes the patching offset from the starting address of the instruction.
Thus, in case the destination register operand of SHL instruction is an extended GPR register, we miss accounting additional REX2 prefix byte in patch offset, thereby corrupting the encoding since runtime patches the primary opcode byte resulting into ILLEGAL instruction exception.
This patch fixes reported failures by computing the relocation offset of SHL instruction from end of instruction, thereby making the patch offset agnostic to REX/REX2 prefix.
Please review and share your feedback.
Best Regards,
Jatin
PS: Validation were performed using latest Intel Software Development Emulator after modifying static register allocation order in x86_64.ad file giving preference to EGPRs.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24664/head:pull/24664
$ git checkout pull/24664
Update a local copy of the PR:
$ git checkout pull/24664
$ git pull https://git.openjdk.org/jdk.git pull/24664/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24664
View PR using the GUI difftool:
$ git pr show -t 24664
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24664.diff
Using Webrev
Link to Webrev Comment