Skip to content

vmotherboard: add chipset, base chipset, and PCIe unit tests - #5243

Merged
Sunil Muthuswamy (sunilmut) merged 2 commits into
microsoft:mainfrom
sunilmut:user/sunilmut/vmotherboard-unit-tests
Nov 26, 2026
Merged

Sunil Muthuswamy (sunilmut) merged 2 commits into
microsoft:mainfrom
sunilmut:user/sunilmut/vmotherboard-unit-tests

Conversation

@sunilmut

@sunilmut Sunil Muthuswamy (sunilmut) commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Before this change, vmotherboard had no unit tests for how the chipset routes
guest I/O to devices, how the base chipset wires up its devices, or the errors
its builder reports. This PR adds 24 tests. Each one builds a real chipset with
a small test device and checks only what callers can see. Tests prefixed with
gen1_ cover devices used only by Gen1 VMs.

Test Checks
accesses_reach_owning_device Only owner gets I/O
unclaimed_accesses_read_all_ones Unclaimed reads all 1s
device_errors_read_all_ones Errors read all 1s
deferred_accesses_complete_with_device_result Deferred I/O completes
fallback_device_receives_only_unclaimed_mmio Fallback gets MMIO
overlapping_static_ranges_fail_build Overlaps fail build
pci_device_wiring_errors_are_reported Bad PCI wiring fails
runtime_region_mapping_moves_dispatch Remap moves I/O
pic_and_eoi_route_to_registered_handlers PIC/EOI reach handlers
generic_pci_bus_routes_config_space Config space routed
gen1_piix4_pci_bus_resets_and_hosts_legacy_pci_devices PIIX4 bus works
base_chipset_forwards_unclaimed_mmio_to_fallback Fallback gets MMIO
generic_cmos_rtc_exposes_cmos_ram CMOS RAM works
gen1_piix4_cmos_rtc_exposes_cmos_ram CMOS RAM works
gen1_isa_dma_controller_is_resolved_and_programmable DMA programmable
gen1_floppy_controllers_require_isa_dma Floppy needs DMA
irq_lines_reach_the_pic_and_external_targets IRQ to CPU vector
pcie_config_space_reaches_root_complex_devices ECAM reaches devices
pcie_placement_errors_fail_build Misplaced fails
integrated_endpoint_at_nonzero_device_is_reachable Ignored: known bug
dynamic_device_is_reachable_until_removed Removal unmaps
vm_state_transitions_reach_devices Lifecycle reaches all
inspect_controls_debug_breaks_and_lists_ranges Break filters match
device_builder_variants Builder variants work

This PR changes tests only. Coverage of the crate's production code rises from
32.5% to 92.4% (540 to 1,535 of 1,661 lines).

@sunilmut
Sunil Muthuswamy (sunilmut) requested a review from a team as a code owner November 23, 2026 07:05
Copilot AI balanced review requested due to automatic review settings November 23, 2026 07:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The test calls unmap() after the mapping conflict has already left the region unmapped, so its assertions do not verify removal of a live mapping.

1 open issue
What changed in this PR

Adds nine unit tests for vmotherboard’s guest I/O dispatch and chipset builder validation, using a shared fixture and configurable test device. Production code is unchanged.

Changes:

  • Tests MMIO and port I/O routing, unclaimed accesses, device errors, deferred completion, and fallback behavior.
  • Exercises runtime MMIO mapping and static range conflict validation.
  • Checks PCI wiring errors, interrupt dispatch, and duplicate handler rejection.
File Description
vmm_core/​vmotherboard/​src/​chipset/​mod.rs Adds test helpers and nine tests covering chipset dispatch and builder validation.

Review effort: Balanced

Before this change, vmotherboard had no unit tests for how the chipset routes
guest I/O to devices, how the base chipset wires up its devices, or the errors
its builder reports. This PR adds 24 tests. Each one builds a real chipset with
a small test device and checks only what callers can see. Tests prefixed with
gen1_ cover devices used only by Gen1 VMs.

| Test | Checks |
|---|---|
| accesses_reach_owning_device | Only owner gets I/O |
| unclaimed_accesses_read_all_ones | Unclaimed reads all 1s |
| device_errors_read_all_ones | Errors read all 1s |
| deferred_accesses_complete_with_device_result | Deferred I/O completes |
| fallback_device_receives_only_unclaimed_mmio | Fallback gets MMIO |
| overlapping_static_ranges_fail_build | Overlaps fail build |
| pci_device_wiring_errors_are_reported | Bad PCI wiring fails |
| runtime_region_mapping_moves_dispatch | Remap moves I/O |
| pic_and_eoi_route_to_registered_handlers | PIC/EOI reach handlers |
| generic_pci_bus_routes_config_space | Config space routed |
| gen1_piix4_pci_bus_resets_and_hosts_legacy_pci_devices | PIIX4 bus works |
| base_chipset_forwards_unclaimed_mmio_to_fallback | Fallback gets MMIO |
| generic_cmos_rtc_exposes_cmos_ram | CMOS RAM works |
| gen1_piix4_cmos_rtc_exposes_cmos_ram | CMOS RAM works |
| gen1_isa_dma_controller_is_resolved_and_programmable | DMA programmable |
| gen1_floppy_controllers_require_isa_dma | Floppy needs DMA |
| irq_lines_reach_the_pic_and_external_targets | IRQ to CPU vector |
| pcie_config_space_reaches_root_complex_devices | ECAM reaches devices |
| pcie_placement_errors_fail_build | Misplaced fails |
| integrated_endpoint_at_nonzero_device_is_reachable | Ignored: known bug |
| dynamic_device_is_reachable_until_removed | Removal unmaps |
| vm_state_transitions_reach_devices | Lifecycle reaches all |
| inspect_controls_debug_breaks_and_lists_ranges | Break filters match |
| device_builder_variants | Builder variants work |

This PR changes tests only. Coverage of the crate's production code rises from
32.5% to 92.4% (540 to 1,535 of 1,661 lines).
@sunilmut
Sunil Muthuswamy (sunilmut) force-pushed the user/sunilmut/vmotherboard-unit-tests branch from 4d09a44 to 0aa13d1 Compare November 23, 2026 23:32
Copilot AI balanced review requested due to automatic review settings November 23, 2026 23:32
@sunilmut Sunil Muthuswamy (sunilmut) changed the title vmotherboard: add chipset dispatch and builder unit tests vmotherboard: add chipset, base chipset, and PCIe unit tests Nov 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests omit DMA prerequisite coverage when only some floppy features are enabled and fail to verify that a conflicting map revokes the previous mapping before unmapping.

3 open issues

Review effort: Balanced

Run floppy DMA prerequisite checks for each enabled controller, including
single-feature and two-feature builds.

Check that a conflicting MMIO map revokes the old mapping immediately,
then establish and verify a live mapping before testing explicit unmap.

Validation on Linux x64: package check, clippy, docs, and formatting passed.
Default tests: 32 passed, 1 ignored. With all floppy features: 33 passed,
1 ignored. Focused DMA tests passed in all six partial-feature combinations.
Copilot AI balanced review requested due to automatic review settings November 25, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because the lifecycle test would pass even if device restoration were skipped, leaving restore-callback delivery unverified.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@sunilmut
Sunil Muthuswamy (sunilmut) merged commit 6d4b917 into microsoft:main Nov 26, 2026
108 of 109 checks passed
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.

5 participants