mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
memory_manager: Make addressable space size 64k aligned
While the addressable space size reduction of 4k in necessary due to the Linux bug, the 64k alignment of the addressable space size is required by Windows. This patch satisfies both. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
parent
c0827e01b1
commit
b399287430
@ -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())])
|
||||
|
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user