vmm: pass AccessPlatform implementation for SEV-SNP guest

Passing AccessPlatform trait to virtio-device for requesting
restricting page access during IO for SEV-SNP guest.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam 2024-08-06 15:29:50 -07:00 committed by Liu Wei
parent 959ea7115f
commit 1e967697c2

View File

@ -3741,15 +3741,22 @@ impl DeviceManager {
// Create the AccessPlatform trait from the implementation IommuMapping. // Create the AccessPlatform trait from the implementation IommuMapping.
// This will provide address translation for any virtio device sitting // This will provide address translation for any virtio device sitting
// behind a vIOMMU. // behind a vIOMMU.
let access_platform: Option<Arc<dyn AccessPlatform>> = if let Some(mapping) = iommu_mapping let mut access_platform: Option<Arc<dyn AccessPlatform>> = None;
{
Some(Arc::new(AccessPlatformMapping::new( if let Some(mapping) = iommu_mapping {
access_platform = Some(Arc::new(AccessPlatformMapping::new(
pci_device_bdf.into(), pci_device_bdf.into(),
mapping.clone(), mapping.clone(),
))) )));
} else { }
None
}; // If SEV-SNP is enabled create the AccessPlatform from SevSnpPageAccessProxy
#[cfg(feature = "sev_snp")]
if self.config.lock().unwrap().is_sev_snp_enabled() {
access_platform = Some(Arc::new(SevSnpPageAccessProxy::new(
self.address_manager.vm.clone(),
)));
}
let memory = self.memory_manager.lock().unwrap().guest_memory(); let memory = self.memory_manager.lock().unwrap().guest_memory();