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

feat: Implement Memory Map Primitive #144

Open
Tracked by #142
JonasKruckenberg opened this issue Nov 12, 2024 · 0 comments
Open
Tracked by #142

feat: Implement Memory Map Primitive #144

JonasKruckenberg opened this issue Nov 12, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@JonasKruckenberg
Copy link
Owner

JonasKruckenberg commented Nov 12, 2024

Implement a RAII memory mapping primitive that allows us to manage virtual memory associated with WASM instances. In essence this should behave like a wrapper around mmap_anonymous, so things the type must support:

  • construction from a specific virtual address range
    • Should zero memory range
    • Like mmap(2) with MAP_FIXED_NOREPLACE | MAP_ANONYMOUS where the ptr and len arg correspond to the range.
    • Fail if address range is misaligned
    • Fail if range size is not multiple of page size
    • Fail if address range is already reserved
    • Fail if out-of-memory
  • construction from an allocator chosen address range
    • Should zero memory range
    • Like mmap(2) with MAP_FIXED_NOREPLACE | MAP_ANONYMOUS where the ptr is NULL and len is the range length.
    • should choose an arbitrary free range
    • should use randomization if ASLR is enabled
    • Fail if range size is not multiple of page size
    • Fail if out-of-memory
  • ability to make subregion read-only
    • Fail if subregion is not aligned
    • Fail if subregion size is not multiple of page size
  • ability to make subregion execute-read
    • Fail if subregion is not aligned
    • Fail if subregion size is not multiple of page size
  • ability to make subregion read-write
    • Fail if subregion is not aligned
    • Fail if subregion size is not multiple of page size
  • should unmap region on Drop
  • OPTIONAL fill region with guard pattern in debug mode?

And of course the type should expose as_ptr, as_slice etc. accessor methods so we can actually get to the underlying memory.

This should be relatively straightforward to implement since all of the required functionality already exists in the kmm crate. This is issue is just about creating a friendly and harder to abuse wrapper!

@JonasKruckenberg JonasKruckenberg changed the title Implement Memory Map Primitive feat: Implement Memory Map Primitive Nov 12, 2024
@JonasKruckenberg JonasKruckenberg added the good first issue Good for newcomers label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant