mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: gate reserve_bootloader_regions on KVM hypervisor type
The reserve_bootloader_regions() call allocates RAM regions at KVM-specific addresses (0xffc00000 for stage0, 0xfffffffff000 for VMSA) that are only needed by the KVM SEV-SNP boot path. The existing #[cfg(all(feature = "kvm", feature = "sev_snp"))] compile-time guard is insufficient when both 'mshv' and 'kvm' features are enabled in the same binary. The runtime check only verified sev_snp_enabled() but not the hypervisor type, causing these KVM-specific memory regions to be allocated on MSHV. On MSHV, these spurious RAM mappings at high addresses interfere with the hypervisor's address space layout. When the guest kernel subsequently accesses MMIO regions (e.g., IOAPIC at 0xFEC00000), MSHV incorrectly reports HVMSG_UNACCEPTED_GPA instead of routing the access through MMIO emulation, crashing the guest. Add a runtime hypervisor type check to ensure these regions are only reserved when running on KVM. Assisted-by: Claude:Opus-4.6 Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
4608de134f
commit
f6ed896f68
@@ -1547,7 +1547,9 @@ impl Vm {
|
||||
// Only reserve bootloader/VMSA regions for KVM + SEV-SNP; other hypervisors
|
||||
// (e.g. MSHV) handle this through their own import path.
|
||||
#[cfg(all(feature = "kvm", feature = "sev_snp"))]
|
||||
if cpu_manager.lock().unwrap().sev_snp_enabled() {
|
||||
if cpu_manager.lock().unwrap().sev_snp_enabled()
|
||||
&& cpu_manager.lock().unwrap().hypervisor_type() == hypervisor::HypervisorType::Kvm
|
||||
{
|
||||
Self::reserve_bootloader_regions(&memory_manager)?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user