From 1741af74ed203edf1be2160e1d804cc50acd2dd2 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 24 Jun 2020 15:29:49 +0000 Subject: [PATCH] hypervisor: add safety statement in set_user_memory_region When set_user_memory_region was moved to hypervisor crate, it was turned into a safe function that wrapped around an unsafe call. All but one call site had the safety statements removed. But safety statement was not moved inside the wrapper function. Add the safety statement back to help reasoning in the future. Also remove that one last instance where the safety statement is not needed . No functional change. Signed-off-by: Wei Liu --- hypervisor/src/kvm/mod.rs | 1 + vmm/src/vm.rs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index 1bf25b37b..9cf1753e0 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -170,6 +170,7 @@ impl vm::Vm for KvmVm { /// Creates/modifies a guest physical memory slot. /// fn set_user_memory_region(&self, user_memory_region: MemoryRegion) -> vm::Result<()> { + // Safe because guest regions are guaranteed not to overlap. unsafe { self.fd .set_user_memory_region(user_memory_region) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index e9cc41854..0338988e7 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -1459,7 +1459,6 @@ pub fn test_vm() { flags: 0, }; - // Safe because the guest regions are guaranteed not to overlap. vm_fd.set_user_memory_region(mem_region) }) .expect("Cannot configure guest memory");