diff --git a/mshv-ioctls/src/ioctls/vm.rs b/mshv-ioctls/src/ioctls/vm.rs index dc614478..63c05a0d 100644 --- a/mshv-ioctls/src/ioctls/vm.rs +++ b/mshv-ioctls/src/ioctls/vm.rs @@ -99,6 +99,63 @@ impl VmFd { Err(errno::Error::last()) } } + /// Modify host visibility for a range of GPA + pub fn modify_gpa_host_access( + &self, + gpa_host_access_args: &mshv_modify_gpa_host_access, + ) -> Result<()> { + // SAFETY: IOCTL with correct types + let ret = + unsafe { ioctl_with_ref(self, MSHV_MODIFY_GPA_HOST_ACCESS(), gpa_host_access_args) }; + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } + /// Import the isolated pages + pub fn import_isolated_pages( + &self, + isolate_page_list: &mshv_import_isolated_pages, + ) -> Result<()> { + // SAFETY: IOCTL with correct types + let ret = unsafe { ioctl_with_ref(self, MSHV_IMPORT_ISOLATED_PAGES(), isolate_page_list) }; + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } + /// Mark completion of importing the isoalted pages + pub fn complete_isolated_import(&self, data: &mshv_complete_isolated_import) -> Result<()> { + // SAFETY: IOCTL with correct types + let ret = unsafe { ioctl_with_ref(self, MSHV_COMPLETE_ISOLATED_IMPORT(), data) }; + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } + /// Issue PSP request from guest side + pub fn psp_issue_guest_request(&self, data: &mshv_issue_psp_guest_request) -> Result<()> { + // SAFETY: IOCTL with correct types + let ret = unsafe { ioctl_with_ref(self, MSHV_ISSUE_PSP_GUEST_REQUEST(), data) }; + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } + /// Create AP threads for SEV-SNP guest + pub fn sev_snp_ap_create(&self, data: &mshv_sev_snp_ap_create) -> Result<()> { + // SAFETY: IOCTL with correct types + let ret = unsafe { ioctl_with_ref(self, MSHV_SEV_SNP_AP_CREATE(), data) }; + if ret == 0 { + Ok(()) + } else { + Err(errno::Error::last()) + } + } /// Creates/modifies a guest physical memory. pub fn map_user_memory(&self, user_memory_region: mshv_user_mem_region) -> Result<()> { // SAFETY: IOCTL with correct types diff --git a/mshv-ioctls/src/mshv_ioctls.rs b/mshv-ioctls/src/mshv_ioctls.rs index f0ea3ec9..8683a284 100644 --- a/mshv-ioctls/src/mshv_ioctls.rs +++ b/mshv-ioctls/src/mshv_ioctls.rs @@ -99,5 +99,35 @@ ioctl_iowr_nr!( 0x1B, mshv_get_vp_cpuid_values ); +ioctl_iow_nr!( + MSHV_MODIFY_GPA_HOST_ACCESS, + MSHV_IOCTL, + 0x28, + mshv_modify_gpa_host_access +); +ioctl_iow_nr!( + MSHV_IMPORT_ISOLATED_PAGES, + MSHV_IOCTL, + 0x29, + mshv_import_isolated_pages +); +ioctl_iow_nr!( + MSHV_COMPLETE_ISOLATED_IMPORT, + MSHV_IOCTL, + 0x30, + mshv_complete_isolated_import +); +ioctl_iow_nr!( + MSHV_ISSUE_PSP_GUEST_REQUEST, + MSHV_IOCTL, + 0x31, + mshv_issue_psp_guest_request +); ioctl_iowr_nr!(MSHV_READ_GPA, MSHV_IOCTL, 0x32, mshv_read_write_gpa); ioctl_iow_nr!(MSHV_WRITE_GPA, MSHV_IOCTL, 0x33, mshv_read_write_gpa); +ioctl_iow_nr!( + MSHV_SEV_SNP_AP_CREATE, + MSHV_IOCTL, + 0x34, + mshv_sev_snp_ap_create +);