From 959ea7115f94e5a80cfa1a55a84c5651281ff00f Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Tue, 6 Aug 2024 14:44:51 -0700 Subject: [PATCH] vmm: implement AccessPlatform for SEV-SNP proxy struct Implement AccessPlatform for SEV-SNP guest to access restricted page using IO. VMM calls MSHV api to get access of the pages, MSHV requests guest to release the access. Signed-off-by: Muminul Islam --- vmm/src/device_manager.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index e03296406..a76d9cdc1 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -800,6 +800,20 @@ impl SevSnpPageAccessProxy { } } +#[cfg(all(feature = "mshv", feature = "sev_snp"))] +impl AccessPlatform for SevSnpPageAccessProxy { + fn translate_gpa(&self, base: u64, _size: u64) -> std::result::Result { + Ok(base) + } + + fn translate_gva(&self, base: u64, size: u64) -> std::result::Result { + self.vm + .gain_page_access(base, size as u32) + .map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; + Ok(base) + } +} + pub struct DeviceManager { // Manage address space related to devices address_manager: Arc,