mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
vmm: Move TDX initialization before vCPUs creation
TDX was broken by the recent refactoring moving the vCPU creation earlier than before. The simple and correct way to fix this problem is by moving the TDX initialization right before the vCPUs creation. The rest of the TDX setup can remain where it is. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
0e09b537e3
commit
31209474b3
@ -551,6 +551,16 @@ impl Vm {
|
||||
)
|
||||
.map_err(Error::CpuManager)?;
|
||||
|
||||
// The initial TDX configuration must be done before the vCPUs are
|
||||
// created
|
||||
#[cfg(feature = "tdx")]
|
||||
if tdx_enabled {
|
||||
let cpuid = cpu_manager.lock().unwrap().common_cpuid();
|
||||
let max_vcpus = cpu_manager.lock().unwrap().max_vcpus() as u32;
|
||||
vm.tdx_init(&cpuid, max_vcpus)
|
||||
.map_err(Error::InitializeTdxVm)?;
|
||||
}
|
||||
|
||||
cpu_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
@ -1638,16 +1648,6 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
fn init_tdx(&mut self) -> Result<()> {
|
||||
let cpuid = self.cpu_manager.lock().unwrap().common_cpuid();
|
||||
let max_vcpus = self.cpu_manager.lock().unwrap().max_vcpus() as u32;
|
||||
self.vm
|
||||
.tdx_init(&cpuid, max_vcpus)
|
||||
.map_err(Error::InitializeTdxVm)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
fn extract_tdvf_sections(&mut self) -> Result<Vec<TdvfSection>> {
|
||||
use arch::x86_64::tdx::*;
|
||||
@ -2059,13 +2059,6 @@ impl Vm {
|
||||
#[cfg(feature = "tdx")]
|
||||
let tdx_enabled = self.config.lock().unwrap().is_tdx_enabled();
|
||||
|
||||
// The initial TDX configuration must be done before the vCPUs are
|
||||
// created
|
||||
#[cfg(feature = "tdx")]
|
||||
if tdx_enabled {
|
||||
self.init_tdx()?;
|
||||
}
|
||||
|
||||
// Configure the vcpus that have been created
|
||||
let vcpus = self.cpu_manager.lock().unwrap().vcpus();
|
||||
for vcpu in vcpus {
|
||||
|
Loading…
Reference in New Issue
Block a user