aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorGregory Haskins <ghaskins@novell.com>2009-05-20 10:30:49 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:32:41 -0400
commit721eecbf4fe995ca94a9edec0c9843b1cc0eaaf3 (patch)
treec759fe98a4ea5e2e2a7694e4b44a558407077290 /virt/kvm/kvm_main.c
parent0ba12d10817a8db1fd7d96d3283ec6c0b294aeab (diff)
KVM: irqfd
KVM provides a complete virtual system environment for guests, including support for injecting interrupts modeled after the real exception/interrupt facilities present on the native platform (such as the IDT on x86). Virtual interrupts can come from a variety of sources (emulated devices, pass-through devices, etc) but all must be injected to the guest via the KVM infrastructure. This patch adds a new mechanism to inject a specific interrupt to a guest using a decoupled eventfd mechnanism: Any legal signal on the irqfd (using eventfd semantics from either userspace or kernel) will translate into an injected interrupt in the guest at the next available interrupt window. Signed-off-by: Gregory Haskins <ghaskins@novell.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2884baf1d5f9..dee321e58894 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -986,6 +986,7 @@ static struct kvm *kvm_create_vm(void)
986 spin_lock_init(&kvm->mmu_lock); 986 spin_lock_init(&kvm->mmu_lock);
987 spin_lock_init(&kvm->requests_lock); 987 spin_lock_init(&kvm->requests_lock);
988 kvm_io_bus_init(&kvm->pio_bus); 988 kvm_io_bus_init(&kvm->pio_bus);
989 kvm_irqfd_init(kvm);
989 mutex_init(&kvm->lock); 990 mutex_init(&kvm->lock);
990 kvm_io_bus_init(&kvm->mmio_bus); 991 kvm_io_bus_init(&kvm->mmio_bus);
991 init_rwsem(&kvm->slots_lock); 992 init_rwsem(&kvm->slots_lock);
@@ -1071,6 +1072,8 @@ static int kvm_vm_release(struct inode *inode, struct file *filp)
1071{ 1072{
1072 struct kvm *kvm = filp->private_data; 1073 struct kvm *kvm = filp->private_data;
1073 1074
1075 kvm_irqfd_release(kvm);
1076
1074 kvm_put_kvm(kvm); 1077 kvm_put_kvm(kvm);
1075 return 0; 1078 return 0;
1076} 1079}
@@ -2222,6 +2225,15 @@ static long kvm_vm_ioctl(struct file *filp,
2222 } 2225 }
2223#endif 2226#endif
2224#endif /* KVM_CAP_IRQ_ROUTING */ 2227#endif /* KVM_CAP_IRQ_ROUTING */
2228 case KVM_IRQFD: {
2229 struct kvm_irqfd data;
2230
2231 r = -EFAULT;
2232 if (copy_from_user(&data, argp, sizeof data))
2233 goto out;
2234 r = kvm_irqfd(kvm, data.fd, data.gsi, data.flags);
2235 break;
2236 }
2225 default: 2237 default:
2226 r = kvm_arch_vm_ioctl(filp, ioctl, arg); 2238 r = kvm_arch_vm_ioctl(filp, ioctl, arg);
2227 } 2239 }