diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 6dcac04f1..e4c626835 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -832,9 +832,9 @@ pub fn configure_vcpu( cpuid: Vec, kvm_hyperv: bool, cpu_vendor: CpuVendor, - topology: Option<(u16, u16, u16, u16)>, + topology: (u16, u16, u16, u16), ) -> super::Result<()> { - let x2apic_id = get_x2apic_id(id, topology); + let x2apic_id = get_x2apic_id(id, Some(topology)); // Per vCPU CPUID changes; common are handled via generate_common_cpuid() let mut cpuid = cpuid; @@ -856,9 +856,9 @@ pub fn configure_vcpu( } assert!(apic_id_patched); - if let Some(t) = topology { - update_cpuid_topology(&mut cpuid, t.0, t.1, t.2, t.3, cpu_vendor, id); - } + update_cpuid_topology( + &mut cpuid, topology.0, topology.1, topology.2, topology.3, cpu_vendor, id, + ); // The TSC frequency CPUID leaf should not be included when running with HyperV emulation if !kvm_hyperv { diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 7b16b3988..629b0152b 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -390,7 +390,7 @@ impl Vcpu { boot_setup: Option<(EntryPoint, &GuestMemoryAtomic)>, #[cfg(target_arch = "x86_64")] cpuid: Vec, #[cfg(target_arch = "x86_64")] kvm_hyperv: bool, - #[cfg(target_arch = "x86_64")] topology: Option<(u16, u16, u16, u16)>, + #[cfg(target_arch = "x86_64")] topology: (u16, u16, u16, u16), ) -> Result<()> { #[cfg(target_arch = "aarch64")] { @@ -885,20 +885,20 @@ impl CpuManager { #[cfg(target_arch = "x86_64")] let topology = self.config.topology.clone().map_or_else( || { - Some(( + ( 1_u16, u16::try_from(self.boot_vcpus()).unwrap(), 1_u16, 1_u16, - )) + ) }, |t| { - Some(( + ( t.threads_per_core.into(), t.cores_per_die.into(), t.dies_per_package.into(), t.packages.into(), - )) + ) }, ); #[cfg(target_arch = "x86_64")]