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: 1df6ddede1
("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>
Šī revīzija ir iekļauta:

revīziju iesūtīja
Paolo Bonzini

vecāks
bcb85c8876
revīzija
5c0aea0e8d
@@ -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;
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user