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: emulate Hyper-V enlightenment stack #849

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

gjcolombo
Copy link
Contributor

Add the beginnings of a Hyper-V enlightenment stack to complement the bhyve enlightenment stack. This change aims to provide the absolute minimum functionality needed for a hypervisor to claim to expose a Hyper-V-compatible guest-hypervisor interface. These minimum requirements are described in the doc comments throughout this change.

Add PHD tests that boot VMs with the Hyper-V enlightenment stack enabled and (if the guest supports it) that try to query the hypervisor interface from within the guest.

Add a simple propolis-cli option to enable the Hyper-V stack. Once the stack has some actual features, this may be better expressed as a table in the propolis-config-toml crate, but this gives users a quick and easy way to enable the new interface.

Tests: PHD with Debian 11, Ubuntu 22.04, Alpine, and Windows Server 2022 guests; repeated the Debian 11 and WS2022 runs with the Hyper-V enlightenment stack enabled by default for all PHD VMs. Tested with an ad hoc Debian 11 VM, verifying that it detected the Hyper-V hypervisor, that the guest wrote appropriate values to the Hyper-V MSRs, and (through mdb-bhyve) that the correct instruction sequence appears on the guest's hypercall page.

Related to #328.

lib/propolis/src/enlightenment/hyperv/mod.rs Outdated Show resolved Hide resolved
lib/propolis/src/vmm/mem.rs Outdated Show resolved Hide resolved
@gjcolombo gjcolombo marked this pull request as ready for review February 5, 2025 17:02
@hawkw hawkw self-requested a review February 5, 2025 18:19
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.

Overall, this looks great to me, and I didn't note any blocking concerns. Left a bunch of minor suggestions, hope they're helpful

lib/propolis/src/enlightenment/hyperv/bits.rs Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/bits.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/hypercall.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Show resolved Hide resolved
phd-tests/tests/src/hyperv.rs Show resolved Hide resolved
phd-tests/tests/src/hyperv.rs Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/bits.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/bits.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/bits.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/hypercall.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/hypercall.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/hypercall.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/mod.rs Outdated Show resolved Hide resolved
lib/propolis/src/enlightenment/hyperv/hypercall.rs Outdated Show resolved Hide resolved
@hawkw
Copy link
Member

hawkw commented Feb 6, 2025

Thanks for addressing the review feedback, the new changes look good!

const LOCKED_MASK: u64 = 1 << LOCKED_BIT;
const ENABLED_BIT: u64 = 0;
const ENABLED_MASK: u64 = 1 << ENABLED_BIT;
const GPA_MASK: u64 = !((1 << PAGE_SHIFT) - 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could use PAGE_MASK here, or in place of GPA_MASK all together.

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.

4 participants