Repository navigation
Description
On a KVM SNP partition, reading the activity of a vCPU whose MP state is KVM_MP_STATE_AP_RESET_HOLD (9) panics the VM worker with "unrecognized mp state 9", in debug and release builds. A VP save and an inspect of the VP (vp/N/vtl0) both read the activity. The guest puts its AP in this state on its own, through the GHCB AP reset-hold request, so it only has to be waiting there when the host saves or inspects the VP. NVX's microVM runs without isolation and is not affected.
Reproduction
Bind an AP of a KVM partition, set its MP state to KVM_MP_STATE_AP_RESET_HOLD with KVM_SET_MP_STATE (which KVM accepts with an in-kernel LAPIC, so no SNP guest is needed), and call access_state(Vtl0).activity(). Expected: an error. Actual: the panic "unrecognized mp state 9", in debug and release builds. The patch's test activity_of_an_ap_in_reset_hold_is_an_error does this; it needs /dev/kvm, so it is #[ignore]d.
Cause
KvmVpStateAccess::activity (vmm_core/virt_kvm/src/arch/x86_64/vp_state.rs) panics on any MP state it does not map, although it returns a Result:
// vmm_core/virt_kvm/src/arch/x86_64/vp_state.rs
fn activity(&mut self) -> Result<vp::Activity, Self::Error> {
let mp_state = match self.kvm().get_mp_state()? {
kvm::KVM_MP_STATE_RUNNABLE => vp::MpState::Running,
kvm::KVM_MP_STATE_UNINITIALIZED => vp::MpState::WaitForSipi, // TODO: add a state for this
kvm::KVM_MP_STATE_INIT_RECEIVED => vp::MpState::WaitForSipi,
kvm::KVM_MP_STATE_HALTED => vp::MpState::Halted,
kvm::KVM_MP_STATE_SIPI_RECEIVED => todo!("handle intermediate sipi states"),
state => {
panic!("unrecognized mp state {}", state);
}
};The todo!() arm is unreachable, since KVM no longer reports SIPI_RECEIVED, but AP_RESET_HOLD it does report.
Fix
fix.patch moves the mapping into activity_mp_state, which returns the new KvmError::UnrecognizedMpState(state) for any state it does not map, AP_RESET_HOLD and SIPI_RECEIVED included. The four existing mappings are unchanged. A save of such an AP then fails with that error rather than panicking, and an inspect shows no activity for it. Such an AP is still not saveable, because the saved state has no representation for reset hold. The native test unsupported_activity_mp_states_return_errors covers the mapping. The patch adds pal_async as a dev-dependency of virt_kvm (with its Cargo.lock line) for the KVM 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.patch