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

Enable enclave exit when a TCS is blocked on I/O #223

Merged
merged 1 commit into from
Mar 27, 2020
Merged

Conversation

mzohreva
Copy link
Contributor

This fixes issue #109

@mzohreva mzohreva requested review from parthsane and jethrogb March 19, 2020 22:51
@mzohreva
Copy link
Contributor Author

Open questions:

  • Do we need to add the exit handler for other calls such as alloc/free/async_queues/insecure_time, etc?
  • Is there a better way to avoid creating an extra future?

@@ -1083,6 +1092,23 @@ impl<T: UsercallExtension> From<T> for Box<dyn UsercallExtension> {
struct UsercallExtensionDefault;
impl UsercallExtension for UsercallExtensionDefault {}

macro_rules! with_exit_handler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems complicated, I'd much rather have something where we make use of tokio's task cancellation mechanisms such as https://docs.rs/tokio/0.2.13/tokio/runtime/struct.Runtime.html#method.shutdown_timeout

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if this is wrapping all usercalls, couldn't it be done one level down in the stack (in usercall dispatch)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use of tokio's task cancellation mechanisms such as https://docs.rs/tokio/0.2.13/tokio/runtime/struct.Runtime.html#method.shutdown_timeout

That would require upgrading to tokio 0.2, I'll explore that option using PR #210

couldn't it be done one level down in the stack (in usercall dispatch)?

Good idea, I'll give that a shot

@jethrogb
Copy link
Member

Can we add some tests? Maybe they could be part of the rust-lang/rust test suite.

@mzohreva mzohreva force-pushed the mz/fix_exit_io_block branch from 20383f3 to 8dd1f3a Compare March 23, 2020 20:55
@mzohreva
Copy link
Contributor Author

Just found out that the parallel future approach implemented here is not necessary. The blocking issue appears to be due to the following line in syscall_loop():

tokio::runtime::current_thread::block_on_all(select_fut.unit_error().compat()).unwrap()

The documentation for tokio::runtime::current_thread::block_on_all() says:

This first creates a new Runtime, and calls Runtime::block_on with the provided future, which blocks the current thread until the provided future completes. It then calls Runtime::run to wait for any other spawned futures to resolve.

The problematic part is the It then calls Runtime::run to wait for any other spawned futures to resolve. and that is not what we need in syscall_loop. We want to return from syscall_loop as soon as the select future returns.

I'll update this PR accordingly.

@mzohreva mzohreva force-pushed the mz/fix_exit_io_block branch from 8dd1f3a to a9e3c75 Compare March 23, 2020 23:43
@mzohreva mzohreva force-pushed the mz/fix_exit_io_block branch from a9e3c75 to dcfd632 Compare March 25, 2020 21:26
@jethrogb
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 27, 2020

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit befe14a into master Mar 27, 2020
@mzohreva mzohreva deleted the mz/fix_exit_io_block branch March 27, 2020 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants