aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 11:47:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 11:47:12 -0400
commitb05d59dfceaea72565b1648af929b037b0f96d7f (patch)
treebbe92714be468ed8783bce6ac2c305c0aedf8eb5 /virt
parentdaf342af2f7856fd2f5c66b9fb39a8f24986ca53 (diff)
parent820b3fcdeb80d30410f4427d2cbf9161c35fdeef (diff)
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm into next
Pull KVM updates from Paolo Bonzini: "At over 200 commits, covering almost all supported architectures, this was a pretty active cycle for KVM. Changes include: - a lot of s390 changes: optimizations, support for migration, GDB support and more - ARM changes are pretty small: support for the PSCI 0.2 hypercall interface on both the guest and the host (the latter acked by Catalin) - initial POWER8 and little-endian host support - support for running u-boot on embedded POWER targets - pretty large changes to MIPS too, completing the userspace interface and improving the handling of virtualized timer hardware - for x86, a larger set of changes is scheduled for 3.17. Still, we have a few emulator bugfixes and support for running nested fully-virtualized Xen guests (para-virtualized Xen guests have always worked). And some optimizations too. The only missing architecture here is ia64. It's not a coincidence that support for KVM on ia64 is scheduled for removal in 3.17" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (203 commits) KVM: add missing cleanup_srcu_struct KVM: PPC: Book3S PR: Rework SLB switching code KVM: PPC: Book3S PR: Use SLB entry 0 KVM: PPC: Book3S HV: Fix machine check delivery to guest KVM: PPC: Book3S HV: Work around POWER8 performance monitor bugs KVM: PPC: Book3S HV: Make sure we don't miss dirty pages KVM: PPC: Book3S HV: Fix dirty map for hugepages KVM: PPC: Book3S HV: Put huge-page HPTEs in rmap chain for base address KVM: PPC: Book3S HV: Fix check for running inside guest in global_invalidates() KVM: PPC: Book3S: Move KVM_REG_PPC_WORT to an unused register number KVM: PPC: Book3S: Add ONE_REG register names that were missed KVM: PPC: Add CAP to indicate hcall fixes KVM: PPC: MPIC: Reset IRQ source private members KVM: PPC: Graciously fail broken LE hypercalls PPC: ePAPR: Fix hypercall on LE guest KVM: PPC: BOOK3S: Remove open coded make_dsisr in alignment handler KVM: PPC: BOOK3S: Always use the saved DAR value PPC: KVM: Make NX bit available with magic page KVM: PPC: Disable NX for old magic page using guests KVM: PPC: BOOK3S: HV: Add mixed page-size support for guest ...
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/async_pf.c4
-rw-r--r--virt/kvm/eventfd.c68
-rw-r--r--virt/kvm/irq_comm.c17
-rw-r--r--virt/kvm/irqchip.c31
-rw-r--r--virt/kvm/kvm_main.c25
5 files changed, 95 insertions, 50 deletions
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index 06e6401d6ef4..d6a3d0993d88 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -80,12 +80,10 @@ static void async_pf_execute(struct work_struct *work)
80 80
81 might_sleep(); 81 might_sleep();
82 82
83 use_mm(mm);
84 down_read(&mm->mmap_sem); 83 down_read(&mm->mmap_sem);
85 get_user_pages(current, mm, addr, 1, 1, 0, NULL, NULL); 84 get_user_pages(NULL, mm, addr, 1, 1, 0, NULL, NULL);
86 up_read(&mm->mmap_sem); 85 up_read(&mm->mmap_sem);
87 kvm_async_page_present_sync(vcpu, apf); 86 kvm_async_page_present_sync(vcpu, apf);
88 unuse_mm(mm);
89 87
90 spin_lock(&vcpu->async_pf.lock); 88 spin_lock(&vcpu->async_pf.lock);
91 list_add_tail(&apf->link, &vcpu->async_pf.done); 89 list_add_tail(&apf->link, &vcpu->async_pf.done);
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 29c2a04e036e..20c3af7692c5 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -31,6 +31,7 @@
31#include <linux/list.h> 31#include <linux/list.h>
32#include <linux/eventfd.h> 32#include <linux/eventfd.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/srcu.h>
34#include <linux/slab.h> 35#include <linux/slab.h>
35 36
36#include "iodev.h" 37#include "iodev.h"
@@ -118,19 +119,22 @@ static void
118irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian) 119irqfd_resampler_ack(struct kvm_irq_ack_notifier *kian)
119{ 120{
120 struct _irqfd_resampler *resampler; 121 struct _irqfd_resampler *resampler;
122 struct kvm *kvm;
121 struct _irqfd *irqfd; 123 struct _irqfd *irqfd;
124 int idx;
122 125
123 resampler = container_of(kian, struct _irqfd_resampler, notifier); 126 resampler = container_of(kian, struct _irqfd_resampler, notifier);
127 kvm = resampler->kvm;
124 128
125 kvm_set_irq(resampler->kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID, 129 kvm_set_irq(kvm, KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID,
126 resampler->notifier.gsi, 0, false); 130 resampler->notifier.gsi, 0, false);
127 131
128 rcu_read_lock(); 132 idx = srcu_read_lock(&kvm->irq_srcu);
129 133
130 list_for_each_entry_rcu(irqfd, &resampler->list, resampler_link) 134 list_for_each_entry_rcu(irqfd, &resampler->list, resampler_link)
131 eventfd_signal(irqfd->resamplefd, 1); 135 eventfd_signal(irqfd->resamplefd, 1);
132 136
133 rcu_read_unlock(); 137 srcu_read_unlock(&kvm->irq_srcu, idx);
134} 138}
135 139
136static void 140static void
@@ -142,7 +146,7 @@ irqfd_resampler_shutdown(struct _irqfd *irqfd)
142 mutex_lock(&kvm->irqfds.resampler_lock); 146 mutex_lock(&kvm->irqfds.resampler_lock);
143 147
144 list_del_rcu(&irqfd->resampler_link); 148 list_del_rcu(&irqfd->resampler_link);
145 synchronize_rcu(); 149 synchronize_srcu(&kvm->irq_srcu);
146 150
147 if (list_empty(&resampler->list)) { 151 if (list_empty(&resampler->list)) {
148 list_del(&resampler->link); 152 list_del(&resampler->link);
@@ -221,17 +225,18 @@ irqfd_wakeup(wait_queue_t *wait, unsigned mode, int sync, void *key)
221 unsigned long flags = (unsigned long)key; 225 unsigned long flags = (unsigned long)key;
222 struct kvm_kernel_irq_routing_entry *irq; 226 struct kvm_kernel_irq_routing_entry *irq;
223 struct kvm *kvm = irqfd->kvm; 227 struct kvm *kvm = irqfd->kvm;
228 int idx;
224 229
225 if (flags & POLLIN) { 230 if (flags & POLLIN) {
226 rcu_read_lock(); 231 idx = srcu_read_lock(&kvm->irq_srcu);
227 irq = rcu_dereference(irqfd->irq_entry); 232 irq = srcu_dereference(irqfd->irq_entry, &kvm->irq_srcu);
228 /* An event has been signaled, inject an interrupt */ 233 /* An event has been signaled, inject an interrupt */
229 if (irq) 234 if (irq)
230 kvm_set_msi(irq, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1, 235 kvm_set_msi(irq, kvm, KVM_USERSPACE_IRQ_SOURCE_ID, 1,
231 false); 236 false);
232 else 237 else
233 schedule_work(&irqfd->inject); 238 schedule_work(&irqfd->inject);
234 rcu_read_unlock(); 239 srcu_read_unlock(&kvm->irq_srcu, idx);
235 } 240 }
236 241
237 if (flags & POLLHUP) { 242 if (flags & POLLHUP) {
@@ -363,7 +368,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
363 } 368 }
364 369
365 list_add_rcu(&irqfd->resampler_link, &irqfd->resampler->list); 370 list_add_rcu(&irqfd->resampler_link, &irqfd->resampler->list);
366 synchronize_rcu(); 371 synchronize_srcu(&kvm->irq_srcu);
367 372
368 mutex_unlock(&kvm->irqfds.resampler_lock); 373 mutex_unlock(&kvm->irqfds.resampler_lock);
369 } 374 }
@@ -465,7 +470,7 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args)
465 * another thread calls kvm_irq_routing_update before 470 * another thread calls kvm_irq_routing_update before
466 * we flush workqueue below (we synchronize with 471 * we flush workqueue below (we synchronize with
467 * kvm_irq_routing_update using irqfds.lock). 472 * kvm_irq_routing_update using irqfds.lock).
468 * It is paired with synchronize_rcu done by caller 473 * It is paired with synchronize_srcu done by caller
469 * of that function. 474 * of that function.
470 */ 475 */
471 rcu_assign_pointer(irqfd->irq_entry, NULL); 476 rcu_assign_pointer(irqfd->irq_entry, NULL);
@@ -524,7 +529,7 @@ kvm_irqfd_release(struct kvm *kvm)
524 529
525/* 530/*
526 * Change irq_routing and irqfd. 531 * Change irq_routing and irqfd.
527 * Caller must invoke synchronize_rcu afterwards. 532 * Caller must invoke synchronize_srcu(&kvm->irq_srcu) afterwards.
528 */ 533 */
529void kvm_irq_routing_update(struct kvm *kvm, 534void kvm_irq_routing_update(struct kvm *kvm,
530 struct kvm_irq_routing_table *irq_rt) 535 struct kvm_irq_routing_table *irq_rt)
@@ -600,7 +605,15 @@ ioeventfd_in_range(struct _ioeventfd *p, gpa_t addr, int len, const void *val)
600{ 605{
601 u64 _val; 606 u64 _val;
602 607
603 if (!(addr == p->addr && len == p->length)) 608 if (addr != p->addr)
609 /* address must be precise for a hit */
610 return false;
611
612 if (!p->length)
613 /* length = 0 means only look at the address, so always a hit */
614 return true;
615
616 if (len != p->length)
604 /* address-range must be precise for a hit */ 617 /* address-range must be precise for a hit */
605 return false; 618 return false;
606 619
@@ -671,9 +684,11 @@ ioeventfd_check_collision(struct kvm *kvm, struct _ioeventfd *p)
671 684
672 list_for_each_entry(_p, &kvm->ioeventfds, list) 685 list_for_each_entry(_p, &kvm->ioeventfds, list)
673 if (_p->bus_idx == p->bus_idx && 686 if (_p->bus_idx == p->bus_idx &&
674 _p->addr == p->addr && _p->length == p->length && 687 _p->addr == p->addr &&
675 (_p->wildcard || p->wildcard || 688 (!_p->length || !p->length ||
676 _p->datamatch == p->datamatch)) 689 (_p->length == p->length &&
690 (_p->wildcard || p->wildcard ||
691 _p->datamatch == p->datamatch))))
677 return true; 692 return true;
678 693
679 return false; 694 return false;
@@ -697,8 +712,9 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
697 int ret; 712 int ret;
698 713
699 bus_idx = ioeventfd_bus_from_flags(args->flags); 714 bus_idx = ioeventfd_bus_from_flags(args->flags);
700 /* must be natural-word sized */ 715 /* must be natural-word sized, or 0 to ignore length */
701 switch (args->len) { 716 switch (args->len) {