aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/kvm_host.h3
-rw-r--r--virt/kvm/ioapic.c5
-rw-r--r--virt/kvm/kvm_main.c1
3 files changed, 8 insertions, 1 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 19240feefe6f..0c71688b1ee3 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -124,7 +124,6 @@ struct kvm_kernel_irq_routing_entry {
124}; 124};
125 125
126struct kvm { 126struct kvm {
127 struct mutex lock; /* protects the vcpus array and APIC accesses */
128 spinlock_t mmu_lock; 127 spinlock_t mmu_lock;
129 spinlock_t requests_lock; 128 spinlock_t requests_lock;
130 struct rw_semaphore slots_lock; 129 struct rw_semaphore slots_lock;
@@ -134,6 +133,7 @@ struct kvm {
134 KVM_PRIVATE_MEM_SLOTS]; 133 KVM_PRIVATE_MEM_SLOTS];
135 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; 134 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
136 struct list_head vm_list; 135 struct list_head vm_list;
136 struct mutex lock;
137 struct kvm_io_bus mmio_bus; 137 struct kvm_io_bus mmio_bus;
138 struct kvm_io_bus pio_bus; 138 struct kvm_io_bus pio_bus;
139#ifdef CONFIG_HAVE_KVM_EVENTFD 139#ifdef CONFIG_HAVE_KVM_EVENTFD
@@ -150,6 +150,7 @@ struct kvm {
150 struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; 150 struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
151#endif 151#endif
152 152
153 struct mutex irq_lock;
153#ifdef CONFIG_HAVE_KVM_IRQCHIP 154#ifdef CONFIG_HAVE_KVM_IRQCHIP
154 struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */ 155 struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
155 struct hlist_head mask_notifier_list; 156 struct hlist_head mask_notifier_list;
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 469b9faae665..2a5667173995 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -243,6 +243,7 @@ static void ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len,
243 ioapic_debug("addr %lx\n", (unsigned long)addr); 243 ioapic_debug("addr %lx\n", (unsigned long)addr);
244 ASSERT(!(addr & 0xf)); /* check alignment */ 244 ASSERT(!(addr & 0xf)); /* check alignment */
245 245
246 mutex_lock(&ioapic->kvm->irq_lock);
246 addr &= 0xff; 247 addr &= 0xff;
247 switch (addr) { 248 switch (addr) {
248 case IOAPIC_REG_SELECT: 249 case IOAPIC_REG_SELECT:
@@ -269,6 +270,7 @@ static void ioapic_mmio_read(struct kvm_io_device *this, gpa_t addr, int len,
269 default: 270 default:
270 printk(KERN_WARNING "ioapic: wrong length %d\n", len); 271 printk(KERN_WARNING "ioapic: wrong length %d\n", len);
271 } 272 }
273 mutex_unlock(&ioapic->kvm->irq_lock);
272} 274}
273 275
274static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len, 276static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
@@ -280,6 +282,8 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
280 ioapic_debug("ioapic_mmio_write addr=%p len=%d val=%p\n", 282 ioapic_debug("ioapic_mmio_write addr=%p len=%d val=%p\n",
281 (void*)addr, len, val); 283 (void*)addr, len, val);
282 ASSERT(!(addr & 0xf)); /* check alignment */ 284 ASSERT(!(addr & 0xf)); /* check alignment */
285
286 mutex_lock(&ioapic->kvm->irq_lock);
283 if (len == 4 || len == 8) 287 if (len == 4 || len == 8)
284 data = *(u32 *) val; 288 data = *(u32 *) val;
285 else { 289 else {
@@ -305,6 +309,7 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
305 default: 309 default:
306 break; 310 break;
307 } 311 }
312 mutex_unlock(&ioapic->kvm->irq_lock);
308} 313}
309 314
310void kvm_ioapic_reset(struct kvm_ioapic *ioapic) 315void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d1f9c87daa87..d47e660fb709 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -982,6 +982,7 @@ static struct kvm *kvm_create_vm(void)
982 kvm_io_bus_init(&kvm->pio_bus); 982 kvm_io_bus_init(&kvm->pio_bus);
983 kvm_irqfd_init(kvm); 983 kvm_irqfd_init(kvm);
984 mutex_init(&kvm->lock); 984 mutex_init(&kvm->lock);
985 mutex_init(&kvm->irq_lock);
985 kvm_io_bus_init(&kvm->mmio_bus); 986 kvm_io_bus_init(&kvm->mmio_bus);
986 init_rwsem(&kvm->slots_lock); 987 init_rwsem(&kvm->slots_lock);
987 atomic_set(&kvm->users_count, 1); 988 atomic_set(&kvm->users_count, 1);