aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/assigned-dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/assigned-dev.c')
-rw-r--r--virt/kvm/assigned-dev.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index 02ff2b19dbe2..7c98928b09d9 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Kernel-based Virtual Machine - device assignment support 2 * Kernel-based Virtual Machine - device assignment support
3 * 3 *
4 * Copyright (C) 2006-9 Red Hat, Inc 4 * Copyright (C) 2010 Red Hat, Inc. and/or its affiliates.
5 * 5 *
6 * This work is licensed under the terms of the GNU GPL, version 2. See 6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory. 7 * the COPYING file in the top-level directory.
@@ -58,12 +58,10 @@ static int find_index_from_host_irq(struct kvm_assigned_dev_kernel
58static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work) 58static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
59{ 59{
60 struct kvm_assigned_dev_kernel *assigned_dev; 60 struct kvm_assigned_dev_kernel *assigned_dev;
61 struct kvm *kvm;
62 int i; 61 int i;
63 62
64 assigned_dev = container_of(work, struct kvm_assigned_dev_kernel, 63 assigned_dev = container_of(work, struct kvm_assigned_dev_kernel,
65 interrupt_work); 64 interrupt_work);
66 kvm = assigned_dev->kvm;
67 65
68 spin_lock_irq(&assigned_dev->assigned_dev_lock); 66 spin_lock_irq(&assigned_dev->assigned_dev_lock);
69 if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_MSIX) { 67 if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_MSIX) {
@@ -316,12 +314,16 @@ static int assigned_device_enable_host_msix(struct kvm *kvm,
316 kvm_assigned_dev_intr, 0, 314 kvm_assigned_dev_intr, 0,
317 "kvm_assigned_msix_device", 315 "kvm_assigned_msix_device",
318 (void *)dev); 316 (void *)dev);
319 /* FIXME: free requested_irq's on failure */
320 if (r) 317 if (r)
321 return r; 318 goto err;
322 } 319 }
323 320
324 return 0; 321 return 0;
322err:
323 for (i -= 1; i >= 0; i--)
324 free_irq(dev->host_msix_entries[i].vector, (void *)dev);
325 pci_disable_msix(dev->dev);
326 return r;
325} 327}
326 328
327#endif 329#endif
@@ -444,9 +446,6 @@ static int kvm_vm_ioctl_assign_irq(struct kvm *kvm,
444 struct kvm_assigned_dev_kernel *match; 446 struct kvm_assigned_dev_kernel *match;
445 unsigned long host_irq_type, guest_irq_type; 447 unsigned long host_irq_type, guest_irq_type;
446 448
447 if (!capable(CAP_SYS_RAWIO))
448 return -EPERM;
449
450 if (!irqchip_in_kernel(kvm)) 449 if (!irqchip_in_kernel(kvm))
451 return r; 450 return r;
452 451