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 <jinankjain@microsoft.com>
Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Jinank Jain 2024-02-05 15:40:49 +05:30 committed by Bo Chen
parent af4a193b43
commit 3a683b54d5

View File

@ -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<VmFd>,
msrs: Vec<MsrEntry>,
dirty_log_slots: Arc<RwLock<HashMap<u64, MshvDirtyLogSlot>>>,
#[cfg(feature = "sev_snp")]
sev_snp_enabled: bool,
}
impl MshvVm {