Repository navigation
Conversation
On WHP hosts with TscAdjustSupport, restore does not rewind the guest TSC. Writing TSC shifts TSC_ADJUST by the same amount, and writing TSC_ADJUST shifts TSC back, so restoring both keeps the time since the snapshot. Clear TscAdjustSupport in the partition's processor feature banks, as the MSHV driver does. The probe then drops TSC_ADJUST from the reset set, and restore_rewinds_tsc runs on WHP too. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Failures in configure_partition can return before WhpVm owns the partition, bypassing cleanup and leaking partition handles on repeated creation attempts.
1 open issue
What changed in this PR
This PR gives MSHV and WHP a shared CPU feature policy, addressing differing backend defaults. It also isolates WHP guest speculation and enables TSC rewind coverage on WHP.
Changes:
- Apply shared processor and XSAVE feature masks while retaining AVX through AVX-512.
- Give WHP guests a separate speculation domain.
- Add feature-exposure tests and document the guest compatibility changes.
| File | Description |
|---|---|
src/tests/rust_guests/simpleguest/src/main.rs |
Adds a guest CPUID query for tests. |
src/hyperlight_host/src/sandbox/initialized.rs |
Tests feature exposure and TSC rewind on WHP. |
src/hyperlight_host/src/hypervisor/virtual_machine/whp/x86_64.rs |
Configures feature masks and a separate security domain. |
src/hyperlight_host/src/hypervisor/virtual_machine/partition_features.rs |
Defines shared processor and XSAVE feature masks. |
src/hyperlight_host/src/hypervisor/virtual_machine/mshv/x86_64.rs |
Applies shared masks during partition creation. |
src/hyperlight_host/src/hypervisor/virtual_machine/mod.rs |
Registers the shared feature module. |
src/hyperlight_host/src/hypervisor/regs/x86_64/msrs.rs |
Removes a TSC_ADJUST comment. No functional change. |
docs/README.md |
Links CPU feature and MSR documentation. |
docs/msr.md |
Aligns MSR documentation with the feature policy. |
docs/guest-cpu.md |
Documents exposed features and exclusions. |
CHANGELOG.md |
Records feature restrictions, speculation isolation, and the TSC fix. |
Review effort: Balanced
| }, | ||
| )?; | ||
|
|
||
| Self::configure_partition(p)?; |
There was a problem hiding this comment.
The leak is older than this PR. On main, every failure after WHvCreatePartition in WhpVm::new leaks the handle. We should fix it in a separate PR.
0b47648 to
cc462d0
Compare
Benchmark ResultsMeasured commit: kvm / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
cc462d0 to
f2e1995
Compare

Draft until #2022 is merged.
MSHV and WHP use different default CPU features. Both expose features with guest state, such as speculation control, TSX, CET, and
TSC_ADJUST. WHP guests also share the host process's speculation domain.This sets one feature list for both backends in
partition_features.rsand gives WHP guests their own speculation domain. The list keeps AVX through AVX-512. Hyperlight does not support AVX, but a guest can enable it. Restore resets XCR0 to x87 only.Breaking: guests that use a removed feature fault on MSHV and WHP. See
docs/guest-cpu.mdfor the list.Fixes #1685