kvm: add wrapper for KVM_KVMCLOCK_CTRL VM ioctl

This ioctl will be used to resolve an issue where the jump forward in
kvmclock on suspended VCPUs upon resume triggers the soft lockup
detection. Using this ioctl prevents this detection from triggering,
preventing a kernel panic on resume.

TEST=cargo test -p kvm
BUG=chromium:920875

Change-Id: Id1402a9d67d790e5e7e8655f2e5916210cc6e7cc
Reviewed-on: https://chromium-review.googlesource.com/1415849
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Zach Reizner 2019-01-16 17:35:45 -08:00 committed by chrome-bot
parent 6a8fdd9f8e
commit f1a3375725

View file

@ -1454,6 +1454,21 @@ impl Vcpu {
Ok(())
}
/// Signals to the host kernel that this VCPU is about to be paused.
///
/// See the documentation for KVM_KVMCLOCK_CTRL.
pub fn kvmclock_ctrl(&self) -> Result<()> {
let ret = unsafe {
// The ioctl is safe because it does not read or write memory in this process.
ioctl(self, KVM_KVMCLOCK_CTRL())
};
if ret < 0 {
return errno_result();
}
Ok(())
}
/// Specifies set of signals that are blocked during execution of KVM_RUN.
/// Signals that are not blocked will will cause KVM_RUN to return
/// with -EINTR.