diff options
-rw-r--r-- | arch/x86/kvm/irq.c | 7 | ||||
-rw-r--r-- | arch/x86/kvm/irq.h | 1 | ||||
-rw-r--r-- | virt/kvm/eventfd.c | 9 |
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 | |||
176 | bool 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 | ||
117 | bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args); | ||
117 | void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); | 118 | void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); |
118 | void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); | 119 | void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); |
119 | void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu); | 120 | void 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 | ||
45 | static struct workqueue_struct *irqfd_cleanup_wq; | 45 | static struct workqueue_struct *irqfd_cleanup_wq; |
46 | 46 | ||
47 | bool __attribute__((weak)) | ||
48 | kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args) | ||
49 | { | ||
50 | return true; | ||
51 | } | ||
52 | |||
47 | static void | 53 | static void |
48 | irqfd_inject(struct work_struct *work) | 54 | irqfd_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; |