mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
arch, vmm: Add new struct CpuidConfig
This struct contains all configuration fields that controls the way how we generate CPUID for the guest on x86_64. This allows cleaner extension when adding new configuration fields. Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
@@ -726,7 +726,7 @@ impl CpuManager {
|
||||
&mut self,
|
||||
memory_manager: &Arc<Mutex<MemoryManager>>,
|
||||
hypervisor: &Arc<dyn hypervisor::Hypervisor>,
|
||||
#[cfg(feature = "tdx")] tdx_enabled: bool,
|
||||
#[cfg(feature = "tdx")] tdx: bool,
|
||||
) -> Result<()> {
|
||||
let sgx_epc_sections = memory_manager
|
||||
.lock()
|
||||
@@ -739,11 +739,13 @@ impl CpuManager {
|
||||
let phys_bits = physical_bits(hypervisor, self.config.max_phys_bits);
|
||||
arch::generate_common_cpuid(
|
||||
hypervisor,
|
||||
sgx_epc_sections,
|
||||
phys_bits,
|
||||
self.config.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx_enabled,
|
||||
&arch::CpuidConfig {
|
||||
sgx_epc_sections,
|
||||
phys_bits,
|
||||
kvm_hyperv: self.config.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx,
|
||||
},
|
||||
)
|
||||
.map_err(Error::CommonCpuId)?
|
||||
};
|
||||
|
||||
@@ -1664,16 +1664,18 @@ impl Vmm {
|
||||
#[cfg(all(feature = "kvm", target_arch = "x86_64"))]
|
||||
let common_cpuid = {
|
||||
#[cfg(feature = "tdx")]
|
||||
let tdx_enabled = vm_config.lock().unwrap().is_tdx_enabled();
|
||||
let tdx = vm_config.lock().unwrap().is_tdx_enabled();
|
||||
let phys_bits =
|
||||
vm::physical_bits(&hypervisor, vm_config.lock().unwrap().cpus.max_phys_bits);
|
||||
arch::generate_common_cpuid(
|
||||
&hypervisor,
|
||||
None,
|
||||
phys_bits,
|
||||
vm_config.lock().unwrap().cpus.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx_enabled,
|
||||
&arch::CpuidConfig {
|
||||
sgx_epc_sections: None,
|
||||
phys_bits,
|
||||
kvm_hyperv: vm_config.lock().unwrap().cpus.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx,
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid': {:?}", e))
|
||||
@@ -1858,11 +1860,13 @@ impl Vmm {
|
||||
let phys_bits = vm::physical_bits(&self.hypervisor, vm_config.cpus.max_phys_bits);
|
||||
arch::generate_common_cpuid(
|
||||
&self.hypervisor.clone(),
|
||||
None,
|
||||
phys_bits,
|
||||
vm_config.cpus.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
vm_config.is_tdx_enabled(),
|
||||
&arch::CpuidConfig {
|
||||
sgx_epc_sections: None,
|
||||
phys_bits,
|
||||
kvm_hyperv: vm_config.cpus.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx: vm_config.is_tdx_enabled(),
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {:?}", e))
|
||||
|
||||
@@ -2415,11 +2415,13 @@ impl Snapshottable for Vm {
|
||||
);
|
||||
arch::generate_common_cpuid(
|
||||
&self.hypervisor,
|
||||
None,
|
||||
phys_bits,
|
||||
self.config.lock().unwrap().cpus.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx_enabled,
|
||||
&arch::CpuidConfig {
|
||||
sgx_epc_sections: None,
|
||||
phys_bits,
|
||||
kvm_hyperv: self.config.lock().unwrap().cpus.kvm_hyperv,
|
||||
#[cfg(feature = "tdx")]
|
||||
tdx: tdx_enabled,
|
||||
},
|
||||
)
|
||||
.map_err(|e| {
|
||||
MigratableError::MigrateReceive(anyhow!("Error generating common cpuid: {:?}", e))
|
||||
|
||||
Reference in New Issue
Block a user