vmm: cpu: Split vCPU creation

Split the vCPU creation into two distincts parts. On the one hand we
create the actual Vcpu object with the creation of the hypervisor::Vcpu.
And on the other hand, we configure the existing Vcpu, setting registers
to proper values (such as setting the entry point).

This will allow for further work to move the creation earlier in the
boot, so that the hypervisor::Vcpu will be already created when the
DeviceManager gets created.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
Sebastien Boeuf
2022-11-04 10:27:22 +01:00
parent ec01062ada
commit 578780ed0c
2 changed files with 48 additions and 23 deletions
+9 -6
View File
@@ -2087,12 +2087,15 @@ impl Vm {
self.init_tdx()?;
}
// Create and configure vcpus
self.cpu_manager
.lock()
.unwrap()
.create_boot_vcpus(entry_point)
.map_err(Error::CpuManager)?;
// Configure the vcpus that have been created
let vcpus = self.cpu_manager.lock().unwrap().vcpus();
for vcpu in vcpus {
self.cpu_manager
.lock()
.unwrap()
.configure_vcpu(vcpu, entry_point, None)
.map_err(Error::CpuManager)?;
}
#[cfg(feature = "tdx")]
let sections = if tdx_enabled {