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

lib: add better management of Hyper-V overlay pages #851

Merged
merged 15 commits into from
Feb 14, 2025

Conversation

gjcolombo
Copy link
Contributor

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.rs for 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).

@gjcolombo
Copy link
Contributor Author

Thanks for the review, @hawkw! I think this is ready for another lap at your convenience. I'll work on rebasing #853 onto this.

@gjcolombo gjcolombo requested a review from hawkw February 10, 2025 23:15
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

The new changes look good to me! Perhaps worth getting a second opinion?

@gjcolombo
Copy link
Contributor Author

I found a bug during ad hoc testing: HyperV::reset creates a new overlay manager, but doesn't attach its (new) memory accessor to the accessor hierarchy. It needs to do that (and reset needs to be careful to drop things in the correct order; it does so today, but only by the grace of the drop ordering rules for structs...).

I'm going to merge #849 and rebase this branch before pushing a fix and working on other PR feedback.

Base automatically changed from gjcolombo/hyperv to master February 11, 2025 22:37
@gjcolombo gjcolombo force-pushed the gjcolombo/overlay-pages-part-1 branch from 07e3c11 to 161729b Compare February 11, 2025 22:54
@gjcolombo
Copy link
Contributor Author

I found a bug during ad hoc testing

a3186ef should fix this.

@gjcolombo gjcolombo merged commit c849bab into master Feb 14, 2025
11 checks passed
@gjcolombo gjcolombo deleted the gjcolombo/overlay-pages-part-1 branch February 14, 2025 18:39
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.

2 participants