summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kvm/irq.c7
-rw-r--r--arch/x86/kvm/irq.h1
-rw-r--r--virt/kvm/eventfd.c9
3 files changed, 17 insertions, 0 deletions
diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index faa264822cee..007bc654f928 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -172,3 +172,10 @@ void __kvm_migrate_timers(struct kvm_vcpu *vcpu)
172 __kvm_migrate_apic_timer(vcpu); 172 __kvm_migrate_apic_timer(vcpu);
173 __kvm_migrate_pit_timer(vcpu); 173 __kvm_migrate_pit_timer(vcpu);
174} 174}
175
176bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args)
177{
178 bool resample = args->flags & KVM_IRQFD_FLAG_RESAMPLE;
179
180 return resample ? irqchip_kernel(kvm) : irqchip_in_kernel(kvm);
181}
diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
index d5005cc26521..fd210cdd4983 100644
--- a/arch/x86/kvm/irq.h
+++ b/arch/x86/kvm/irq.h
@@ -114,6 +114,7 @@ static inline int irqchip_in_kernel(struct kvm *kvm)
114 return mode != KVM_IRQCHIP_NONE; 114 return mode != KVM_IRQCHIP_NONE;
115} 115}
116 116
117bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args);
117void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); 118void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
118void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); 119void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
119void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu); 120void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu);
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 001aeda4c154..3972a9564c76 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -44,6 +44,12 @@
44 44
45static struct workqueue_struct *irqfd_cleanup_wq; 45static struct workqueue_struct *irqfd_cleanup_wq;
46 46
47bool __attribute__((weak))
48kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args)
49{
50 return true;
51}
52
47static void 53static void
48irqfd_inject(struct work_struct *work) 54irqfd_inject(struct work_struct *work)
49{ 55{
@@ -297,6 +303,9 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
297 if (!kvm_arch_intc_initialized(kvm)) 303 if (!kvm_arch_intc_initialized(kvm))
298 return -EAGAIN; 304 return -EAGAIN;
299 305
306 if (!kvm_arch_irqfd_allowed(kvm, args))
307 return -EINVAL;
308
300 irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL_ACCOUNT); 309 irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL_ACCOUNT);
301 if (!irqfd) 310 if (!irqfd)
302 return -ENOMEM; 311 return -ENOMEM;