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
openvmm: restoring an injected #BP or #OF on KVM loses it or panics debug #1385
On KVM, restoring a VP saved state whose activity has an injected #BP (vector 3) or #OF (vector 4) as its pending_interruption succeeds, but KVM never reports the exception afterwards. A debug build then panics in restore_all's read-back check ("restore state mismatch"), and a release build restores a VP whose activity reads back without the exception. Only a crafted or corrupted snapshot reaches this: KVM never reports such an exception as injected, so no save holds one.
Reproduction
Take a KVM VP's save_all(), set its activity's pending_interruption to Exception { vector: 3, error_code: None }, and restore_all it. Expected: the restore is refused. Actual: a debug build panics (actual pending_interruption: None, expected Some(Exception { vector: 3, error_code: None })); a release build returns Ok, and activity() then reads back no pending interruption.
Cause
KvmVpStateAccess::set_activity (vmm_core/virt_kvm/src/arch/x86_64/vp_state.rs) passes any injected exception to KVM_SET_VCPU_EVENTS:
KVM accepts vectors 3 and 4, since it refuses only a vector above 31 or NMI's. But it treats them as soft exceptions (kvm_exception_is_soft), and injecting one needs the length of the instruction that raised it, which the ioctl does not carry. So KVM_GET_VCPU_EVENTS never reports them as injected (arch/x86/kvm/x86.c).
Fix
fix.patch adds check_restorable_interruption. set_activity calls it before it changes any state, and it returns KvmError::InvalidState for an injected #BP or #OF, as set_activity already does for a pending ExtINT. Such a restore then fails with restore_all's StateError for the activity; every other activity is unchanged. The unit test restore_of_an_injected_soft_exception_is_refused checks that vectors 3 and 4 are refused and that #GP, a hard interrupt and an NMI are still accepted. The patch has no KVM-backed test.
Activity
tangruize commentedon Nov 8, 2026
Proposed patch
Patch against OpenVMM 3cf58a5234ed824435825c9f87187f5129219724. Save the contents below as
fix.patchand rungit apply fix.patch.fix.patchopenvmm: pin the refusal to restore an injected #BP or #OF