lib: add better management of Hyper-V overlay pages#851
Merged
Conversation
gjcolombo
commented
Feb 7, 2025
gjcolombo
commented
Feb 10, 2025
hawkw
reviewed
Feb 10, 2025
hawkw
reviewed
Feb 10, 2025
Contributor
Author
hawkw
approved these changes
Feb 11, 2025
Member
hawkw
left a comment
There was a problem hiding this comment.
The new changes look good to me! Perhaps worth getting a second opinion?
Contributor
Author
|
I found a bug during ad hoc testing: I'm going to merge #849 and rebase this branch before pushing a fix and working on other PR feedback. |
07e3c11 to
161729b
Compare
Contributor
Author
a3186ef should fix this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add to the Hyper-V module some supporting types to support overlay pages. A Hyper-V overlay page is a sort of auxiliary page of guest memory that "covers up" or temporarily "replaces" a specific physical page in the guest's physical memory, such that accesses to the overlaid GPA end up accessing the overlay instead. See the doc comments throughout
overlay.rsfor many more details.To avoid creating a 2,500-line patch, this PR omits direct migration of overlay manager state. Instead, the target Hyper-V stack re-creates all overlays during import based on the contents of its imported MSRs. This is somewhat dangerous: a single guest page is allowed to have multiple overlays, and there's nothing in this change that guarantees that the source and target will agree on which overlay is active at migration time. The danger is mitigated here by having only one overlay page in the whole VM (the hypercall page), but this will need to be addressed in a follow-up PR before adding any more overlay kinds (like a reference TSC page).
Tests: cargo tests, including new unit tests of the overlay manager; PHD runs with Alpine and Debian 11 guests; manually migrated a VM and made sure the hypercall page was preserved properly over migration.
Related to #850 (but doesn't close it since migration work is still pending).