aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2009-08-24 04:54:26 -0400
committerAvi Kivity <avi@redhat.com>2009-12-03 02:32:08 -0500
commit680b3648ba89c44ac8d0316f78a0d6e147b88809 (patch)
treeb2b40034c4c33affef8b89822673cca835874651
parenteba0226bdfffe262e72b8360e4d0d12070e9a0f0 (diff)
KVM: Drop kvm->irq_lock lock from irq injection path
The only thing it protects now is interrupt injection into lapic and this can work lockless. Even now with kvm->irq_lock in place access to lapic is not entirely serialized since vcpu access doesn't take kvm->irq_lock. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/ia64/kvm/kvm-ia64.c2
-rw-r--r--arch/x86/kvm/i8254.c2
-rw-r--r--arch/x86/kvm/lapic.c2
-rw-r--r--arch/x86/kvm/x86.c2
-rw-r--r--virt/kvm/eventfd.c2
-rw-r--r--virt/kvm/irq_comm.c6
-rw-r--r--virt/kvm/kvm_main.c2
7 files changed, 1 insertions, 17 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 4a983147f6eb..f534e0f6bb0d 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -982,10 +982,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
982 goto out; 982 goto out;
983 if (irqchip_in_kernel(kvm)) { 983 if (irqchip_in_kernel(kvm)) {
984 __s32 status; 984 __s32 status;
985 mutex_lock(&kvm->irq_lock);
986 status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 985 status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,
987 irq_event.irq, irq_event.level); 986 irq_event.irq, irq_event.level);
988 mutex_unlock(&kvm->irq_lock);
989 if (ioctl == KVM_IRQ_LINE_STATUS) { 987 if (ioctl == KVM_IRQ_LINE_STATUS) {
990 irq_event.status = status; 988 irq_event.status = status;
991 if (copy_to_user(argp, &irq_event, 989 if (copy_to_user(argp, &irq_event,
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 144e7f60b5e2..fab7440c9bb2 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -688,10 +688,8 @@ static void __inject_pit_timer_intr(struct kvm *kvm)
688 struct kvm_vcpu *vcpu; 688 struct kvm_vcpu *vcpu;
689 int i; 689 int i;
690 690
691 mutex_lock(&kvm->irq_lock);
692 kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1); 691 kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1);
693 kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0); 692 kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0);
694 mutex_unlock(&kvm->irq_lock);
695 693
696 /* 694 /*
697 * Provides NMI watchdog support via Virtual Wire mode. 695 * Provides NMI watchdog support via Virtual Wire mode.
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index df8bcb0f66d8..8787637b1a9c 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -501,9 +501,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
501 irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode, 501 irq.trig_mode, irq.level, irq.dest_mode, irq.delivery_mode,
502 irq.vector); 502 irq.vector);
503 503
504 mutex_lock(&apic->vcpu->kvm->irq_lock);
505 kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq); 504 kvm_irq_delivery_to_apic(apic->vcpu->kvm, apic, &irq);
506 mutex_unlock(&apic->vcpu->kvm->irq_lock);
507} 505}
508 506
509static u32 apic_get_tmcct(struct kvm_lapic *apic) 507static u32 apic_get_tmcct(struct kvm_lapic *apic)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fdf989f17a61..5beb4c16caab 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2286,10 +2286,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
2286 goto out; 2286 goto out;
2287 if (irqchip_in_kernel(kvm)) { 2287 if (irqchip_in_kernel(kvm)) {
2288 __s32 status; 2288 __s32 status;
2289 mutex_lock(&kvm->irq_lock);
2290 status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 2289 status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID,
2291 irq_event.irq, irq_event.level); 2290 irq_event.irq, irq_event.level);
2292 mutex_unlock(&kvm->irq_lock);
2293 if (ioctl == KVM_IRQ_LINE_STATUS) { 2291 if (ioctl == KVM_IRQ_LINE_STATUS) {
2294 irq_event.status = status; 2292 irq_event.status = status;
2295 if (copy_to_user(argp, &irq_event, 2293 if (copy_to_user(argp, &irq_event,
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index bb4ebd89b9ff..30f70fd511c4 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -61,10 +61,8 @@ irqfd_inject(struct work_struct *work)
61 struct _irqfd *irqfd = container_of(work, struct _irqfd, inject); 61 struct _irqfd *irqfd = container_of(work, struct _irqfd, inject);
62 struct kvm *kvm = irqfd->kvm; 62 struct kvm *kvm = irqfd->kvm;
63 63
64 mutex_lock(&kvm->irq_lock);
65 kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1); 64 kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1);
66 kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0); 65 kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0);
67 mutex_unlock(&kvm->irq_lock);
68} 66}
69 67
70/* 68/*
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index fadf4408a820..15a83b93566d 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -82,8 +82,6 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
82 int i, r = -1; 82 int i, r = -1;
83 struct kvm_vcpu *vcpu, *lowest = NULL; 83 struct kvm_vcpu *vcpu, *lowest = NULL;
84 84
85 WARN_ON(!mutex_is_locked(&kvm->irq_lock));
86
87 if (irq->dest_mode == 0 && irq->dest_id == 0xff && 85 if (irq->dest_mode == 0 && irq->dest_id == 0xff &&
88 kvm_is_dm_lowest_prio(irq)) 86 kvm_is_dm_lowest_prio(irq))
89 printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n"); 87 printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n");
@@ -138,7 +136,7 @@ static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
138 return kvm_irq_delivery_to_apic(kvm, NULL, &irq); 136 return kvm_irq_delivery_to_apic(kvm, NULL, &irq);
139} 137}
140 138
141/* This should be called with the kvm->irq_lock mutex held 139/*
142 * Return value: 140 * Return value:
143 * < 0 Interrupt was ignored (masked or not delivered for other reasons) 141 * < 0 Interrupt was ignored (masked or not delivered for other reasons)
144 * = 0 Interrupt was coalesced (previous irq is still pending) 142 * = 0 Interrupt was coalesced (previous irq is still pending)
@@ -153,8 +151,6 @@ int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level)
153 151
154 trace_kvm_set_irq(irq, level, irq_source_id); 152 trace_kvm_set_irq(irq, level, irq_source_id);
155 153
156 WARN_ON(!mutex_is_locked(&kvm->irq_lock));
157
158 /* Not possible to detect if the guest uses the PIC or the 154 /* Not possible to detect if the guest uses the PIC or the
159 * IOAPIC. So set the bit in both. The guest will ignore 155 * IOAPIC. So set the bit in both. The guest will ignore
160 * writes to the unused one. 156 * writes to the unused one.
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6eca153e1a02..c12c95b1b641 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -137,7 +137,6 @@ static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
137 interrupt_work); 137 interrupt_work);
138 kvm = assigned_dev->kvm; 138 kvm = assigned_dev->kvm;
139 139
140 mutex_lock(&kvm->irq_lock);
141 spin_lock_irq(&assigned_dev->assigned_dev_lock); 140 spin_lock_irq(&assigned_dev->assigned_dev_lock);
142 if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_MSIX) { 141 if (assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_MSIX) {
143 struct kvm_guest_msix_entry *guest_entries = 142 struct kvm_guest_msix_entry *guest_entries =
@@ -156,7 +155,6 @@ static void kvm_assigned_dev_interrupt_work_handler(struct work_struct *work)
156 assigned_dev->guest_irq, 1); 155 assigned_dev->guest_irq, 1);
157 156
158 spin_unlock_irq(&assigned_dev->assigned_dev_lock); 157 spin_unlock_irq(&assigned_dev->assigned_dev_lock);
159 mutex_unlock(&assigned_dev->kvm->irq_lock);
160} 158}
161 159
162static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id) 160static irqreturn_t kvm_assigned_dev_intr(int irq, void *dev_id)