vmm: cpu: Add functionality for enabling TDX for all vCPUs

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2021-03-03 12:10:10 +00:00
parent c8cad394b5
commit 57ce0986f7

View File

@ -186,6 +186,9 @@ pub enum Error {
/// Error populating CPUID with CPU identification
#[cfg(target_arch = "x86_64")]
CpuidIdentification(vmm_sys_util::fam::Error),
#[cfg(feature = "tdx")]
InitializeTdx(hypervisor::HypervisorCpuError),
}
pub type Result<T> = result::Result<T, Error>;
@ -1083,6 +1086,18 @@ impl CpuManager {
Ok(())
}
#[cfg(feature = "tdx")]
pub fn initialize_tdx(&self, hob_address: u64) -> Result<()> {
for vcpu in &self.vcpus {
vcpu.lock()
.unwrap()
.vcpu
.tdx_init(hob_address)
.map_err(Error::InitializeTdx)?;
}
Ok(())
}
pub fn boot_vcpus(&self) -> u8 {
self.config.boot_vcpus
}