Repository navigation
Description
On a host whose KVM supports SMM (Linux built with CONFIG_KVM_SMM, and on Intel with unrestricted guest), a guest can kill the whole VM by sending itself an SMI: KVM takes the vCPU into SMM and switches it to address space 1 to save its state at SMBASE, OpenVMM maps RAM only into address space 0, the save fails, and KVM marks the VM dead, after which every vCPU ioctl on the partition returns EIO. No device is needed: a write to the x2APIC ICR MSR with SMI delivery and the self shorthand does it, as does any IOAPIC redirection or MSI with SMI delivery.
Reproduction
The patch's test a_guest_smi_enters_smm_instead_of_killing_the_vm (virt_kvm, arch::x86_64::smm_ram_tests) reproduces it on real KVM: it maps RAM into the partition through PartitionMemoryMap, delivers an SMI to the VP as an MSI with DeliveryMode::SMI, and runs the VP. Without the fix the first KVM_RUN returns EIO and the VM is dead; with it the VP enters SMM, executing the stub at SMBASE + 0x8000, and the VM stays alive. The test needs /dev/kvm and is #[ignore]d; it was run for this report.
Cause
KvmPartitionInner::map_region (vmm_core/virt_kvm/src/memory.rs) passes its dense slot index to KVM as the slot id, and KVM takes the address space from the slot id's upper 16 bits, so every RAM slot lands in address space 0 and address space 1, the address space a vCPU uses while in SMM, stays empty:
// vmm_core/virt_kvm/src/memory.rs
// ...
self.kvm.set_user_memory_region(
slot_to_use as u32,
data,
size,
addr,
readonly,
)?On the SMI, KVM enters SMM and switches the vCPU to address space 1 before writing the 512-byte state-save area at SMBASE + 0xfe00 (the default SMBASE, 0x30000, is in RAM). The write finds no memslot, fails, and KVM marks the VM dead; every later vCPU ioctl returns EIO.
Fix
fix.patch also maps every userspace-backed RAM slot into address space 1, setting the address-space bits of the slot id, on hosts that report KVM_CAP_X86_SMM and for partitions without private memory (KVM does not support SMM with private memory, and rejects address space 1 slots there). The mirror is cleared when the slot is cleared or reused. It mirrors all of RAM rather than a fixed 64 KiB SMRAM window, since a guest SMM handler can relocate SMBASE, and KVM gives userspace no way to refuse SMIs. It adds the test above.
Related: #1158.
Activity
tangruize commentedon Nov 9, 2026
Proposed patch
Patch against OpenVMM 881619911d1a6ec2fec7bebdad7cfe69d09018f1. Save the contents below as
fix.patchand rungit apply fix.patch.fix.patch