You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
virt: add unit tests for synic dispatch, VP state, and interrupts - #5242
Add behavior-focused tests for widely used, previously untested logic in the virt crate. Two tests expose existing bugs and are marked #[ignore] with notes explaining them; they will be re-enabled with the fixes.
Test changes:
Synic hypercall dispatch: connection-ID and port-type checks, minimum VTL, busy ports, handle ownership, teardown, and fast-path cleanup.
VP register state: get/set round trips and register-name alignment.
XSAVE: standard/compact conversion, disabled features, and normalization across hypervisors.
CPUID override merging, DR7 breakpoint encoding, and MSI/IRQ routing.
Ignored (known bugs): DR7 write breakpoints use the I/O encoding; SYSENTER EIP/ESP register names are swapped.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The test’s zero-filled destination masks unintended writes to disabled feature regions; nonzero sentinels are needed to verify those regions remain untouched.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Test that disabled feature regions remain untouched
vmm_core/virt/src/x86/vp.rs:2564
The zero-filled destination does not verify that disabled feature regions are left untouched: if write_standard loses its xstate_bv guard and copies every compact component, it overwrites these regions with zeros and all assertions still pass. Initialize the destination with a nonzero sentinel and assert that the disabled YMM and A regions retain it, so this test detects unintended writes as well as stale-state copies.
The reason will be displayed to describe this comment to others. Learn more.
there are two bugs that this test catches, that will be fixed in following PRs. I wanted to keep this PR as test only so that its easy to review. Please see the description for details.
Build on microsoft#5242 with tests for CPUID capabilities, reset state,
Intel/AMD topology, partition state, APICs, MSI routing, ARM64 state,
isolation, and VP stop/yield behavior. Tests use fake CPUID tables,
fake VPs, and recording interrupt controllers without requiring a VM.
Across the combined tests, four existing product bugs are exposed.
Their tests are currently marked #[ignore] because they assert correct
behavior that the existing implementation does not satisfy. The DR7
and SYSENTER bugs were exposed in microsoft#5242; this extension also exposes
the MSI retarget and Intel cache-sharing bugs.
| Ignored test | Bug |
|---|---|
| failed_retarget_leaves_interrupt_unchanged | 1 |
| hardware_breakpoint_dr7_bits_match_architectural_encoding | 2 |
| intel_cache_sharing_is_reported_per_cache_level | 3 |
| virtual_msrs_report_fields_under_their_names | 4 |
1. A failed MSI retarget changes the existing interrupt vector.
2. DR7 write breakpoints use the I/O encoding instead of data-write encoding.
3. Cache sharing uses the wrong source for the cache level and omits subleaf
indices.
4. SYSENTER EIP/ESP names are swapped relative to their fields; the fix
requires saved-state compatibility handling.
Fixes are incoming in separate PRs and will re-enable these tests.
Keep this PR unit-test-only so the tests and product fixes can be
reviewed independently. No production behavior is changed here.
Code coverage (virt production lines, Linux x64):
| Scope | Before | After |
|--------------------------|--------|-------|
| This extension | 40.7% | 95.3% |
| Combined with microsoft#5242 | 7.3% | 95.3% |
Build on #5242 with tests for CPUID capabilities, reset state, Intel/AMD
topology, partition state, APICs, MSI routing, ARM64 state, isolation,
and
VP stop/yield behavior. Tests use fake CPUID tables, fake VPs, and
recording
interrupt controllers without requiring a VM.
### Four Existing Product Bugs
Across the combined tests, **four existing product bugs are exposed**.
Their tests are currently marked `#[ignore]` because they assert correct
behavior that the existing implementation does not satisfy.
The DR7 and SYSENTER bugs were exposed in #5242; this extension also
exposes the MSI retarget and Intel cache-sharing bugs.
| Ignored Test | Bug |
|---|---|
| `failed_retarget_leaves_interrupt_unchanged` | 1 |
| `hardware_breakpoint_dr7_bits_match_architectural_encoding` | 2 |
| `intel_cache_sharing_is_reported_per_cache_level` | 3 |
| `virtual_msrs_report_fields_under_their_names` | 4 |
1. A failed MSI retarget changes the existing interrupt vector.
2. DR7 write breakpoints use the I/O encoding instead of the data-write
encoding.
3. Cache sharing uses the wrong source for the cache level and omits
subleaf indices.
4. SYSENTER EIP/ESP names are swapped relative to their fields. The fix
requires saved-state compatibility handling.
**Fixes are incoming in separate PRs and will re-enable these tests.**
This PR intentionally remains unit-test-only so the tests and product
fixes can be reviewed independently. No production behavior is changed
here.
### Code Coverage
Previously measured `virt` production-line coverage on Linux x64:
| Scope | Before | After | Increase |
|---|---:|---:|---:|
| This extension | 40.7% | 95.3% | +54.6 percentage points |
| Combined with #5242 | 7.3% | 95.3% | +88.0 percentage points |
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
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
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 behavior-focused tests for widely used, previously untested logic in the virt crate. Two tests expose existing bugs and are marked #[ignore] with notes explaining them; they will be re-enabled with the fixes.
Test changes:
Code coverage summary:
virt crate:
Total: 7.3% → 40.7% (+33.4 points, +861 lines)
x86/vp.rssynic.rsirqcon.rsx86/mod.rscpuid.rsvirt(unchanged)#5274 already brings in these changes