mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Unify address space allocation
It seems like address allocation has been spread into different files and different location for x86 vs ARM. This makes it hard to follow the code. Thus, unify it a single location which satisfies all the requirement. Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
This commit is contained in:
@@ -646,6 +646,19 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
memory_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.allocate_address_space()
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
memory_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.add_uefi_flash()
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
// Loading the igvm file is pushed down here because
|
||||
// igvm parser needs cpu_manager to retrieve cpuid leaf.
|
||||
// Currently, Microsoft Hypervisor does not provide any
|
||||
@@ -2320,18 +2333,6 @@ impl Vm {
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
self.configure_system().unwrap();
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
// Note: For x86, always call this function before invoking start boot vcpus.
|
||||
// Otherwise guest would fail to boot because we haven't created the
|
||||
// userspace mappings to update the hypervisor about the memory mappings.
|
||||
// These mappings must be created before we start the vCPU threads for
|
||||
// the very first time.
|
||||
self.memory_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.allocate_address_space()
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
if let Some(hob_address) = hob_address {
|
||||
// With the HOB address extracted the vCPUs can have
|
||||
@@ -2368,18 +2369,6 @@ impl Vm {
|
||||
pub fn restore(&mut self) -> Result<()> {
|
||||
event!("vm", "restoring");
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
// Note: For x86, always call this function before invoking start boot vcpus.
|
||||
// Otherwise guest would fail to boot because we haven't created the
|
||||
// userspace mappings to update the hypervisor about the memory mappings.
|
||||
// These mappings must be created before we start the vCPU threads for
|
||||
// the very first time for the restored VM.
|
||||
self.memory_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.allocate_address_space()
|
||||
.map_err(Error::MemoryManager)?;
|
||||
|
||||
// Now we can start all vCPUs from here.
|
||||
self.cpu_manager
|
||||
.lock()
|
||||
|
||||
Reference in New Issue
Block a user