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

Support mprotect in wasi-emulated-mman #497

Closed
whitequark opened this issue May 19, 2024 · 6 comments
Closed

Support mprotect in wasi-emulated-mman #497

whitequark opened this issue May 19, 2024 · 6 comments

Comments

@whitequark
Copy link
Contributor

Is there any interest in supporting mprotect in the emulation library? The main utility would be to compile programming language runtimes that link, but not execute at runtime, a JIT (what prompted me to write the issue was LLVM, similar to #447).

I think the semantics should be that mapping in-bounds memory is only possible as PROT_READ|PROT_WRITE, and out-of-bounds memory as PROT_NONE.

@sunfishcode
Copy link
Member

That sounds reasonable to me. I'm not sure about the PROT_NONE case because memory.grow can cause previously out-of-bounds memory to become in-bounds, but allowing PROT_READ|PROT_WRITE for in-bounds memory sounds fine.

@whitequark
Copy link
Contributor Author

whitequark commented May 20, 2024

How do you find out the current memory size from C?

@sunfishcode
Copy link
Member

__builtin_wasm_memory_size(0) returns the number of 64KiB pages currently allocated (in memory 0).

@whitequark
Copy link
Contributor Author

Thanks. Do you think mprotect should require the address to be page-aligned, or should it accept just any? I'm leaning towards the latter since it's a stub anyways.

@whitequark
Copy link
Contributor Author

It looks like POSIX requires the address to be page-aligned so I chose to do that.

@sunfishcode
Copy link
Member

This is now implemented in #500.

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

No branches or pull requests

2 participants