summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorDavid Hildenbrand2017-04-28 17:06:20 +0200
committerPaolo Bonzini2017-05-02 14:45:45 +0200
commit5c0aea0e8d98e38858fbb3a09870ed8487a01da2 (patch)
tree12549a0a41cdda2b265bf0107daca828bc52b8c5 /arch/x86/kvm/x86.c
parentKVM: Documentation: remove VM mmap documentation (diff)
downloadkernel-qcow2-linux-5c0aea0e8d98e38858fbb3a09870ed8487a01da2.tar.gz
kernel-qcow2-linux-5c0aea0e8d98e38858fbb3a09870ed8487a01da2.tar.xz
kernel-qcow2-linux-5c0aea0e8d98e38858fbb3a09870ed8487a01da2.zip
KVM: x86: don't hold kvm->lock in KVM_SET_GSI_ROUTING
We needed the lock to avoid racing with creation of the irqchip on x86. As kvm_set_irq_routing() calls srcu_synchronize_expedited(), this lock might be held for a longer time. Let's introduce an arch specific callback to check if we can actually add irq routes. For x86, all we have to do is check if we have an irqchip in the kernel. We don't need kvm->lock at that point as the irqchip is marked as inititalized only when actually fully created. Reported-by: Steve Rutherford <srutherford@google.com> Reviewed-by: Radim Krčmář <rkrcmar@redhat.com> Fixes: 1df6ddede10a ("KVM: x86: race between KVM_SET_GSI_ROUTING and KVM_CREATE_IRQCHIP") Signed-off-by: David Hildenbrand <david@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.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index be2ade58edb9..2fe9aa116288 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3919,14 +3919,9 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
goto split_irqchip_unlock;
if (kvm->created_vcpus)
goto split_irqchip_unlock;
- kvm->arch.irqchip_mode = KVM_IRQCHIP_INIT_IN_PROGRESS;
r = kvm_setup_empty_irq_routing(kvm);
- if (r) {
- kvm->arch.irqchip_mode = KVM_IRQCHIP_NONE;
- /* Pairs with smp_rmb() when reading irqchip_mode */
- smp_wmb();
+ if (r)
goto split_irqchip_unlock;
- }
/* Pairs with irqchip_in_kernel. */
smp_wmb();
kvm->arch.irqchip_mode = KVM_IRQCHIP_SPLIT;
@@ -4012,12 +4007,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
goto create_irqchip_unlock;
}
- kvm->arch.irqchip_mode = KVM_IRQCHIP_INIT_IN_PROGRESS;
r = kvm_setup_default_irq_routing(kvm);
if (r) {
- kvm->arch.irqchip_mode = KVM_IRQCHIP_NONE;
- /* Pairs with smp_rmb() when reading irqchip_mode */
- smp_wmb();
kvm_ioapic_destroy(kvm);
kvm_pic_destroy(kvm);
goto create_irqchip_unlock;