diff --git a/tests/integration.rs b/tests/integration.rs index bd28809d3..42fbcd404 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -5523,7 +5523,7 @@ mod tests { osdisk_path.push("windows-server-2019.raw"); let mut child = Command::new(clh_command("cloud-hypervisor")) - .args(&["--cpus", "boot=2,kvm_hyperv=on,max_phys_bits=39"]) + .args(&["--cpus", "boot=2,kvm_hyperv=on"]) .args(&["--memory", "size=4G"]) .args(&["--kernel", ovmf_path.to_str().unwrap()]) .args(&["--disk", &format!("path={}", osdisk_path.to_str().unwrap())]) @@ -5578,7 +5578,7 @@ mod tests { let mut child = Command::new(clh_command("cloud-hypervisor")) .args(&["--api-socket", &api_socket]) - .args(&["--cpus", "boot=2,kvm_hyperv=on,max_phys_bits=39"]) + .args(&["--cpus", "boot=2,kvm_hyperv=on"]) .args(&["--memory", "size=4G"]) .args(&["--kernel", ovmf_path.to_str().unwrap()]) .args(&["--disk", &format!("path={}", osdisk_path.to_str().unwrap())]) diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index 91ec67f34..2f94e12c7 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -255,11 +255,13 @@ const LENGTH_OFFSET_HIGH: u64 = 0xC; const STATUS_OFFSET: u64 = 0x14; const SELECTION_OFFSET: u64 = 0; -// The MMIO address space size is subtracted with the size of a 4k page. This -// is done on purpose to workaround a Linux bug when the VMM allocates devices -// at the end of the addressable space. +// The MMIO address space size is subtracted with 64k. This is done for the +// following reasons: +// - Reduce the addressable space size by at least 4k to workaround a Linux +// bug when the VMM allocates devices at the end of the addressable space +// - Windows requires the addressable space size to be 64k aligned fn mmio_address_space_size(phys_bits: u8) -> u64 { - (1 << phys_bits) - 0x1000 + (1 << phys_bits) - (1 << 16) } impl BusDevice for MemoryManager { @@ -609,6 +611,10 @@ impl MemoryManager { let boot_guest_memory = guest_memory.clone(); let mmio_address_space_size = mmio_address_space_size(phys_bits); + debug_assert_eq!( + (((mmio_address_space_size) >> 16) << 16), + mmio_address_space_size + ); let end_of_device_area = GuestAddress(mmio_address_space_size - 1); let mut start_of_device_area =