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), } } }