-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8276314: [JVMCI] check alignment of call displacement during code installation #6218
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
👋 Welcome back dnsimon! A progress list of the required criteria for merging this PR into |
Webrevs
|
call->set_destination(SharedRuntime::get_resolve_static_call_stub()); | ||
_instructions->relocate(call->instruction_address(), | ||
relocInfo::static_call_type, Assembler::call32_operand); | ||
break; | ||
} | ||
case INVOKESPECIAL: { | ||
assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); | ||
NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); | ||
call = nativeCall_at(_instructions->start() + pc_offset); | ||
call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); | ||
_instructions->relocate(call->instruction_address(), | ||
relocInfo::opt_virtual_call_type, Assembler::call32_operand); | ||
break; | ||
} | ||
default: | ||
JVMCI_ERROR("invalid _next_call_type value"); |
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.
May be print %d
invalid call type here too since you are changing code around.
break; | ||
return; | ||
} | ||
if (os::is_MP() && !call->is_displacement_aligned()) { |
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.
You are checking for MP
in current era? Why not always require alignment?
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.
I agree. I think C2 has always aligned and C1 used to check is_MP but no longer does. Requiring JVMCI compilers to always align seems right, particularly since we don't expose is is_MP
through JVMCI. Graal and C1 actually appear to over align the displacement by aligning it to BytesPerWord while C2 always aligns to 4 which is all that is required. It's odd that alignment check in NativeCall isn't simply displacement_offset() % 4
. The existing check implies that it's ok to use a misaligned offset as long as it starts and ends within an 8 byte region but I don't know that that would really work and none of the compilers actually take advantage of it. That's probably beyond the scope of this PR. Actually verify_alignment
checks that it's aligned on BytesPerInt so maybe is_displacement_aligned
should unify around that definition.
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.
I will remove the is_MP()
calls.
while C2 always aligns to 4
I'm having trouble finding where that is done - can you please point it out.
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.
It's deeply hidden. in x86_64.ad, it specifies the call alignment as 4 and in compute_padding it uses that alignment value to align the offset of the displacement.
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 we fix C1 and JVMCI to do the same as C2? As separate RFE.
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.
There's nothing to fix on the JVMCI side other than ensuring that we're asserting the correct alignment restrictions. Reducing the alignment to 4 instead of 8 would be a pure Graal change.
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.
It's deeply hidden
Thanks - doubt I would ever have found that in reasonable time.
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.
I meant C1 and Graal. Yes, in JVMCI we should just check correct alignment.
enhanced error message for invalid _next_call_type value removed os::is_MP test
|
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.
Good.
Please, run mach5 testing before push.
@dougxc 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 19 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 |
/integrate |
Going to push as commit 2f4b540.
Your commit was automatically rebased without conflicts. |
This PR add verification of code alignment invariants related to x64 call instructions during code installation.
This in turn allows a JVMCI compilation that generates a misaligned call to fail gracefully (i.e. bailout) instead of the VM crashing when it checks alignment before patching the displacement of a call instruction.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6218/head:pull/6218
$ git checkout pull/6218
Update a local copy of the PR:
$ git checkout pull/6218
$ git pull https://git.openjdk.java.net/jdk pull/6218/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6218
View PR using the GUI difftool:
$ git pr show -t 6218
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6218.diff