summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorRadim Krčmář2016-03-02 22:56:45 +0100
committerPaolo Bonzini2016-03-04 09:30:01 +0100
commit71474e2f0f439b83b7b53ee6e9cf4f44c15b5806 (patch)
tree92305f6cbf6f6a935818ae102bab682fd38fd96e /arch/x86/kvm/x86.c
parentKVM: i8254: remove unnecessary uses of PIT state lock (diff)
downloadkernel-qcow2-linux-71474e2f0f439b83b7b53ee6e9cf4f44c15b5806.tar.gz
kernel-qcow2-linux-71474e2f0f439b83b7b53ee6e9cf4f44c15b5806.tar.xz
kernel-qcow2-linux-71474e2f0f439b83b7b53ee6e9cf4f44c15b5806.zip
KVM: i8254: remove notifiers from PIT discard policy
Discard policy doesn't rely on information from notifiers, so we don't need to register notifiers unconditionally. We kept correct counts in case userspace switched between policies during runtime, but that can be avoided by reseting the state. Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ce4e91db5bae..76f9f48898a5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3659,10 +3659,18 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
static int kvm_vm_ioctl_reinject(struct kvm *kvm,
struct kvm_reinject_control *control)
{
- if (!kvm->arch.vpit)
+ struct kvm_pit *pit = kvm->arch.vpit;
+
+ if (!pit)
return -ENXIO;
- kvm->arch.vpit->pit_state.reinject = control->pit_reinject;
+ /* pit->pit_state.lock was overloaded to prevent userspace from getting
+ * an inconsistent state after running multiple KVM_REINJECT_CONTROL
+ * ioctls in parallel. Use a separate lock if that ioctl isn't rare.
+ */
+ mutex_lock(&pit->pit_state.lock);
+ kvm_pit_set_reinject(pit, control->pit_reinject);
+ mutex_unlock(&pit->pit_state.lock);
return 0;
}