-
Notifications
You must be signed in to change notification settings - Fork 566
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#6919: Fix XMM saving after synchall #6920
i#6919: Fix XMM saving after synchall #6920
Conversation
thread_set_self_mcontext should fill in fpstate from mcontext and thread_set_self_context should not call save_fpstate, which would overwrite saved state with clobbered state. This fixes saving along the following path: dispatch_enter_fcache => check_wait_at_safe_spot => thread_set_self_mcontext => thread_set_self_context The test included in this commit uses dr_flush_region to trigger a synch-all event, triggering the above path and clobbering fp regs.
The remaining failing tests do not appear to be my fault... |
I re-run your only failing test and it passed. |
If printf/assert is preferred, I am happy to change it and the test will still pass (as long as the fix is applied) The only reason I avoided these functions is that my test is so effective at triggering synchalls that it will reliably crash in these libc functions if xmm registers are not preserved (i.e. before the signal.c patch is applied). I personally preferred that the test failed gracefully, but a segfault is also clearly a failure. |
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.
Sorry for the delay: confusion over 2nd reviewer. Mostly I have style nits plus question on putting back the libc calls; after that should be good to go! Thank you for bearing with the review process.
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. Thank you for contributing!
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.
LGTM.
Thank you @ndrewh !
Sorry for the confusion. It turns out this can be fixed by just reordering the existing get_and_initialize_xstate_buffer and leaving everything else the same (I think this ended up being the same fix I proposed in the original email chain). The new fix is ready for review. I definitely just got confused while writing the test (I originally thought this fix was insufficient because it was failing in release mode -- but that was just a skill issue on my part because I had only rebuilt the debug bins with the fix). |
No worries, to be fair I think us reviewers also had trouble fully understanding as well, maybe b/c it's hard to understand this code with just a quick glance. |
The a64 drcachesim.TLB-threads online-analysis failure is a known flake "invalid exit before a bundle" #3320 |
This adds a test and a fix for #6919.
The test (modeled after the linux.sigcontext test) uses
dr_flush_region
to trigger a synchall, which causes XMM regs to be clobbered. The fix in core/unix/signal.c copies fp state from the mcontext.This fixes saving along the following path:
dispatch_enter_fcache => check_wait_at_safe_spot
=> thread_set_self_mcontext => thread_set_self_context
Fixes: #6919