Skip to content

Commit fdc5ba1

Browse files
committed
feat: add allocator for past 64bit memory region
Virtio-pmem devices need to allocate a memory region in guest physical memory. The safe place to do this is past 64bit MMIO region. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent 9b86a41 commit fdc5ba1

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

src/vmm/src/arch/aarch64/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,5 @@ pub const MEM_64BIT_DEVICES_START: u64 = MMIO64_MEM_START;
139139
pub const MEM_64BIT_DEVICES_SIZE: u64 = MMIO64_MEM_SIZE;
140140
/// First address past the 64-bit MMIO gap
141141
pub const FIRST_ADDR_PAST_64BITS_MMIO: u64 = MMIO64_MEM_START + MMIO64_MEM_SIZE;
142+
/// Size of the memory past 64-bit MMIO gap
143+
pub const PAST_64BITS_MMIO_SIZE: u64 = 512 << 30;

src/vmm/src/arch/mod.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ pub use aarch64::vm::{ArchVm, ArchVmError, VmState};
2121
#[cfg(target_arch = "aarch64")]
2222
pub use aarch64::{
2323
ConfigurationError, arch_memory_regions, configure_system_for_boot, get_kernel_start,
24-
initrd_load_addr, layout::BOOT_DEVICE_MEM_START, layout::CMDLINE_MAX_SIZE,
25-
layout::GSI_LEGACY_END, layout::GSI_LEGACY_NUM, layout::GSI_LEGACY_START, layout::GSI_MSI_END,
26-
layout::GSI_MSI_NUM, layout::GSI_MSI_START, layout::MEM_32BIT_DEVICES_SIZE,
27-
layout::MEM_32BIT_DEVICES_START, layout::MEM_64BIT_DEVICES_SIZE,
28-
layout::MEM_64BIT_DEVICES_START, layout::MMIO32_MEM_SIZE, layout::MMIO32_MEM_START,
29-
layout::PCI_MMCONFIG_SIZE, layout::PCI_MMCONFIG_START,
30-
layout::PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, layout::RTC_MEM_START, layout::SERIAL_MEM_START,
31-
layout::SPI_START, layout::SYSTEM_MEM_SIZE, layout::SYSTEM_MEM_START, load_kernel,
24+
initrd_load_addr, layout::*, load_kernel,
3225
};
3326

3427
/// Module for x86_64 related functionality.
@@ -45,14 +38,7 @@ pub use x86_64::vm::{ArchVm, ArchVmError, VmState};
4538
#[cfg(target_arch = "x86_64")]
4639
pub use crate::arch::x86_64::{
4740
ConfigurationError, arch_memory_regions, configure_system_for_boot, get_kernel_start,
48-
initrd_load_addr, layout::APIC_ADDR, layout::BOOT_DEVICE_MEM_START, layout::CMDLINE_MAX_SIZE,
49-
layout::GSI_LEGACY_END, layout::GSI_LEGACY_NUM, layout::GSI_LEGACY_START, layout::GSI_MSI_END,
50-
layout::GSI_MSI_NUM, layout::GSI_MSI_START, layout::IOAPIC_ADDR,
51-
layout::MEM_32BIT_DEVICES_SIZE, layout::MEM_32BIT_DEVICES_START,
52-
layout::MEM_64BIT_DEVICES_SIZE, layout::MEM_64BIT_DEVICES_START, layout::MMIO32_MEM_SIZE,
53-
layout::MMIO32_MEM_START, layout::PCI_MMCONFIG_SIZE, layout::PCI_MMCONFIG_START,
54-
layout::PCI_MMIO_CONFIG_SIZE_PER_SEGMENT, layout::SYSTEM_MEM_SIZE, layout::SYSTEM_MEM_START,
55-
load_kernel,
41+
initrd_load_addr, layout::*, load_kernel,
5642
};
5743

5844
/// Types of devices that can get attached to this platform.

src/vmm/src/arch/x86_64/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,5 @@ pub const MEM_64BIT_DEVICES_START: u64 = MMIO64_MEM_START;
132132
pub const MEM_64BIT_DEVICES_SIZE: u64 = MMIO64_MEM_SIZE;
133133
/// First address past the 64-bit MMIO gap
134134
pub const FIRST_ADDR_PAST_64BITS_MMIO: u64 = MMIO64_MEM_START + MMIO64_MEM_SIZE;
135+
/// Size of the memory past 64-bit MMIO gap
136+
pub const PAST_64BITS_MMIO_SIZE: u64 = 512 << 30;

src/vmm/src/vstate/resources.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pub struct ResourceAllocator {
5050
pub mmio32_memory: AddressAllocator,
5151
/// Allocator for memory in the 64-bit MMIO address space
5252
pub mmio64_memory: AddressAllocator,
53+
/// Allocator for memory after the 64-bit MMIO address space
54+
pub past_mmio64_memory: AddressAllocator,
5355
/// Memory allocator for system data
5456
pub system_memory: AddressAllocator,
5557
}
@@ -79,6 +81,11 @@ impl ResourceAllocator {
7981
arch::MEM_64BIT_DEVICES_SIZE,
8082
)
8183
.unwrap(),
84+
past_mmio64_memory: AddressAllocator::new(
85+
arch::FIRST_ADDR_PAST_64BITS_MMIO,
86+
arch::PAST_64BITS_MMIO_SIZE,
87+
)
88+
.unwrap(),
8289
system_memory: AddressAllocator::new(arch::SYSTEM_MEM_START, arch::SYSTEM_MEM_SIZE)
8390
.unwrap(),
8491
}

0 commit comments

Comments
 (0)