Skip to content
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

Design a threading model to use #3

Closed
DCNick3 opened this issue Apr 27, 2021 · 0 comments
Closed

Design a threading model to use #3

DCNick3 opened this issue Apr 27, 2021 · 0 comments

Comments

@DCNick3
Copy link
Owner

DCNick3 commented Apr 27, 2021

What is threading model?

How do we map target execution threads to host threads, how we start, execute, suspend and stop them.

Design requirements:

  • Be as portable as possible, i. e. require only the bare minimum from the host platform. Currently these platforms are considered:
    • linux on x86_64
    • linux on arm64
    • windows on x86_64 (still needs some work, but should work in principle)
    • Atmosphere with libnx on arm64 (Nintendo switch homebrew)
  • Enforce strict mutual exclusion of thread execution (for both the target and native code). This is not required per se, but greatly reduces complexity (mostly concerning the memory ordering issues on arm64, which will require additional work on remill side of things)
  • Be preemptive, i. e. be able to switch threads when target code is executing (think: inifinite loop). This is only for target code, native code may be written so that it will not get stuck.

Different existing implementations:

  • qemu: make the code non-executable and handle the raised signal; needs to enforce special structure of the recompiled code (recompiled target code being separate from the native code). Needs some linker magic
  • LuaJIT: run hook in every looping path (can be changed to just an interrupt variable check). Needs some work on remill side and research into how to find good places to put the hook in LLVM IR (see 1, 2, 3)
  • luavela: similar approach; TODO: is it any different?
  • wine: Uses a combination of sending an async POSIX signal and select inside it. Good approach, but, unfortunately, works only on POSIX platforms, needs adaptation otherwise. (see 1, 2)

All of these approaches might be feasible in uwin, but portability should be considered. (The most restrictive platform for now is the Atmosphere).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant