-
Notifications
You must be signed in to change notification settings - Fork 129
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
Deferred signals investigation #1666
Comments
Spent some time today on this as a break from the SMC work, and an inconvenience is that fully restoring a context seems quite hard on aarch64, and possibly will require some sort of SMC magic (limited branch range) or a dedicated scratch register (returns to JIT only) or slightly abusing Another approach is to resume from the signal and implement our own signal queues in user mode, or to modify the restored signal state. I think i'll explore this route first. |
Investigating further while waiting for the SMC reviews,
Also hastily merged in the SMC work as unity depends on that too. Will rebase cleanly. This gets Unity 2020.1 /much/ further, with Mango getting ingame. Interestingly, unity (mono) needs full ucontext to recover from SIGSEGVs around null pointer accesses. Looks like mono generates NullReferenceExceptions and gracefully recovers there. The code is very hasty at places. POC branch >> |
Spent some time on this over the weekend, I think we should split to two parts. Deferring guest signals for (a) signal safety and for (b) state reconstruction / recovery. (a) Is easy to do by adding a "is signal pending" check before returns to the JIT (syscalls, compile code, thunks). This can be easily done either in the dispatcher/jit side, or the C++ side. The only complication is automatically restarted system calls. It has near zero overhead, and doesn't suffer from execution 'overshot', just delayed signal delivery. This will largely resolve signal safety issues. (b) Is more tricky and will come with a perf cost. |
For thunks, we may want to allow them to be interrupted, as that would be closer to what the guest application can observe when running natively. Recovering the context is not a worry in that case. |
This is implemented in the latest version, isn't it? (EDIT: Yikes, didn't mean to insta-close, hit the wrong button) |
Overview
This has interesting complications and can resolve unity problems.
Current high level idea
Add a new config option or two that enables "deferred/safe signal handling"
Other related ideas
Curent low level ideas for first implementation
ldb/stb [ctx-1], #0
+ a guard page before the context for low cost handling of "should we exit from exit point" checks(Description updated by @skmp)
The text was updated successfully, but these errors were encountered: