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>
This commit is contained in:
Zach Reizner 2018-01-02 13:40:00 -08:00 committed by chrome-bot
parent d60bb1616c
commit df59500364

View file

@ -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.