kvm: add KVM_GET_FPU ioctl

BUG=None
TEST=./build_test

Change-Id: I38ee166d9c7a0340d58fb3fd7f51895ca158f8b3
Reviewed-on: https://chromium-review.googlesource.com/848016
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:43:40 -08:00 committed by chrome-bot
parent ce4611cde2
commit d60bb1616c

View file

@ -581,6 +581,19 @@ impl Vcpu {
Ok(())
}
/// Gets the VCPU FPU registers.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn get_fpu(&self) -> Result<kvm_fpu> {
// Safe because we know that our file is a VCPU fd, we know the kernel will only write the
// correct amount of memory to our pointer, and we verify the return result.
let mut regs = unsafe { std::mem::zeroed() };
let ret = unsafe { ioctl_with_mut_ref(self, KVM_GET_FPU(), &mut regs) };
if ret != 0 {
return errno_result();
}
Ok(regs)
}
/// X86 specific call to setup the FPU
///
/// See the documentation for KVM_SET_FPU.