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

Update wasmi host executor #3017

Open
3 of 4 tasks
ark0f opened this issue Aug 2, 2023 · 2 comments · May be fixed by #4282
Open
3 of 4 tasks

Update wasmi host executor #3017

ark0f opened this issue Aug 2, 2023 · 2 comments · May be fixed by #4282
Labels
C2-refactoring Refactoring proposal

Comments

@ark0f
Copy link
Member

ark0f commented Aug 2, 2023

File Location(s)

sandbox/host

Proposal

Update wasmi executor to 0.30.

The main problem is latest versions of main-stream executors (wasmi, wasmer, wasmtime) implement WASM store using only Rust borrow semantics and no synchronization primitives. As a result, we cannot simply clone required structures elsewhere.

It is the problem because we have lazy pages concept that requires access to WASM globals during WASM function invocation, when accessing protected memory pages. Pseudocode:

let store = Store::new(...);
func.call(&mut store, ...);

// inside WASM function call
fn call(...) {
	// ...some WASM instructions

	memory.write 123 at 0xCAFE
	// let's think 0xCAFE address belongs to protected memory page, so:
    // 1. MMU sees protected memory and causes interruption to OS
	// 2. We set signal handler earlier, so OS jumps to `signal_handler()`
	// 3. After handler is done, OS jumps back to `memory.write` and it will be successful now

	// ..execution continues
}

// when interruption occurs, lazy-pages signal handler is in work
fn signal_handler() {
    let store = ???; // how to access mutable reference again, if `func.call` holds it?
	global.set(&mut store, 333);
    memory.unprotect 0xCAFE // unprotect page which address belongs to
}

Possible solutions:

@grishasobol
Copy link
Member

My thoughts about why we can update to wasmer 4 #3917.

@grishasobol
Copy link
Member

Possible safe lazy-pages implementation #3920

@ByteNacked ByteNacked linked a pull request Oct 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C2-refactoring Refactoring proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants