From a00189cf7278582e559b189967d0f262077a824b Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 19 Jan 2026 19:15:12 +0100 Subject: [PATCH] hypervisor: vmm: mshv: Enable SMT for guests with threads_per_core > 1 Set HV_PARTITION_CREATION_FLAG_SMT_ENABLED_GUEST when the guest topology has more than one thread per core. This allows the hypervisor to schedule guest VPs correctly on SMT-enabled hosts. Without this flag, the hypervisor schedules guest VPs incorrectly, causing SMT unusable. Signed-off-by: Anatol Belski --- hypervisor/src/lib.rs | 1 + hypervisor/src/mshv/mod.rs | 4 ++++ vmm/src/lib.rs | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs index 77e1f9a43..7f8084d06 100644 --- a/hypervisor/src/lib.rs +++ b/hypervisor/src/lib.rs @@ -171,6 +171,7 @@ pub struct HypervisorVmConfig { #[cfg(feature = "sev_snp")] pub mem_size: u64, pub nested: bool, + pub smt_enabled: bool, } #[derive(Copy, Clone)] diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 0c8d2632c..b36b306a9 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -307,6 +307,10 @@ impl hypervisor::Hypervisor for MshvHypervisor { .__bindgen_anon_1 .set_nested_virt_support(1u64); } + + if _config.smt_enabled { + create_args.pt_flags |= 1 << MSHV_PT_BIT_SMT_ENABLED_GUEST; + } } // Modified feature bit fields are written back to create_args for i in 0..create_args.pt_num_cpu_fbanks { diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index 6917e005e..41a2c3383 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -221,6 +221,11 @@ impl From<&VmConfig> for hypervisor::HypervisorVmConfig { #[cfg(feature = "sev_snp")] mem_size: _value.memory.total_size(), nested: _value.cpus.nested, + smt_enabled: _value + .cpus + .topology + .as_ref() + .is_some_and(|t| t.threads_per_core > 1), } } }