mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
The SnpCpuidInfo allocation and guest_memory.read() call in the isolated page import loop are only needed for KVM's CPUID page retry logic. However, when building with both 'mshv' and 'kvm' features, #[cfg(feature = "kvm")] alone is insufficient as a guard because both features compile into the same binary. Without a runtime hypervisor type check, this code executes on MSHV as well, reading guest memory at arbitrary GPAs that may not be valid in the MSHV memory layout. This can cause undefined behavior or crashes during IGVM loading. Add #[cfg(feature = "kvm")] to the variable declarations and wrap the guest_memory.read() call in a runtime check for HypervisorType::Kvm to ensure it only executes on KVM. Assisted-by: Claude:Opus-4.6 Signed-off-by: Muminul Islam <muislam@microsoft.com>