diff options
author | Zach Reizner <zachr@google.com> | 2019-01-16 17:35:45 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-23 20:40:38 -0800 |
commit | f1a33757257f5d210b52397919209971d459c5c7 (patch) | |
tree | de40dd044772b0a94575b2e82c06b35f068758f2 /kvm/src/lib.rs | |
parent | 6a8fdd9f8e23545619a7da330f1baf6cc34c552c (diff) | |
download | crosvm-f1a33757257f5d210b52397919209971d459c5c7.tar crosvm-f1a33757257f5d210b52397919209971d459c5c7.tar.gz crosvm-f1a33757257f5d210b52397919209971d459c5c7.tar.bz2 crosvm-f1a33757257f5d210b52397919209971d459c5c7.tar.lz crosvm-f1a33757257f5d210b52397919209971d459c5c7.tar.xz crosvm-f1a33757257f5d210b52397919209971d459c5c7.tar.zst crosvm-f1a33757257f5d210b52397919209971d459c5c7.zip |
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>
Diffstat (limited to 'kvm/src/lib.rs')
-rw-r--r-- | kvm/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs index 65c4ee5..8b647b5 100644 --- a/kvm/src/lib.rs +++ b/kvm/src/lib.rs @@ -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. |