Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
i#4687: conservatively handle aflags for unrecognized (OP_xx) instructions on AArch64 #4688
i#4687: conservatively handle aflags for unrecognized (OP_xx) instructions on AArch64 #4688
Changes from 3 commits
fd040d9
b75aea8
385f7a4
23c6225
a5e4073
7523a1a
9b43b13
e8b4102
0d2f303
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Given that all of the missing opcodes are vector instructions, I would expect a very small fraction to read or write flags (or GPR's for that matter). I wonder if adding the couple of opcodes that affect flags and GPR's would not be much work. Though it's certainly more work than this workaround. Let's wait for advice from those more familiar with the a64 decoder: @AssadHashmi?
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.
The resourcing planned to address AArch64 decoder gaps has been diverted elsewhere at the present time. Reluctantly, I'd advise carrying on with the workaround. This is far from ideal for AArch64 support but we currently have to work within limited constraints. Hopefully the situation will change later in the year.
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.
Thinking more about the implications here: workarounds will have to added to multiple places and not just drreg. The drcachesim tracer does GPR analysis to elide same-base addresses. The memval tool looks at register usage. Dr. Memory, being ported now, looks at everything. (The core does flags analysis for fragment prefixes and stay-on-trace comparisons -- though I believe these have no problem today due to flags-less IBL and no trace support yet for AArch64.)
@AssadHashmi is it the case that OP_xx insructions have GPR operands in place as hinted at here #2626 (comment)? Does that reliably cover all GPR usage in such instructions?
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.
@derekbruening yes I believe that is the case. @egrimley can confirm.
The majority, if not all,
OP_xx
instructions are SIMD. Of those, GPR usage is restricted to an index register. Based on that you should be reliably covered. There may be cases of non-SIMDOP_xx
but even then you should be ok.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.
So to summarize, the recommendation is:
I would then propose: let's tweak the decoder to make the 2nd point automatic: to add aflags as read and written to every OP_xx. That might be a very simple change that would then remove the need to find and change any other code and put all the workarounds in a central place. Then we're covered for correctness for flags and GPR's and only SIMD registers have correctness issues; flags and GPR's only have performance issues.
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.
This is only handling reading flags: there are also points where drreg needs to update a spilled aflags value after an app instruction writes to the flags. That point would need a workaround as well.
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 thought that this workaround handles writing flags as well. My understanding is that even if an unrecognized application instruction (
xx
) writes to the flags, this workaround will force the flags to be restored beforexx
, effectively preventing insertion of a restore afterxx
that overwrites the write to the flags byxx
. If there is another save/restore pair by drreg after the 'xx' inst, it will not change the application view of the flags. Are you thinking of something else or am I missing something?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.
Restoring is not unreserving. drreg will assume that the app's flags value is still stored in TLS after an app read but not write of the flags, which will be incorrect after
xx
writes to the flags and changes that value. drreg will proceed to use the wrong value when restoring on future reads or unreserves.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 see.