From 3a683b54d585a8e13f481cf009f9bfac2c0e0a17 Mon Sep 17 00:00:00 2001 From: Jinank Jain Date: Mon, 5 Feb 2024 15:40:49 +0530 Subject: [PATCH] hypervisor: Add a flag to identify sev-snp VM This will help in identify whether a VM supports sev-snp and based on that disable/enable certain features. Signed-off-by: Jinank Jain Signed-off-by: Muminul Islam --- hypervisor/src/mshv/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index 516b81bbf..19f657e06 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -251,6 +251,7 @@ impl hypervisor::Hypervisor for MshvHypervisor { } // Set additional partition property for SEV-SNP partition. + let mut _sev_snp_enabled = mshv_vm_type == VmType::Snp; if mshv_vm_type == VmType::Snp { let snp_policy = snp::get_default_snp_guest_policy(); let vmgexit_offloads = snp::get_default_vmgexit_offload_features(); @@ -306,6 +307,8 @@ impl hypervisor::Hypervisor for MshvHypervisor { fd: vm_fd, msrs, dirty_log_slots: Arc::new(RwLock::new(HashMap::new())), + #[cfg(feature = "sev_snp")] + sev_snp_enabled: _sev_snp_enabled, })) } @@ -1467,6 +1470,8 @@ pub struct MshvVm { fd: Arc, msrs: Vec, dirty_log_slots: Arc>>, + #[cfg(feature = "sev_snp")] + sev_snp_enabled: bool, } impl MshvVm {