Skip to content

Fix Windows build with --no-default-features #712

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danbugs
Copy link
Contributor

@danbugs danbugs commented Jul 11, 2025

Fixes #685 and updates CI to ensure Windows builds successfully without default features.


Btw, to validate this fix, I tested running Nanvix (which uses --no-default-features) on Windows as a guest. This revealed that additional register setup was needed in hyperv_windows.rs:

  • Mirror the CS register setup used with default features, except without the L bit
  • Explicitly set the Limit parameter for CS to 0xFFFF (required when paging isn't initialized)

These changes ensure Windows Hyper-V properly initializes guest VMs that don't use the init-paging feature.

ludfjig
ludfjig previously approved these changes Jul 11, 2025
Copy link
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

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

Looks good! I think we should strive to set the same registers on all hypervisors, so we don't rely on any inherent defaults of a particular hv. Thoughts?

@danbugs
Copy link
Contributor Author

danbugs commented Jul 11, 2025

Looks good! I think we should strive to set the same registers on all hypervisors, so we don't rely on any inherent defaults of a particular hv. Thoughts?

Probably a good idea—we should also avoid relying on Default and be a little more explicit. For example, on KVM, the default CS register (excluding base & selector fields) looks like this:

CS: limit=0xffff, type=0xa, s=1, dpl=0, p=1, avl=0, l=0, db=0, g=0

This is exactly the setup we needed w/o default-features to run a workload like Nanvix and why it worked from the get go. But, on WHP, Default just zeroes out everything :|

Might be a good work item for #469?

danbugs added 2 commits July 11, 2025 18:20
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs danbugs force-pushed the init-paging-windows-fix branch from 2c28574 to 85e2184 Compare July 11, 2025 18:20
@@ -399,16 +402,22 @@ impl HypervWindowsDriver {
])?;

#[cfg(not(feature = "init-paging"))]
proc.set_registers(&[(
Copy link
Member

Choose a reason for hiding this comment

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

Does this change need to be mirrored on the Linux hypervisor drivers?

{{ if os() == "linux" { "! cargo check -p hyperlight-host --no-default-features 2> /dev/null"} else { "" } }}
# tests compilation with no default features on different platforms
test-compilation-no-default-features target=default-target:
@# Linux should fail without a hypervisor feature (kvm, mshv, or mshv3)
Copy link
Member

Choose a reason for hiding this comment

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

Should we also be checking that compilation with a hypervisor driver but without init-paging succeeds on Linux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bugfix For PRs that fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hyperlight_host doesn't build on Windows without init-paging feature enabled
3 participants