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_support_apic: add local APIC behavior unit tests - #5246
virt_support_apic emulates the local APIC for OpenHCL on SNP/TDX and for
OpenVMM's WHP software APIC, but most of its guest-facing behavior had no unit
tests. This PR adds 20 tests in lib.rs that drive the APIC the way a guest and
VMM do: register access over MMIO and MSRs, MSIs, LINT pulses, and the
delivery, offload, save, and restore APIs. The test client now records wakes,
IO-APIC EOIs, and APIC base updates, and has a settable clock for timer tests.
Coverage areas
Interrupt priority, EOI, and level-triggered EOI forwarding to the IO-APIC.
Software disable, LVT masking, and reserved vectors.
xAPIC and x2APIC IPI routing: physical, flat and cluster logical, broadcast,
shorthands, lowest priority.
INIT, SIPI, NMI, EXTINT, and LINT delivery.
APIC base MSR transitions and MMIO/x2APIC MSR access rules.
Timer one-shot, periodic, divide, and masking.
Save/restore round trip.
Hyper-V APIC MSRs.
APIC offload, lazy EOI, the local fast path, and scan().
Two tests are marked %23[ignore] for bugs found while writing them:
dfr_write_with_unknown_model_does_not_panic: a reserved DFR model panics.
Fixed separately in "virt_support_apic: ignore DFR writes with a reserved
model"; this test can be dropped once that merges.
tpr_write_ignores_reserved_bits: TPR writes pass bits above 7 to CR8.
Adds pal_async as a dev-dependency for the async scan() test.
Coverage of production lines goes from 40% to 98%. Tests only; no production
code changes.
Add behavior tests for interrupt delivery and EOI, IPI routing, APIC base
and register access, the timer, save/restore, Hyper-V MSRs, offload, lazy
EOI, and scan. Two tests are ignored for known bugs (reserved DFR model
panic, unmasked TPR writes).
These unit tests raise virt_support_apic production-code coverage from
40.3% (467 of 1,160 lines) to 98.0% (1,137 of 1,160).
Keep the xAPIC MMIO masking expectation, but require an InvalidAccess
error and unchanged CR8 for an x2APIC TPR write with reserved bits set.
Rename the ignored test and document both existing product bugs.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The save–restore–save test can miss serialization regressions because it does not independently verify restored LDR, DFR, or timer values against their programmed values.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Verify restored LDR, DFR, and timer register values
vmm_core/virt_support_apic/src/lib.rs:3110
The save–restore–save equality can miss serialization regressions: if save() starts writing zero for LDR instead of its programmed value, both saves still match after restore() loads that zero. Only LVT_LINT0 is independently checked here, so losing the programmed LDR, DFR, or timer configuration would pass. Please also read those restored registers through the guest interface and compare them with the values programmed above.
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.
virt_support_apicemulates the local APIC for OpenHCL on SNP/TDX and forOpenVMM's WHP software APIC, but most of its guest-facing behavior had no unit
tests. This PR adds 20 tests in
lib.rsthat drive the APIC the way a guest andVMM do: register access over MMIO and MSRs, MSIs, LINT pulses, and the
delivery, offload, save, and restore APIs. The test client now records wakes,
IO-APIC EOIs, and APIC base updates, and has a settable clock for timer tests.
Coverage areas
shorthands, lowest priority.
scan().Two tests are marked
%23[ignore]for bugs found while writing them:dfr_write_with_unknown_model_does_not_panic: a reserved DFR model panics.Fixed separately in "virt_support_apic: ignore DFR writes with a reserved
model"; this test can be dropped once that merges.
tpr_write_ignores_reserved_bits: TPR writes pass bits above 7 to CR8.Adds
pal_asyncas a dev-dependency for the asyncscan()test.Coverage of production lines goes from 40% to 98%. Tests only; no production
code changes.