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

Track regions of the TVM guest physical address space #4

Merged
merged 5 commits into from
Jun 29, 2022

Conversation

abrestic-rivos
Copy link
Collaborator

Introduce VmRegionList which tracks the distinct regions in a TVM's guest physical address space, similar in principle to KVM memslots. This will be used in follow-on patches to support demand faulting of zero pages and emulated MMIO (and can also be used to support shared memory).

Patches 1 and 2 are minor PageVec fixes, patch 3 fixes an error path when mapping pages, patch 4 introduces the VM region tracking, and patch 5 removes hooks for handling demand faults when copying to/from the guest address space.

Just like std::vec::Vec::insert.

Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
So that we can get a mutable iterator to the underlying vector. Also use
as{,_mut}_slice() to avoid the unsafe block.

Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
copy_and_add_data_pages_builder() intializes and maps pages one-by-one
so if copy_from_guest() fails in the middle of the range, we end up with
a partially-mapped range of pages. Fix this by intializing the entire
range first before mapping.

Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
Copy link
Collaborator

@dgreid dgreid left a comment

Choose a reason for hiding this comment

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

overall looks good, just a few questions.

Thanks!

src/vm_pages.rs Outdated Show resolved Hide resolved
src/vm_pages.rs Show resolved Hide resolved
src/vm_pages.rs Outdated Show resolved Hide resolved
src/vm_pages.rs Outdated Show resolved Hide resolved
src/vm_pages.rs Show resolved Hide resolved
In preparation for demand-filled pages, shared memory, and emulated MMIO
introduce VmRegionList which keeps track of the regions in the guest
physical address space. For now the only type of region we have is the
memory that's fully populated prior to VM finalization. The region list
is backed by an extra page that the host must donate during TvmCreate.

Note that this could also be accomplished in the page table itself by
flagging PTEs. That wastes much more memory however, in particular for
regions which will never be populated (MMIO) or will likely only be
sparsely populated (shared memory).

Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
There's no demand faulting currently and the direction we've decided
to take going forward (for both shared memory and zero-fill-on-demand
pages) is to forward the page fault to the host so that it can handle
it by inserting a page.

Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
@dgreid
Copy link
Collaborator

dgreid commented Jun 29, 2022

LGTM, thanks!

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.

3 participants