summary refs log tree commit diff
path: root/kvm/src/lib.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-01-02 13:40:00 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-03 14:23:23 -0800
commitdf595003645c39728b05974990cca52ed9ff6742 (patch)
tree4553e281f9cce9db39407b6cd62e7379f0ee7450 /kvm/src/lib.rs
parentd60bb1616c18c8fa0250204f460c4c632275cf48 (diff)
downloadcrosvm-df595003645c39728b05974990cca52ed9ff6742.tar
crosvm-df595003645c39728b05974990cca52ed9ff6742.tar.gz
crosvm-df595003645c39728b05974990cca52ed9ff6742.tar.bz2
crosvm-df595003645c39728b05974990cca52ed9ff6742.tar.lz
crosvm-df595003645c39728b05974990cca52ed9ff6742.tar.xz
crosvm-df595003645c39728b05974990cca52ed9ff6742.tar.zst
crosvm-df595003645c39728b05974990cca52ed9ff6742.zip
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 <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Diffstat (limited to 'kvm/src/lib.rs')
-rw-r--r--kvm/src/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs
index bd7fdf5..2c72271 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.