From 034b48faf7399b6ed9fc94313fdc81c8b2935cdf Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 27 Mar 2023 15:45:32 +0200 Subject: [PATCH] mshv: Pass topology explicitly while constructing cpuid Unlike KVM, there's no internal handling for topoolgy under MSHV. Thus, if no topology has been passed during the CH launch, use the boot CPUs count to construct the topology struct. Signed-off-by: Anatol Belski --- vmm/src/cpu.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index afb247841..5e0f97947 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -696,14 +696,23 @@ impl CpuManager { .sgx_epc_region() .as_ref() .map(|sgx_epc_region| sgx_epc_region.epc_sections().values().cloned().collect()); + + let topology = self.config.topology.clone().map_or_else( + || { + #[cfg(feature = "mshv")] + if matches!(hypervisor.hypervisor_type(), HypervisorType::Mshv) { + return Some((1, self.boot_vcpus(), 1)); + } + None + }, + |t| Some((t.threads_per_core, t.cores_per_die, t.dies_per_package)), + ); + self.cpuid = { let phys_bits = physical_bits(self.config.max_phys_bits); arch::generate_common_cpuid( hypervisor, - self.config - .topology - .clone() - .map(|t| (t.threads_per_core, t.cores_per_die, t.dies_per_package)), + topology, sgx_epc_sections, phys_bits, self.config.kvm_hyperv,