From df595003645c39728b05974990cca52ed9ff6742 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Tue, 2 Jan 2018 13:40:00 -0800 Subject: [PATCH] kvm: add KVM_SET_IDENTITY_MAP_ADDR ioctl BUG=None TEST=./build_test Change-Id: Ic5b479487f45949fd0888af6d670293931a6a0a7 Reviewed-on: https://chromium-review.googlesource.com/848017 Commit-Ready: Zach Reizner Tested-by: Zach Reizner Reviewed-by: Stephen Barber --- kvm/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index bd7fdf5386..2c72271854 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -272,6 +272,22 @@ impl Vm { } } + /// Sets the address of a one-page region in the VM's address space. + /// + /// See the documentation on the KVM_SET_IDENTITY_MAP_ADDR ioctl. + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub fn set_identity_map_addr(&self, addr: GuestAddress) -> Result<()> { + // Safe because we know that our file is a VM fd and we verify the return result. + let ret = unsafe { + ioctl_with_val(self, KVM_SET_IDENTITY_MAP_ADDR(), addr.offset() as u64) + }; + if ret == 0 { + Ok(()) + } else { + errno_result() + } + } + /// Crates an in kernel interrupt controller. /// /// See the documentation on the KVM_CREATE_IRQCHIP ioctl.