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

Hugepage support #92

Open
abrestic-rivos opened this issue Sep 8, 2022 · 2 comments · Fixed by #154
Open

Hugepage support #92

abrestic-rivos opened this issue Sep 8, 2022 · 2 comments · Fixed by #154
Assignees

Comments

@abrestic-rivos
Copy link
Collaborator

The TEE APIs have placeholder support for hugepages, but our current implementation rejects anything other than 4kB pages. There's a number of places internally (page table manipulation, page tracking) that will need to be updated to take hugepages into account, and we'll likely want an interface to promote/demote hugepage mappings in a TVM.

@stillson
Copy link
Contributor

I am working on this.

@stillson stillson linked a pull request Nov 8, 2022 that will close this issue
@abrestic-rivos
Copy link
Collaborator Author

Re-opening this since it's far from done :)

@stillson is still working on an orthogonal piece to this, which is to map Salus itself with hugepages. That should speed up our boot times.

For hugepage usage in TVMs, I'd propose the following new TH-ABI calls (largely inspired from @rsahita's draft spec):

  • tvm_block_range(guest_addr, len): Invalidates the pages in the range guest_addr to guest_addr + len, marking them as "blocked" at the current TLB version.
  • tvm_unblock_range(guest_addr, len): Marks the invalidated and blocked pages in the range guest_addr to guest_addr + len as valid.
  • tvm_promote_page(guest_addr, page_size): Promotes the 512 physically-contiguous mappings of size page_size - 1 at guest_addr to a single mapping of page_size. Both guest_addr and the mapped physical address must be aligned to page_size. The mappings must have been blocked at a TLB version older than the current TLB version.
  • tvm_demote_page(guest_addr, page_size): Demotes the mapping of size page_size + 1 at guest_addr to 512 mappings of size page_size. The mapping must have been blocked at a TLB version older than the current TLB version.

The implementation of the existing tvm_add_zero_pages(), tvm_add_shared_pages(), etc APIs would be updated to respect the page_size argument.

Note that the host VM will continue to always be mapped with 4kB pages so as to avoid having to transparently break up hugepage mappings within Salus. This also is consistent with MTT-based deployment modes where the host can operate on physical memory at a 4kB granularity. We do however need to make sure the host VM is mapped in 2MB-aligned chunks so that we can exercise hugepages; we currently only guarantee 16kB.

The flow for promotion/demotion would look like this:

  • tvm_block_range(addr, len)
  • tvm_initiate_fence() + IPIs
  • tvm_{promote,demote}_page(addr, page_size)

Some points for discussion:

  • Should unblock be implicit in promote/demote, or should the host be required to make an explicit tvm_unblock_range() call? I expect implicit unblock is what we'd want in the common case, but in the case we're demoting to support a share/unshare operation, we do not want an implicit unblock.
  • Should we allow batched promote/demote, rather than just one hugepage at a time? I don't think THP would be able to easily take advantage of this as its currently written, so I'm proposing just a single page for now.
  • On a promote, should we allow the host to reclaim the freed page-table page, or should it go back into the TVM's page-table page pool?

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 a pull request may close this issue.

3 participants