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

Restore WASI support #165

Closed
tomaka opened this issue Dec 25, 2019 · 2 comments · Fixed by #315
Closed

Restore WASI support #165

tomaka opened this issue Dec 25, 2019 · 2 comments · Fixed by #315
Labels
A-core Issues concerning the core T-enhancement New feature or request

Comments

@tomaka
Copy link
Owner

tomaka commented Dec 25, 2019

#162 removed support for WASI, as it was too difficult/annoying to port.
Additionally, a new Rust nightly totally broke WASI by switching from wasi_unstable to wasi_preview_snapshot1 without any warning, reminding us that WASI is still unstable. #142 more or less added half-working fixes for that, but WASI hasn't properly worked since then.

The main advantage of using WASI at the moment (compared to wasm32-unknown-unknown) is that Instant::now() doesn't panic and panic messages are automatically printed on stderr.
The latter can be "fixed" by having a custom panic handler.

Last working state: https://github.com/tomaka/redshirt/tree/9b74e7bac86c73a8b9f78835627014675e3c860f/kernel/hosted-wasi

WASI should be implemented by translating WASI function calls into messages. The problem with that approach is that the PIDs of emitted messages should be correct, but if we do so then the code will simply send back the answer as if it was directly emitted by the process.

I can see four approaches to implementing WASI again:

  • Introduce the concept of messages whose answer should or should not be passed to the WASM VM. That makes things a bit more complex again.
  • Translate calls to WASI functions ahead of time by directly modifying the WASM code that is being loaded.
  • Add a layer below the IPC layer that translates WASI extrinsic calls into other extrinsic calls. Unfortunately that would require writing intermediary data to the VM's memory for it to be picked up by the IPC layer.
  • Add a layer between processes.rs and ipc.rs that interprets all extrinsics and has the concept of sending/receiving/cancelling messages in its API.

I like option #4, as it would also clean up a bit the code of ipc.rs.

@tomaka tomaka added A-core Issues concerning the core T-enhancement New feature or request labels Dec 25, 2019
@tomaka
Copy link
Owner Author

tomaka commented Dec 26, 2019

One thing to have in mind is that we want the content of the scheduler module to be multithreaded at some point. In this regard, the functions read_memory and write_memory would be extremely hard to implement.
This kind of disqualifies option 1.

@tomaka
Copy link
Owner Author

tomaka commented Mar 14, 2020

Next step is briansmith/ring#900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Issues concerning the core T-enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant