From 8fff4c1af3c41324625499842711d0eb4e8f1d8d 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 c110e4874..5a7ef2788 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -703,14 +703,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,