@@ -30,7 +30,7 @@ struct irq_desc;
extern void fixup_irqs(void);
#if IS_ENABLED(CONFIG_KVM)
-extern void kvm_set_posted_intr_wakeup_handler(void (*handler)(void));
+void x86_set_kvm_irq_handler(u8 vector, void (*handler)(void));
#endif
extern void (*x86_platform_ipi_callback)(void);
@@ -312,16 +312,22 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_x86_platform_ipi)
static void dummy_handler(void) {}
static void (*kvm_posted_intr_wakeup_handler)(void) = dummy_handler;
-void kvm_set_posted_intr_wakeup_handler(void (*handler)(void))
+void x86_set_kvm_irq_handler(u8 vector, void (*handler)(void))
{
- if (handler)
+ if (!handler)
+ handler = dummy_handler;
+
+ if (vector == POSTED_INTR_WAKEUP_VECTOR &&
+ (handler == dummy_handler ||
+ kvm_posted_intr_wakeup_handler == dummy_handler))
kvm_posted_intr_wakeup_handler = handler;
- else {
- kvm_posted_intr_wakeup_handler = dummy_handler;
+ else
+ WARN_ON_ONCE(1);
+
+ if (handler == dummy_handler)
synchronize_rcu();
- }
}
-EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wakeup_handler);
+EXPORT_SYMBOL_GPL(x86_set_kvm_irq_handler);
/*
* Handler for POSTED_INTERRUPT_VECTOR.
@@ -8292,7 +8292,7 @@ void vmx_migrate_timers(struct kvm_vcpu *vcpu)
void vmx_hardware_unsetup(void)
{
- kvm_set_posted_intr_wakeup_handler(NULL);
+ x86_set_kvm_irq_handler(POSTED_INTR_WAKEUP_VECTOR, NULL);
if (nested)
nested_vmx_hardware_unsetup();
@@ -8602,7 +8602,7 @@ __init int vmx_hardware_setup(void)
if (r && nested)
nested_vmx_hardware_unsetup();
- kvm_set_posted_intr_wakeup_handler(pi_wakeup_handler);
+ x86_set_kvm_irq_handler(POSTED_INTR_WAKEUP_VECTOR, pi_wakeup_handler);
return r;
}