mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
vmm: Allocate guest memory address space before TDX initialization
The refactoring on deferring address space allocation (#5169) broke TDX, as TDX initialization needs to access guest memory for encryption and measurement of guest pages. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
79bc42f3c2
commit
0b1e626fe3
@ -2004,6 +2004,18 @@ impl Vm {
|
|||||||
})
|
})
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
|
#[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")]
|
#[cfg(feature = "tdx")]
|
||||||
if let Some(hob_address) = hob_address {
|
if let Some(hob_address) = hob_address {
|
||||||
// With the HOB address extracted the vCPUs can have
|
// With the HOB address extracted the vCPUs can have
|
||||||
@ -2021,18 +2033,6 @@ impl Vm {
|
|||||||
self.vm.tdx_finalize().map_err(Error::FinalizeTdx)?;
|
self.vm.tdx_finalize().map_err(Error::FinalizeTdx)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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)?;
|
|
||||||
|
|
||||||
self.cpu_manager
|
self.cpu_manager
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
Reference in New Issue
Block a user