Jit: Check MSR state in BLR optimization #12141
Merged
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.
When we execute a JIT block, we have to make sure that both the PC and the DR/IR bits of MSR are the same as they were when the block was compiled. When jumping to a block from the dispatcher, this is done in the way you would expect: By checking the PC and the relevant MSR bits. However, when returning to a block using the BLR optimization, we only check the PC. Checking the MSR bits is done by instead resetting the stack when the MSR changes, making PC checks afterwards fail.
Except... We were only resetting the stack on rfi instructions. There are actually many more ways for the MSR to change, and we weren't covering those at all. I looked into resetting the stack on all of them, but it would be pretty cumbersome both in terms of writing the code and in terms of how often at runtime we'd have to reset the stack, so I think the better option would be to check the MSR bits along with the PC. That's what this commit implements.